repo
stringlengths 1
152
⌀ | file
stringlengths 14
221
| code
stringlengths 501
25k
| file_length
int64 501
25k
| avg_line_length
float64 20
99.5
| max_line_length
int64 21
134
| extension_type
stringclasses 2
values |
---|---|---|---|---|---|---|
null | ceph-main/src/messages/MClientCapRelease.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MCLIENTCAPRELEASE_H
#define CEPH_MCLIENTCAPRELEASE_H
#include "msg/Message.h"
class MClientCapRelease final : public SafeMessage {
public:
std::string_view get_type_name() const override { return "client_cap_release";}
void print(std::ostream& out) const override {
out << "client_cap_release(" << caps.size() << ")";
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(head, p);
ceph::decode_nohead(head.num, caps, p);
if (header.version >= 2) {
decode(osd_epoch_barrier, p);
}
}
void encode_payload(uint64_t features) override {
using ceph::encode;
head.num = caps.size();
encode(head, payload);
ceph::encode_nohead(caps, payload);
encode(osd_epoch_barrier, payload);
}
struct ceph_mds_cap_release head;
std::vector<ceph_mds_cap_item> caps;
// The message receiver must wait for this OSD epoch
// before actioning this cap release.
epoch_t osd_epoch_barrier = 0;
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
static constexpr int HEAD_VERSION = 2;
static constexpr int COMPAT_VERSION = 1;
MClientCapRelease() :
SafeMessage{CEPH_MSG_CLIENT_CAPRELEASE, HEAD_VERSION, COMPAT_VERSION}
{
memset(&head, 0, sizeof(head));
}
~MClientCapRelease() final {}
};
#endif
| 1,913 | 26.342857 | 81 | h |
null | ceph-main/src/messages/MClientCaps.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MCLIENTCAPS_H
#define CEPH_MCLIENTCAPS_H
#include "msg/Message.h"
#include "mds/mdstypes.h"
#include "include/ceph_features.h"
class MClientCaps final : public SafeMessage {
private:
static constexpr int HEAD_VERSION = 12;
static constexpr int COMPAT_VERSION = 1;
public:
static constexpr unsigned FLAG_SYNC = (1<<0);
static constexpr unsigned FLAG_NO_CAPSNAP = (1<<1); // unused
static constexpr unsigned FLAG_PENDING_CAPSNAP = (1<<2);
struct ceph_mds_caps_head head;
uint64_t size = 0;
uint64_t max_size = 0;
uint64_t truncate_size = 0;
uint64_t change_attr = 0;
uint32_t truncate_seq = 0;
utime_t mtime, atime, ctime, btime;
uint32_t time_warp_seq = 0;
int64_t nfiles = -1; // files in dir
int64_t nsubdirs = -1; // subdirs in dir
struct ceph_mds_cap_peer peer;
ceph::buffer::list snapbl;
ceph::buffer::list xattrbl;
ceph::buffer::list flockbl;
version_t inline_version = 0;
ceph::buffer::list inline_data;
// Receivers may not use their new caps until they have this OSD map
epoch_t osd_epoch_barrier = 0;
ceph_tid_t oldest_flush_tid = 0;
uint32_t caller_uid = 0;
uint32_t caller_gid = 0;
/* advisory CLIENT_CAPS_* flags to send to mds */
unsigned flags = 0;
std::vector<uint8_t> fscrypt_auth;
std::vector<uint8_t> fscrypt_file;
int get_caps() const { return head.caps; }
int get_wanted() const { return head.wanted; }
int get_dirty() const { return head.dirty; }
ceph_seq_t get_seq() const { return head.seq; }
ceph_seq_t get_issue_seq() const { return head.issue_seq; }
ceph_seq_t get_mseq() const { return head.migrate_seq; }
inodeno_t get_ino() const { return inodeno_t(head.ino); }
inodeno_t get_realm() const { return inodeno_t(head.realm); }
uint64_t get_cap_id() const { return head.cap_id; }
uint64_t get_size() const { return size; }
uint64_t get_max_size() const { return max_size; }
__u32 get_truncate_seq() const { return truncate_seq; }
uint64_t get_truncate_size() const { return truncate_size; }
utime_t get_ctime() const { return ctime; }
utime_t get_btime() const { return btime; }
utime_t get_mtime() const { return mtime; }
utime_t get_atime() const { return atime; }
__u64 get_change_attr() const { return change_attr; }
__u32 get_time_warp_seq() const { return time_warp_seq; }
uint64_t get_nfiles() const { return nfiles; }
uint64_t get_nsubdirs() const { return nsubdirs; }
bool dirstat_is_valid() const { return nfiles != -1 || nsubdirs != -1; }
const file_layout_t& get_layout() const {
return layout;
}
void set_layout(const file_layout_t &l) {
layout = l;
}
int get_migrate_seq() const { return head.migrate_seq; }
int get_op() const { return head.op; }
uint64_t get_client_tid() const { return get_tid(); }
void set_client_tid(uint64_t s) { set_tid(s); }
snapid_t get_snap_follows() const { return snapid_t(head.snap_follows); }
void set_snap_follows(snapid_t s) { head.snap_follows = s; }
void set_caps(int c) { head.caps = c; }
void set_wanted(int w) { head.wanted = w; }
void set_max_size(uint64_t ms) { max_size = ms; }
void set_migrate_seq(unsigned m) { head.migrate_seq = m; }
void set_op(int o) { head.op = o; }
void set_size(loff_t s) { size = s; }
void set_mtime(const utime_t &t) { mtime = t; }
void set_ctime(const utime_t &t) { ctime = t; }
void set_atime(const utime_t &t) { atime = t; }
void set_cap_peer(uint64_t id, ceph_seq_t seq, ceph_seq_t mseq, int mds, int flags) {
peer.cap_id = id;
peer.seq = seq;
peer.mseq = mseq;
peer.mds = mds;
peer.flags = flags;
}
void set_oldest_flush_tid(ceph_tid_t tid) { oldest_flush_tid = tid; }
ceph_tid_t get_oldest_flush_tid() const { return oldest_flush_tid; }
void clear_dirty() { head.dirty = 0; }
protected:
MClientCaps()
: SafeMessage{CEPH_MSG_CLIENT_CAPS, HEAD_VERSION, COMPAT_VERSION} {}
MClientCaps(int op,
inodeno_t ino,
inodeno_t realm,
uint64_t id,
long seq,
int caps,
int wanted,
int dirty,
int mseq,
epoch_t oeb)
: SafeMessage{CEPH_MSG_CLIENT_CAPS, HEAD_VERSION, COMPAT_VERSION},
osd_epoch_barrier(oeb) {
memset(&head, 0, sizeof(head));
head.op = op;
head.ino = ino;
head.realm = realm;
head.cap_id = id;
head.seq = seq;
head.caps = caps;
head.wanted = wanted;
head.dirty = dirty;
head.migrate_seq = mseq;
memset(&peer, 0, sizeof(peer));
}
MClientCaps(int op,
inodeno_t ino, inodeno_t realm,
uint64_t id, int mseq, epoch_t oeb)
: SafeMessage{CEPH_MSG_CLIENT_CAPS, HEAD_VERSION, COMPAT_VERSION},
osd_epoch_barrier(oeb) {
memset(&head, 0, sizeof(head));
head.op = op;
head.ino = ino;
head.realm = realm;
head.cap_id = id;
head.migrate_seq = mseq;
memset(&peer, 0, sizeof(peer));
}
~MClientCaps() final {}
private:
file_layout_t layout;
public:
std::string_view get_type_name() const override { return "Cfcap";}
void print(std::ostream& out) const override {
out << "client_caps(" << ceph_cap_op_name(head.op)
<< " ino " << inodeno_t(head.ino)
<< " " << head.cap_id
<< " seq " << head.seq;
if (get_tid())
out << " tid " << get_tid();
out << " caps=" << ccap_string(head.caps)
<< " dirty=" << ccap_string(head.dirty)
<< " wanted=" << ccap_string(head.wanted);
out << " follows " << snapid_t(head.snap_follows);
if (head.migrate_seq)
out << " mseq " << head.migrate_seq;
out << " size " << size << "/" << max_size;
if (truncate_seq)
out << " ts " << truncate_seq << "/" << truncate_size;
out << " mtime " << mtime
<< " ctime " << ctime
<< " change_attr " << change_attr;
if (time_warp_seq)
out << " tws " << time_warp_seq;
if (head.xattr_version)
out << " xattrs(v=" << head.xattr_version << " l=" << xattrbl.length() << ")";
out << ")";
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(head, p);
if (head.op == CEPH_CAP_OP_EXPORT) {
ceph_mds_caps_export_body body;
decode(body, p);
peer = body.peer;
p += (sizeof(ceph_mds_caps_non_export_body) -
sizeof(ceph_mds_caps_export_body));
} else {
ceph_mds_caps_non_export_body body;
decode(body, p);
size = body.size;
max_size = body.max_size;
truncate_size = body.truncate_size;
truncate_seq = body.truncate_seq;
mtime = utime_t(body.mtime);
atime = utime_t(body.atime);
ctime = utime_t(body.ctime);
layout.from_legacy(body.layout);
time_warp_seq = body.time_warp_seq;
}
ceph::decode_nohead(head.snap_trace_len, snapbl, p);
ceph_assert(middle.length() == head.xattr_len);
if (head.xattr_len)
xattrbl = middle;
// conditionally decode flock metadata
if (header.version >= 2)
decode(flockbl, p);
if (header.version >= 3) {
if (head.op == CEPH_CAP_OP_IMPORT)
decode(peer, p);
}
if (header.version >= 4) {
decode(inline_version, p);
decode(inline_data, p);
} else {
inline_version = CEPH_INLINE_NONE;
}
if (header.version >= 5) {
decode(osd_epoch_barrier, p);
}
if (header.version >= 6) {
decode(oldest_flush_tid, p);
}
if (header.version >= 7) {
decode(caller_uid, p);
decode(caller_gid, p);
}
if (header.version >= 8) {
decode(layout.pool_ns, p);
}
if (header.version >= 9) {
decode(btime, p);
decode(change_attr, p);
}
if (header.version >= 10) {
decode(flags, p);
}
if (header.version >= 11) {
decode(nfiles, p);
decode(nsubdirs, p);
}
if (header.version >= 12) {
decode(fscrypt_auth, p);
decode(fscrypt_file, p);
}
}
void encode_payload(uint64_t features) override {
using ceph::encode;
header.version = HEAD_VERSION;
head.snap_trace_len = snapbl.length();
head.xattr_len = xattrbl.length();
encode(head, payload);
static_assert(sizeof(ceph_mds_caps_non_export_body) >
sizeof(ceph_mds_caps_export_body));
if (head.op == CEPH_CAP_OP_EXPORT) {
ceph_mds_caps_export_body body;
body.peer = peer;
encode(body, payload);
payload.append_zero(sizeof(ceph_mds_caps_non_export_body) -
sizeof(ceph_mds_caps_export_body));
} else {
ceph_mds_caps_non_export_body body;
body.size = size;
body.max_size = max_size;
body.truncate_size = truncate_size;
body.truncate_seq = truncate_seq;
mtime.encode_timeval(&body.mtime);
atime.encode_timeval(&body.atime);
ctime.encode_timeval(&body.ctime);
layout.to_legacy(&body.layout);
body.time_warp_seq = time_warp_seq;
encode(body, payload);
}
ceph::encode_nohead(snapbl, payload);
middle = xattrbl;
// conditionally include flock metadata
if (features & CEPH_FEATURE_FLOCK) {
encode(flockbl, payload);
} else {
header.version = 1;
return;
}
if (features & CEPH_FEATURE_EXPORT_PEER) {
if (head.op == CEPH_CAP_OP_IMPORT)
encode(peer, payload);
} else {
header.version = 2;
return;
}
if (features & CEPH_FEATURE_MDS_INLINE_DATA) {
encode(inline_version, payload);
encode(inline_data, payload);
} else {
encode(inline_version, payload);
encode(ceph::buffer::list(), payload);
}
encode(osd_epoch_barrier, payload);
encode(oldest_flush_tid, payload);
encode(caller_uid, payload);
encode(caller_gid, payload);
encode(layout.pool_ns, payload);
encode(btime, payload);
encode(change_attr, payload);
encode(flags, payload);
encode(nfiles, payload);
encode(nsubdirs, payload);
encode(fscrypt_auth, payload);
encode(fscrypt_file, payload);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 10,587 | 28.32964 | 87 | h |
null | ceph-main/src/messages/MClientLease.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MCLIENTLEASE_H
#define CEPH_MCLIENTLEASE_H
#include <string_view>
#include "msg/Message.h"
class MClientLease final : public SafeMessage {
public:
struct ceph_mds_lease h;
std::string dname;
int get_action() const { return h.action; }
ceph_seq_t get_seq() const { return h.seq; }
int get_mask() const { return h.mask; }
inodeno_t get_ino() const { return inodeno_t(h.ino); }
snapid_t get_first() const { return snapid_t(h.first); }
snapid_t get_last() const { return snapid_t(h.last); }
protected:
MClientLease() : SafeMessage(CEPH_MSG_CLIENT_LEASE) {}
MClientLease(const MClientLease& m) :
SafeMessage(CEPH_MSG_CLIENT_LEASE),
h(m.h),
dname(m.dname) {}
MClientLease(int ac, ceph_seq_t seq, int m, uint64_t i, uint64_t sf, uint64_t sl) :
SafeMessage(CEPH_MSG_CLIENT_LEASE) {
h.action = ac;
h.seq = seq;
h.mask = m;
h.ino = i;
h.first = sf;
h.last = sl;
h.duration_ms = 0;
}
MClientLease(int ac, ceph_seq_t seq, int m, uint64_t i, uint64_t sf, uint64_t sl, std::string_view d) :
SafeMessage(CEPH_MSG_CLIENT_LEASE),
dname(d) {
h.action = ac;
h.seq = seq;
h.mask = m;
h.ino = i;
h.first = sf;
h.last = sl;
h.duration_ms = 0;
}
~MClientLease() final {}
public:
std::string_view get_type_name() const override { return "client_lease"; }
void print(std::ostream& out) const override {
out << "client_lease(a=" << ceph_lease_op_name(get_action())
<< " seq " << get_seq()
<< " mask " << get_mask();
out << " " << get_ino();
if (h.last != CEPH_NOSNAP)
out << " [" << snapid_t(h.first) << "," << snapid_t(h.last) << "]";
if (dname.length())
out << "/" << dname;
out << ")";
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(h, p);
decode(dname, p);
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(h, payload);
encode(dname, payload);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 2,656 | 26.112245 | 105 | h |
null | ceph-main/src/messages/MClientMetrics.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
#ifndef CEPH_MDS_CLIENT_METRICS_H
#define CEPH_MDS_CLIENT_METRICS_H
#include <vector>
#include "msg/Message.h"
#include "include/cephfs/metrics/Types.h"
class MClientMetrics final : public SafeMessage {
private:
static constexpr int HEAD_VERSION = 1;
static constexpr int COMPAT_VERSION = 1;
public:
std::vector<ClientMetricMessage> updates;
protected:
MClientMetrics() : MClientMetrics(std::vector<ClientMetricMessage>{}) { }
MClientMetrics(std::vector<ClientMetricMessage> updates)
: SafeMessage(CEPH_MSG_CLIENT_METRICS, HEAD_VERSION, COMPAT_VERSION), updates(updates) {
}
~MClientMetrics() final {}
public:
std::string_view get_type_name() const override {
return "client_metrics";
}
void print(std::ostream &out) const override {
out << "client_metrics ";
for (auto &i : updates) {
i.print(&out);
}
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(updates, payload);
}
void decode_payload() override {
using ceph::decode;
auto iter = payload.cbegin();
decode(updates, iter);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif // CEPH_MDS_CLIENT_METRICS_H
| 1,446 | 24.385965 | 92 | h |
null | ceph-main/src/messages/MClientQuota.h | #ifndef CEPH_MCLIENTQUOTA_H
#define CEPH_MCLIENTQUOTA_H
#include "msg/Message.h"
class MClientQuota final : public SafeMessage {
public:
inodeno_t ino;
nest_info_t rstat;
quota_info_t quota;
protected:
MClientQuota() :
SafeMessage{CEPH_MSG_CLIENT_QUOTA},
ino(0)
{}
~MClientQuota() final {}
public:
std::string_view get_type_name() const override { return "client_quota"; }
void print(std::ostream& out) const override {
out << "client_quota(";
out << " [" << ino << "] ";
out << rstat << " ";
out << quota;
out << ")";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(ino, payload);
encode(rstat.rctime, payload);
encode(rstat.rbytes, payload);
encode(rstat.rfiles, payload);
encode(rstat.rsubdirs, payload);
encode(quota, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(ino, p);
decode(rstat.rctime, p);
decode(rstat.rbytes, p);
decode(rstat.rfiles, p);
decode(rstat.rsubdirs, p);
decode(quota, p);
ceph_assert(p.end());
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 1,350 | 22.701754 | 76 | h |
null | ceph-main/src/messages/MClientReclaim.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MCLIENTRECLAIM_H
#define CEPH_MCLIENTRECLAIM_H
#include "msg/Message.h"
class MClientReclaim final : public SafeMessage {
public:
static constexpr int HEAD_VERSION = 1;
static constexpr int COMPAT_VERSION = 1;
static constexpr uint32_t FLAG_FINISH = 1U << 31;
uint32_t get_flags() const { return flags; }
std::string_view get_uuid() const { return uuid; }
std::string_view get_type_name() const override { return "client_reclaim"; }
void print(std::ostream& o) const override {
std::ios_base::fmtflags f(o.flags());
o << "client_reclaim(" << get_uuid() << " flags 0x" << std::hex << get_flags() << ")";
o.flags(f);
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(uuid, payload);
encode(flags, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(uuid, p);
decode(flags, p);
}
protected:
MClientReclaim() :
SafeMessage{CEPH_MSG_CLIENT_RECLAIM, HEAD_VERSION, COMPAT_VERSION} {}
MClientReclaim(std::string_view _uuid, uint32_t _flags) :
SafeMessage{CEPH_MSG_CLIENT_RECLAIM, HEAD_VERSION, COMPAT_VERSION},
uuid(_uuid), flags(_flags) {}
private:
~MClientReclaim() final {}
std::string uuid;
uint32_t flags = 0;
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 1,934 | 27.043478 | 90 | h |
null | ceph-main/src/messages/MClientReclaimReply.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MCLIENTRECLAIMREPLY_H
#define CEPH_MCLIENTRECLAIMREPLY_H
#include "msg/Message.h"
class MClientReclaimReply final : public SafeMessage {
public:
static constexpr int HEAD_VERSION = 1;
static constexpr int COMPAT_VERSION = 1;
int32_t get_result() const { return result; }
void set_result(int r) { result = r; }
epoch_t get_epoch() const { return epoch; }
void set_epoch(epoch_t e) { epoch = e; }
const entity_addrvec_t& get_addrs() const { return addrs; }
void set_addrs(const entity_addrvec_t& _addrs) { addrs = _addrs; }
std::string_view get_type_name() const override { return "client_reclaim_reply"; }
void print(std::ostream& o) const override {
o << "client_reclaim_reply(" << result << " e " << epoch << ")";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(result, payload);
encode(epoch, payload);
encode(addrs, payload, features);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(result, p);
decode(epoch, p);
decode(addrs, p);
}
protected:
MClientReclaimReply() :
MClientReclaimReply{0, 0}
{}
MClientReclaimReply(int r, epoch_t e=0) :
SafeMessage{CEPH_MSG_CLIENT_RECLAIM_REPLY, HEAD_VERSION, COMPAT_VERSION},
result(r), epoch(e) {}
private:
~MClientReclaimReply() final {}
int32_t result;
epoch_t epoch;
entity_addrvec_t addrs;
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 2,071 | 26.626667 | 84 | h |
null | ceph-main/src/messages/MClientReconnect.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MCLIENTRECONNECT_H
#define CEPH_MCLIENTRECONNECT_H
#include "msg/Message.h"
#include "mds/mdstypes.h"
#include "include/ceph_features.h"
class MClientReconnect final : public SafeMessage {
private:
static constexpr int HEAD_VERSION = 5;
static constexpr int COMPAT_VERSION = 4;
public:
std::map<inodeno_t, cap_reconnect_t> caps; // only head inodes
std::vector<snaprealm_reconnect_t> realms;
bool more = false;
private:
MClientReconnect() :
SafeMessage{CEPH_MSG_CLIENT_RECONNECT, HEAD_VERSION, COMPAT_VERSION} {}
~MClientReconnect() final {}
size_t cap_size = 0;
size_t realm_size = 0;
size_t approx_size = sizeof(__u32) + sizeof(__u32) + 1;
void calc_item_size() {
using ceph::encode;
{
ceph::buffer::list bl;
inodeno_t ino;
cap_reconnect_t cr;
encode(ino, bl);
encode(cr, bl);
cap_size = bl.length();
}
{
ceph::buffer::list bl;
snaprealm_reconnect_t sr;
encode(sr, bl);
realm_size = bl.length();
}
}
public:
std::string_view get_type_name() const override { return "client_reconnect"; }
void print(std::ostream& out) const override {
out << "client_reconnect("
<< caps.size() << " caps " << realms.size() << " realms )";
}
// Force to use old encoding.
// Use connection's features to choose encoding if version is set to 0.
void set_encoding_version(int v) {
header.version = v;
if (v <= 3)
header.compat_version = 0;
}
size_t get_approx_size() {
return approx_size;
}
void mark_more() { more = true; }
bool has_more() const { return more; }
void add_cap(inodeno_t ino, uint64_t cap_id, inodeno_t pathbase, const std::string& path,
int wanted, int issued, inodeno_t sr, snapid_t sf, ceph::buffer::list& lb)
{
caps[ino] = cap_reconnect_t(cap_id, pathbase, path, wanted, issued, sr, sf, lb);
if (!cap_size)
calc_item_size();
approx_size += cap_size + path.length() + lb.length();
}
void add_snaprealm(inodeno_t ino, snapid_t seq, inodeno_t parent) {
snaprealm_reconnect_t r;
r.realm.ino = ino;
r.realm.seq = seq;
r.realm.parent = parent;
realms.push_back(r);
if (!realm_size)
calc_item_size();
approx_size += realm_size;
}
void encode_payload(uint64_t features) override {
if (header.version == 0) {
if (features & CEPH_FEATURE_MDSENC)
header.version = 3;
else if (features & CEPH_FEATURE_FLOCK)
header.version = 2;
else
header.version = 1;
}
using ceph::encode;
data.clear();
if (header.version >= 4) {
encode(caps, data);
encode(realms, data);
encode(more, data);
} else {
// compat crap
if (header.version == 3) {
encode(caps, data);
} else if (header.version == 2) {
__u32 n = caps.size();
encode(n, data);
for (auto& p : caps) {
encode(p.first, data);
p.second.encode_old(data);
}
} else {
std::map<inodeno_t, old_cap_reconnect_t> ocaps;
for (auto& p : caps) {
ocaps[p.first] = p.second;
encode(ocaps, data);
}
for (auto& r : realms)
r.encode_old(data);
}
}
}
void decode_payload() override {
using ceph::decode;
auto p = data.cbegin();
if (header.version >= 4) {
decode(caps, p);
decode(realms, p);
if (header.version >= 5)
decode(more, p);
} else {
// compat crap
if (header.version == 3) {
decode(caps, p);
} else if (header.version == 2) {
__u32 n;
decode(n, p);
inodeno_t ino;
while (n--) {
decode(ino, p);
caps[ino].decode_old(p);
}
} else {
std::map<inodeno_t, old_cap_reconnect_t> ocaps;
decode(ocaps, p);
for (auto &q : ocaps)
caps[q.first] = q.second;
}
while (!p.end()) {
realms.push_back(snaprealm_reconnect_t());
realms.back().decode_old(p);
}
}
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 4,489 | 24.083799 | 91 | h |
null | ceph-main/src/messages/MClientReply.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MCLIENTREPLY_H
#define CEPH_MCLIENTREPLY_H
#include "include/types.h"
#include "include/fs_types.h"
#include "include/mempool.h"
#include "MClientRequest.h"
#include "msg/Message.h"
#include "include/ceph_features.h"
#include "common/errno.h"
#include "common/strescape.h"
/***
*
* MClientReply - container message for MDS reply to a client's MClientRequest
*
* key fields:
* long tid - transaction id, so the client can match up with pending request
* int result - error code, or fh if it was open
*
* for most requests:
* trace is a vector of InodeStat's tracing from root to the file/dir/whatever
* the operation referred to, so that the client can update it's info about what
* metadata lives on what MDS.
*
* for readdir replies:
* dir_contents is a vector of InodeStat*'s.
*
* that's mostly it, i think!
*
*/
struct LeaseStat {
// this matches ceph_mds_reply_lease
__u16 mask = 0;
__u32 duration_ms = 0;
__u32 seq = 0;
std::string alternate_name;
LeaseStat() = default;
LeaseStat(__u16 msk, __u32 dur, __u32 sq) : mask{msk}, duration_ms{dur}, seq{sq} {}
void decode(ceph::buffer::list::const_iterator &bl, const uint64_t features) {
using ceph::decode;
if (features == (uint64_t)-1) {
DECODE_START(2, bl);
decode(mask, bl);
decode(duration_ms, bl);
decode(seq, bl);
if (struct_v >= 2)
decode(alternate_name, bl);
DECODE_FINISH(bl);
}
else {
decode(mask, bl);
decode(duration_ms, bl);
decode(seq, bl);
}
}
};
inline std::ostream& operator<<(std::ostream& out, const LeaseStat& l) {
out << "lease(mask " << l.mask << " dur " << l.duration_ms;
if (l.alternate_name.size()) {
out << " altn " << binstrprint(l.alternate_name, 128) << ")";
}
return out << ")";
}
struct DirStat {
// mds distribution hints
frag_t frag;
__s32 auth;
std::set<__s32> dist;
DirStat() : auth(CDIR_AUTH_PARENT) {}
DirStat(ceph::buffer::list::const_iterator& p, const uint64_t features) {
decode(p, features);
}
void decode(ceph::buffer::list::const_iterator& p, const uint64_t features) {
using ceph::decode;
if (features == (uint64_t)-1) {
DECODE_START(1, p);
decode(frag, p);
decode(auth, p);
decode(dist, p);
DECODE_FINISH(p);
}
else {
decode(frag, p);
decode(auth, p);
decode(dist, p);
}
}
// see CDir::encode_dirstat for encoder.
};
struct InodeStat {
vinodeno_t vino;
uint32_t rdev = 0;
version_t version = 0;
version_t xattr_version = 0;
ceph_mds_reply_cap cap;
file_layout_t layout;
utime_t ctime, btime, mtime, atime, snap_btime;
uint32_t time_warp_seq = 0;
uint64_t size = 0, max_size = 0;
uint64_t change_attr = 0;
uint64_t truncate_size = 0;
uint32_t truncate_seq = 0;
uint32_t mode = 0, uid = 0, gid = 0, nlink = 0;
frag_info_t dirstat;
nest_info_t rstat;
fragtree_t dirfragtree;
std::string symlink; // symlink content (if symlink)
ceph_dir_layout dir_layout;
ceph::buffer::list xattrbl;
ceph::buffer::list inline_data;
version_t inline_version;
quota_info_t quota;
mds_rank_t dir_pin;
std::map<std::string,std::string> snap_metadata;
std::vector<uint8_t> fscrypt_auth;
std::vector<uint8_t> fscrypt_file;
public:
InodeStat() {}
InodeStat(ceph::buffer::list::const_iterator& p, const uint64_t features) {
decode(p, features);
}
void decode(ceph::buffer::list::const_iterator &p, const uint64_t features) {
using ceph::decode;
if (features == (uint64_t)-1) {
DECODE_START(7, p);
decode(vino.ino, p);
decode(vino.snapid, p);
decode(rdev, p);
decode(version, p);
decode(xattr_version, p);
decode(cap, p);
{
ceph_file_layout legacy_layout;
decode(legacy_layout, p);
layout.from_legacy(legacy_layout);
}
decode(ctime, p);
decode(mtime, p);
decode(atime, p);
decode(time_warp_seq, p);
decode(size, p);
decode(max_size, p);
decode(truncate_size, p);
decode(truncate_seq, p);
decode(mode, p);
decode(uid, p);
decode(gid, p);
decode(nlink, p);
decode(dirstat.nfiles, p);
decode(dirstat.nsubdirs, p);
decode(rstat.rbytes, p);
decode(rstat.rfiles, p);
decode(rstat.rsubdirs, p);
decode(rstat.rctime, p);
decode(dirfragtree, p);
decode(symlink, p);
decode(dir_layout, p);
decode(xattrbl, p);
decode(inline_version, p);
decode(inline_data, p);
decode(quota, p);
decode(layout.pool_ns, p);
decode(btime, p);
decode(change_attr, p);
if (struct_v > 1) {
decode(dir_pin, p);
} else {
dir_pin = -ENODATA;
}
if (struct_v >= 3) {
decode(snap_btime, p);
} // else remains zero
if (struct_v >= 4) {
decode(rstat.rsnaps, p);
} // else remains zero
if (struct_v >= 5) {
decode(snap_metadata, p);
}
if (struct_v >= 6) {
bool fscrypt_flag;
decode(fscrypt_flag, p); // ignore this
}
if (struct_v >= 7) {
decode(fscrypt_auth, p);
decode(fscrypt_file, p);
}
DECODE_FINISH(p);
}
else {
decode(vino.ino, p);
decode(vino.snapid, p);
decode(rdev, p);
decode(version, p);
decode(xattr_version, p);
decode(cap, p);
{
ceph_file_layout legacy_layout;
decode(legacy_layout, p);
layout.from_legacy(legacy_layout);
}
decode(ctime, p);
decode(mtime, p);
decode(atime, p);
decode(time_warp_seq, p);
decode(size, p);
decode(max_size, p);
decode(truncate_size, p);
decode(truncate_seq, p);
decode(mode, p);
decode(uid, p);
decode(gid, p);
decode(nlink, p);
decode(dirstat.nfiles, p);
decode(dirstat.nsubdirs, p);
decode(rstat.rbytes, p);
decode(rstat.rfiles, p);
decode(rstat.rsubdirs, p);
decode(rstat.rctime, p);
decode(dirfragtree, p);
decode(symlink, p);
if (features & CEPH_FEATURE_DIRLAYOUTHASH)
decode(dir_layout, p);
else
memset(&dir_layout, 0, sizeof(dir_layout));
decode(xattrbl, p);
if (features & CEPH_FEATURE_MDS_INLINE_DATA) {
decode(inline_version, p);
decode(inline_data, p);
} else {
inline_version = CEPH_INLINE_NONE;
}
if (features & CEPH_FEATURE_MDS_QUOTA)
decode(quota, p);
else
quota = quota_info_t{};
if ((features & CEPH_FEATURE_FS_FILE_LAYOUT_V2))
decode(layout.pool_ns, p);
if ((features & CEPH_FEATURE_FS_BTIME)) {
decode(btime, p);
decode(change_attr, p);
} else {
btime = utime_t();
change_attr = 0;
}
}
}
// see CInode::encode_inodestat for encoder.
};
struct openc_response_t {
_inodeno_t created_ino;
interval_set<inodeno_t> delegated_inos;
public:
void encode(ceph::buffer::list& bl) const {
using ceph::encode;
ENCODE_START(1, 1, bl);
encode(created_ino, bl);
encode(delegated_inos, bl);
ENCODE_FINISH(bl);
}
void decode(ceph::buffer::list::const_iterator &p) {
using ceph::decode;
DECODE_START(1, p);
decode(created_ino, p);
decode(delegated_inos, p);
DECODE_FINISH(p);
}
} __attribute__ ((__may_alias__));
WRITE_CLASS_ENCODER(openc_response_t)
class MClientReply final : public MMDSOp {
public:
// reply data
struct ceph_mds_reply_head head {};
ceph::buffer::list trace_bl;
ceph::buffer::list extra_bl;
ceph::buffer::list snapbl;
int get_op() const { return head.op; }
void set_mdsmap_epoch(epoch_t e) { head.mdsmap_epoch = e; }
epoch_t get_mdsmap_epoch() const { return head.mdsmap_epoch; }
int get_result() const {
#ifdef _WIN32
// libclient and libcephfs return CEPHFS_E* errors, which are basically
// Linux errno codes. If we convert mds errors to host errno values, we
// end up mixing error codes.
//
// For Windows, we'll preserve the original error value, which is expected
// to be a linux (CEPHFS_E*) error. It may be worth doing the same for
// other platforms.
return head.result;
#else
return ceph_to_hostos_errno((__s32)(__u32)head.result);
#endif
}
void set_result(int r) { head.result = r; }
void set_unsafe() { head.safe = 0; }
bool is_safe() const { return head.safe; }
protected:
MClientReply() : MMDSOp{CEPH_MSG_CLIENT_REPLY} {}
MClientReply(const MClientRequest &req, int result = 0) :
MMDSOp{CEPH_MSG_CLIENT_REPLY} {
memset(&head, 0, sizeof(head));
header.tid = req.get_tid();
head.op = req.get_op();
head.result = result;
head.safe = 1;
}
~MClientReply() final {}
public:
std::string_view get_type_name() const override { return "creply"; }
void print(std::ostream& o) const override {
o << "client_reply(???:" << get_tid();
o << " = " << get_result();
if (get_result() <= 0) {
o << " " << cpp_strerror(get_result());
}
if (head.op & CEPH_MDS_OP_WRITE) {
if (head.safe)
o << " safe";
else
o << " unsafe";
}
o << ")";
}
// serialization
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(head, p);
decode(trace_bl, p);
decode(extra_bl, p);
decode(snapbl, p);
ceph_assert(p.end());
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(head, payload);
encode(trace_bl, payload);
encode(extra_bl, payload);
encode(snapbl, payload);
}
// dir contents
void set_extra_bl(ceph::buffer::list& bl) {
extra_bl = std::move(bl);
}
ceph::buffer::list& get_extra_bl() {
return extra_bl;
}
const ceph::buffer::list& get_extra_bl() const {
return extra_bl;
}
// trace
void set_trace(ceph::buffer::list& bl) {
trace_bl = std::move(bl);
}
ceph::buffer::list& get_trace_bl() {
return trace_bl;
}
const ceph::buffer::list& get_trace_bl() const {
return trace_bl;
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 10,834 | 24.434272 | 85 | h |
null | ceph-main/src/messages/MClientRequest.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MCLIENTREQUEST_H
#define CEPH_MCLIENTREQUEST_H
/**
*
* MClientRequest - container for a client METADATA request. created/sent by clients.
* can be forwarded around between MDS's.
*
* int client - the originating client
* long tid - transaction id, unique among requests for that client. probably just a counter!
* -> the MDS passes the Request to the Reply constructor, so this always matches.
*
* int op - the metadata op code. MDS_OP_RENAME, etc.
* int caller_uid, _gid - guess
*
* fixed size arguments are in a union.
* there's also a string argument, for e.g. symlink().
*
*/
#include <string_view>
#include "include/filepath.h"
#include "mds/mdstypes.h"
#include "include/ceph_features.h"
#include "messages/MMDSOp.h"
#include <sys/types.h>
#include <utime.h>
#include <sys/stat.h>
#include <fcntl.h>
struct SnapPayload {
std::map<std::string, std::string> metadata;
void encode(ceph::buffer::list &bl) const {
ENCODE_START(1, 1, bl);
encode(metadata, bl);
ENCODE_FINISH(bl);
}
void decode(ceph::buffer::list::const_iterator &iter) {
DECODE_START(1, iter);
decode(metadata, iter);
DECODE_FINISH(iter);
}
};
WRITE_CLASS_ENCODER(SnapPayload)
// metadata ops.
class MClientRequest final : public MMDSOp {
private:
static constexpr int HEAD_VERSION = 6;
static constexpr int COMPAT_VERSION = 1;
public:
mutable struct ceph_mds_request_head head; /* XXX HACK! */
utime_t stamp;
bool peer_old_version = false;
struct Release {
mutable ceph_mds_request_release item;
std::string dname;
Release() : item(), dname() {}
Release(const ceph_mds_request_release& rel, std::string name) :
item(rel), dname(name) {}
void encode(ceph::buffer::list& bl) const {
using ceph::encode;
item.dname_len = dname.length();
encode(item, bl);
ceph::encode_nohead(dname, bl);
}
void decode(ceph::buffer::list::const_iterator& bl) {
using ceph::decode;
decode(item, bl);
ceph::decode_nohead(item.dname_len, dname, bl);
}
};
mutable std::vector<Release> releases; /* XXX HACK! */
// path arguments
filepath path, path2;
std::string alternate_name;
std::vector<uint64_t> gid_list;
std::vector<uint8_t> fscrypt_auth;
std::vector<uint8_t> fscrypt_file;
/* XXX HACK */
mutable bool queued_for_replay = false;
protected:
// cons
MClientRequest()
: MMDSOp(CEPH_MSG_CLIENT_REQUEST, HEAD_VERSION, COMPAT_VERSION) {
memset(&head, 0, sizeof(head));
}
MClientRequest(int op, bool over=true)
: MMDSOp(CEPH_MSG_CLIENT_REQUEST, HEAD_VERSION, COMPAT_VERSION) {
memset(&head, 0, sizeof(head));
head.op = op;
peer_old_version = over;
}
~MClientRequest() final {}
public:
void set_mdsmap_epoch(epoch_t e) { head.mdsmap_epoch = e; }
epoch_t get_mdsmap_epoch() const { return head.mdsmap_epoch; }
epoch_t get_osdmap_epoch() const {
ceph_assert(head.op == CEPH_MDS_OP_SETXATTR);
if (header.version >= 3)
return head.args.setxattr.osdmap_epoch;
else
return 0;
}
void set_osdmap_epoch(epoch_t e) {
ceph_assert(head.op == CEPH_MDS_OP_SETXATTR);
head.args.setxattr.osdmap_epoch = e;
}
metareqid_t get_reqid() const {
// FIXME: for now, assume clients always have 1 incarnation
return metareqid_t(get_orig_source(), header.tid);
}
/*bool open_file_mode_is_readonly() {
return file_mode_is_readonly(ceph_flags_to_mode(head.args.open.flags));
}*/
bool may_write() const {
return
(head.op & CEPH_MDS_OP_WRITE) ||
(head.op == CEPH_MDS_OP_OPEN && (head.args.open.flags & (O_CREAT|O_TRUNC)));
}
int get_flags() const {
return head.flags;
}
bool is_replay() const {
return get_flags() & CEPH_MDS_FLAG_REPLAY;
}
bool is_async() const {
return get_flags() & CEPH_MDS_FLAG_ASYNC;
}
// normal fields
void set_stamp(utime_t t) { stamp = t; }
void set_oldest_client_tid(ceph_tid_t t) { head.oldest_client_tid = t; }
void inc_num_fwd() { head.ext_num_fwd = head.ext_num_fwd + 1; }
void set_retry_attempt(int a) { head.ext_num_retry = a; }
void set_filepath(const filepath& fp) { path = fp; }
void set_filepath2(const filepath& fp) { path2 = fp; }
void set_string2(const char *s) { path2.set_path(std::string_view(s), 0); }
void set_caller_uid(unsigned u) { head.caller_uid = u; }
void set_caller_gid(unsigned g) { head.caller_gid = g; }
void set_gid_list(int count, const gid_t *gids) {
gid_list.reserve(count);
for (int i = 0; i < count; ++i) {
gid_list.push_back(gids[i]);
}
}
void set_dentry_wanted() {
head.flags = head.flags | CEPH_MDS_FLAG_WANT_DENTRY;
}
void set_replayed_op() {
head.flags = head.flags | CEPH_MDS_FLAG_REPLAY;
}
void set_async_op() {
head.flags = head.flags | CEPH_MDS_FLAG_ASYNC;
}
void set_alternate_name(std::string _alternate_name) {
alternate_name = std::move(_alternate_name);
}
void set_alternate_name(bufferptr&& cipher) {
alternate_name = std::move(cipher.c_str());
}
utime_t get_stamp() const { return stamp; }
ceph_tid_t get_oldest_client_tid() const { return head.oldest_client_tid; }
int get_num_fwd() const { return head.ext_num_fwd; }
int get_retry_attempt() const { return head.ext_num_retry; }
int get_op() const { return head.op; }
unsigned get_caller_uid() const { return head.caller_uid; }
unsigned get_caller_gid() const { return head.caller_gid; }
const std::vector<uint64_t>& get_caller_gid_list() const { return gid_list; }
const std::string& get_path() const { return path.get_path(); }
const filepath& get_filepath() const { return path; }
const std::string& get_path2() const { return path2.get_path(); }
const filepath& get_filepath2() const { return path2; }
std::string_view get_alternate_name() const { return std::string_view(alternate_name); }
int get_dentry_wanted() const { return get_flags() & CEPH_MDS_FLAG_WANT_DENTRY; }
void mark_queued_for_replay() const { queued_for_replay = true; }
bool is_queued_for_replay() const { return queued_for_replay; }
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
if (header.version >= 4) {
decode(head, p);
} else {
struct ceph_mds_request_head_legacy old_mds_head;
decode(old_mds_head, p);
copy_from_legacy_head(&head, &old_mds_head);
head.version = 0;
/* Can't set the btime from legacy struct */
if (head.op == CEPH_MDS_OP_SETATTR) {
int localmask = head.args.setattr.mask;
localmask &= ~CEPH_SETATTR_BTIME;
head.args.setattr.btime = { ceph_le32(0), ceph_le32(0) };
head.args.setattr.mask = localmask;
}
}
decode(path, p);
decode(path2, p);
ceph::decode_nohead(head.num_releases, releases, p);
if (header.version >= 2)
decode(stamp, p);
if (header.version >= 4) // epoch 3 was for a ceph_mds_request_args change
decode(gid_list, p);
if (header.version >= 5)
decode(alternate_name, p);
if (header.version >= 6) {
decode(fscrypt_auth, p);
decode(fscrypt_file, p);
}
}
void encode_payload(uint64_t features) override {
using ceph::encode;
head.num_releases = releases.size();
/*
* If the peer is old version, we must skip all the
* new members, because the old version of MDS or
* client will just copy the 'head' memory and isn't
* that smart to skip them.
*/
if (peer_old_version) {
head.version = 1;
} else {
head.version = CEPH_MDS_REQUEST_HEAD_VERSION;
}
if (features & CEPH_FEATURE_FS_BTIME) {
encode(head, payload, peer_old_version);
} else {
struct ceph_mds_request_head_legacy old_mds_head;
copy_to_legacy_head(&old_mds_head, &head);
encode(old_mds_head, payload);
}
encode(path, payload);
encode(path2, payload);
ceph::encode_nohead(releases, payload);
encode(stamp, payload);
encode(gid_list, payload);
encode(alternate_name, payload);
encode(fscrypt_auth, payload);
encode(fscrypt_file, payload);
}
std::string_view get_type_name() const override { return "creq"; }
void print(std::ostream& out) const override {
out << "client_request(" << get_orig_source()
<< ":" << get_tid()
<< " " << ceph_mds_op_name(get_op());
if (head.op == CEPH_MDS_OP_GETATTR)
out << " " << ccap_string(head.args.getattr.mask);
if (head.op == CEPH_MDS_OP_SETATTR) {
if (head.args.setattr.mask & CEPH_SETATTR_MODE)
out << " mode=0" << std::oct << head.args.setattr.mode << std::dec;
if (head.args.setattr.mask & CEPH_SETATTR_UID)
out << " uid=" << head.args.setattr.uid;
if (head.args.setattr.mask & CEPH_SETATTR_GID)
out << " gid=" << head.args.setattr.gid;
if (head.args.setattr.mask & CEPH_SETATTR_SIZE)
out << " size=" << head.args.setattr.size;
if (head.args.setattr.mask & CEPH_SETATTR_MTIME)
out << " mtime=" << utime_t(head.args.setattr.mtime);
if (head.args.setattr.mask & CEPH_SETATTR_ATIME)
out << " atime=" << utime_t(head.args.setattr.atime);
}
if (head.op == CEPH_MDS_OP_SETFILELOCK ||
head.op == CEPH_MDS_OP_GETFILELOCK) {
out << " rule " << (int)head.args.filelock_change.rule
<< ", type " << (int)head.args.filelock_change.type
<< ", owner " << head.args.filelock_change.owner
<< ", pid " << head.args.filelock_change.pid
<< ", start " << head.args.filelock_change.start
<< ", length " << head.args.filelock_change.length
<< ", wait " << (int)head.args.filelock_change.wait;
}
//if (!get_filepath().empty())
out << " " << get_filepath();
if (alternate_name.size())
out << " (" << alternate_name << ") ";
if (!get_filepath2().empty())
out << " " << get_filepath2();
if (stamp != utime_t())
out << " " << stamp;
if (head.ext_num_fwd)
out << " FWD=" << (int)head.ext_num_fwd;
if (head.ext_num_retry)
out << " RETRY=" << (int)head.ext_num_retry;
if (is_async())
out << " ASYNC";
if (is_replay())
out << " REPLAY";
if (queued_for_replay)
out << " QUEUED_FOR_REPLAY";
out << " caller_uid=" << head.caller_uid
<< ", caller_gid=" << head.caller_gid
<< '{';
for (auto i = gid_list.begin(); i != gid_list.end(); ++i)
out << *i << ',';
out << '}'
<< ")";
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
WRITE_CLASS_ENCODER(MClientRequest::Release)
#endif
| 11,113 | 30.131653 | 98 | h |
null | ceph-main/src/messages/MClientRequestForward.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MCLIENTREQUESTFORWARD_H
#define CEPH_MCLIENTREQUESTFORWARD_H
#include "msg/Message.h"
class MClientRequestForward final : public SafeMessage {
private:
int32_t dest_mds;
int32_t num_fwd;
bool client_must_resend;
protected:
MClientRequestForward()
: SafeMessage{CEPH_MSG_CLIENT_REQUEST_FORWARD},
dest_mds(-1), num_fwd(-1), client_must_resend(false) {}
MClientRequestForward(ceph_tid_t t, int dm, int nf, bool cmr) :
SafeMessage{CEPH_MSG_CLIENT_REQUEST_FORWARD},
dest_mds(dm), num_fwd(nf), client_must_resend(cmr) {
ceph_assert(client_must_resend);
header.tid = t;
}
~MClientRequestForward() final {}
public:
int get_dest_mds() const { return dest_mds; }
int get_num_fwd() const { return num_fwd; }
bool must_resend() const { return client_must_resend; }
std::string_view get_type_name() const override { return "client_request_forward"; }
void print(std::ostream& o) const override {
o << "client_request_forward(" << get_tid()
<< " to mds." << dest_mds
<< " num_fwd=" << num_fwd
<< (client_must_resend ? " client_must_resend":"")
<< ")";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(dest_mds, payload);
encode(num_fwd, payload);
encode(client_must_resend, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(dest_mds, p);
decode(num_fwd, p);
decode(client_must_resend, p);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 2,152 | 27.706667 | 86 | h |
null | ceph-main/src/messages/MClientSession.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MCLIENTSESSION_H
#define CEPH_MCLIENTSESSION_H
#include "msg/Message.h"
#include "mds/mdstypes.h"
class MClientSession final : public SafeMessage {
private:
static constexpr int HEAD_VERSION = 5;
static constexpr int COMPAT_VERSION = 1;
public:
ceph_mds_session_head head;
static constexpr unsigned SESSION_BLOCKLISTED = (1<<0);
unsigned flags = 0;
std::map<std::string, std::string> metadata;
feature_bitset_t supported_features;
metric_spec_t metric_spec;
int get_op() const { return head.op; }
version_t get_seq() const { return head.seq; }
utime_t get_stamp() const { return utime_t(head.stamp); }
int get_max_caps() const { return head.max_caps; }
int get_max_leases() const { return head.max_leases; }
protected:
MClientSession() : SafeMessage{CEPH_MSG_CLIENT_SESSION, HEAD_VERSION, COMPAT_VERSION} { }
MClientSession(int o, version_t s=0, unsigned msg_flags=0) :
SafeMessage{CEPH_MSG_CLIENT_SESSION, HEAD_VERSION, COMPAT_VERSION},
flags(msg_flags) {
memset(&head, 0, sizeof(head));
head.op = o;
head.seq = s;
}
MClientSession(int o, utime_t st) :
SafeMessage{CEPH_MSG_CLIENT_SESSION, HEAD_VERSION, COMPAT_VERSION} {
memset(&head, 0, sizeof(head));
head.op = o;
head.seq = 0;
st.encode_timeval(&head.stamp);
}
~MClientSession() final {}
public:
std::string_view get_type_name() const override { return "client_session"; }
void print(std::ostream& out) const override {
out << "client_session(" << ceph_session_op_name(get_op());
if (get_seq())
out << " seq " << get_seq();
if (get_op() == CEPH_SESSION_RECALL_STATE)
out << " max_caps " << head.max_caps << " max_leases " << head.max_leases;
out << ")";
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(head, p);
if (header.version >= 2)
decode(metadata, p);
if (header.version >= 3)
decode(supported_features, p);
if (header.version >= 4) {
decode(metric_spec, p);
}
if (header.version >= 5) {
decode(flags, p);
}
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(head, payload);
if (metadata.empty() && supported_features.empty()) {
// If we're not trying to send any metadata (always the case if
// we are a server) then send older-format message to avoid upsetting
// old kernel clients.
header.version = 1;
} else {
header.version = HEAD_VERSION;
encode(metadata, payload);
encode(supported_features, payload);
encode(metric_spec, payload);
encode(flags, payload);
}
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 3,326 | 29.522936 | 91 | h |
null | ceph-main/src/messages/MClientSnap.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MCLIENTSNAP_H
#define CEPH_MCLIENTSNAP_H
#include "msg/Message.h"
class MClientSnap final : public SafeMessage {
public:
ceph_mds_snap_head head;
ceph::buffer::list bl;
// (for split only)
std::vector<inodeno_t> split_inos;
std::vector<inodeno_t> split_realms;
protected:
MClientSnap(int o=0) :
SafeMessage{CEPH_MSG_CLIENT_SNAP} {
memset(&head, 0, sizeof(head));
head.op = o;
}
~MClientSnap() final {}
public:
std::string_view get_type_name() const override { return "client_snap"; }
void print(std::ostream& out) const override {
out << "client_snap(" << ceph_snap_op_name(head.op);
if (head.split)
out << " split=" << inodeno_t(head.split);
out << " tracelen=" << bl.length();
out << ")";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
head.num_split_inos = split_inos.size();
head.num_split_realms = split_realms.size();
head.trace_len = bl.length();
encode(head, payload);
ceph::encode_nohead(split_inos, payload);
ceph::encode_nohead(split_realms, payload);
ceph::encode_nohead(bl, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(head, p);
ceph::decode_nohead(head.num_split_inos, split_inos, p);
ceph::decode_nohead(head.num_split_realms, split_realms, p);
ceph::decode_nohead(head.trace_len, bl, p);
ceph_assert(p.end());
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 2,106 | 27.472973 | 75 | h |
null | ceph-main/src/messages/MCommand.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MCOMMAND_H
#define CEPH_MCOMMAND_H
#include <vector>
#include "msg/Message.h"
class MCommand final : public Message {
public:
uuid_d fsid;
std::vector<std::string> cmd;
MCommand()
: Message{MSG_COMMAND} {}
MCommand(const uuid_d &f)
: Message{MSG_COMMAND},
fsid(f) { }
private:
~MCommand() final {}
public:
std::string_view get_type_name() const override { return "command"; }
void print(std::ostream& o) const override {
o << "command(tid " << get_tid() << ": ";
for (unsigned i=0; i<cmd.size(); i++) {
if (i) o << ' ';
o << cmd[i];
}
o << ")";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(fsid, payload);
encode(cmd, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(fsid, p);
decode(cmd, p);
}
};
#endif
| 1,335 | 20.901639 | 71 | h |
null | ceph-main/src/messages/MCommandReply.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MCOMMANDREPLY_H
#define CEPH_MCOMMANDREPLY_H
#include <string_view>
#include "msg/Message.h"
#include "MCommand.h"
class MCommandReply final : public Message {
public:
errorcode32_t r;
std::string rs;
MCommandReply()
: Message{MSG_COMMAND_REPLY} {}
MCommandReply(MCommand *m, int _r)
: Message{MSG_COMMAND_REPLY}, r(_r) {
header.tid = m->get_tid();
}
MCommandReply(int _r, std::string_view s)
: Message{MSG_COMMAND_REPLY},
r(_r), rs(s) { }
private:
~MCommandReply() final {}
public:
std::string_view get_type_name() const override { return "command_reply"; }
void print(std::ostream& o) const override {
o << "command_reply(tid " << get_tid() << ": " << r << " " << rs << ")";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(r, payload);
encode(rs, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(r, p);
decode(rs, p);
}
};
#endif
| 1,448 | 23.15 | 77 | h |
null | ceph-main/src/messages/MConfig.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
#pragma once
#include "msg/Message.h"
class MConfig : public Message {
public:
static constexpr int HEAD_VERSION = 1;
static constexpr int COMPAT_VERSION = 1;
// use transparent comparator so we can lookup in it by std::string_view keys
std::map<std::string,std::string,std::less<>> config;
MConfig() : Message{MSG_CONFIG, HEAD_VERSION, COMPAT_VERSION} { }
MConfig(const std::map<std::string,std::string,std::less<>>& c)
: Message{MSG_CONFIG, HEAD_VERSION, COMPAT_VERSION},
config{c} {}
MConfig(std::map<std::string,std::string,std::less<>>&& c)
: Message{MSG_CONFIG, HEAD_VERSION, COMPAT_VERSION},
config{std::move(c)} {}
std::string_view get_type_name() const override {
return "config";
}
void print(std::ostream& o) const override {
o << "config(" << config.size() << " keys" << ")";
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(config, p);
}
void encode_payload(uint64_t) override {
using ceph::encode;
encode(config, payload);
}
};
| 1,167 | 26.162791 | 79 | h |
null | ceph-main/src/messages/MDentryLink.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MDENTRYLINK_H
#define CEPH_MDENTRYLINK_H
#include <string_view>
#include "messages/MMDSOp.h"
class MDentryLink final : public MMDSOp {
private:
static constexpr int HEAD_VERSION = 1;
static constexpr int COMPAT_VERSION = 1;
dirfrag_t subtree;
dirfrag_t dirfrag;
std::string dn;
bool is_primary = false;
public:
dirfrag_t get_subtree() const { return subtree; }
dirfrag_t get_dirfrag() const { return dirfrag; }
const std::string& get_dn() const { return dn; }
bool get_is_primary() const { return is_primary; }
ceph::buffer::list bl;
protected:
MDentryLink() :
MMDSOp(MSG_MDS_DENTRYLINK, HEAD_VERSION, COMPAT_VERSION) { }
MDentryLink(dirfrag_t r, dirfrag_t df, std::string_view n, bool p) :
MMDSOp(MSG_MDS_DENTRYLINK, HEAD_VERSION, COMPAT_VERSION),
subtree(r),
dirfrag(df),
dn(n),
is_primary(p) {}
~MDentryLink() final {}
public:
std::string_view get_type_name() const override { return "dentry_link";}
void print(std::ostream& o) const override {
o << "dentry_link(" << dirfrag << " " << dn << ")";
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(subtree, p);
decode(dirfrag, p);
decode(dn, p);
decode(is_primary, p);
decode(bl, p);
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(subtree, payload);
encode(dirfrag, payload);
encode(dn, payload);
encode(is_primary, payload);
encode(bl, payload);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 2,173 | 25.192771 | 74 | h |
null | ceph-main/src/messages/MDentryUnlink.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MDENTRYUNLINK_H
#define CEPH_MDENTRYUNLINK_H
#include <string_view>
#include "messages/MMDSOp.h"
class MDentryUnlink final : public MMDSOp {
private:
static constexpr int HEAD_VERSION = 2;
static constexpr int COMPAT_VERSION = 1;
dirfrag_t dirfrag;
std::string dn;
bool unlinking = false;
public:
dirfrag_t get_dirfrag() const { return dirfrag; }
const std::string& get_dn() const { return dn; }
bool is_unlinking() const { return unlinking; }
ceph::buffer::list straybl;
ceph::buffer::list snapbl;
protected:
MDentryUnlink() :
MMDSOp(MSG_MDS_DENTRYUNLINK, HEAD_VERSION, COMPAT_VERSION) { }
MDentryUnlink(dirfrag_t df, std::string_view n, bool u=false) :
MMDSOp(MSG_MDS_DENTRYUNLINK, HEAD_VERSION, COMPAT_VERSION),
dirfrag(df), dn(n), unlinking(u) {}
~MDentryUnlink() final {}
public:
std::string_view get_type_name() const override { return "dentry_unlink";}
void print(std::ostream& o) const override {
o << "dentry_unlink(" << dirfrag << " " << dn << ")";
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(dirfrag, p);
decode(dn, p);
decode(straybl, p);
if (header.version >= 2)
decode(unlinking, p);
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(dirfrag, payload);
encode(dn, payload);
encode(straybl, payload);
encode(unlinking, payload);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
class MDentryUnlinkAck final : public MMDSOp {
private:
static constexpr int HEAD_VERSION = 1;
static constexpr int COMPAT_VERSION = 1;
dirfrag_t dirfrag;
std::string dn;
public:
dirfrag_t get_dirfrag() const { return dirfrag; }
const std::string& get_dn() const { return dn; }
protected:
MDentryUnlinkAck() :
MMDSOp(MSG_MDS_DENTRYUNLINK_ACK, HEAD_VERSION, COMPAT_VERSION) { }
MDentryUnlinkAck(dirfrag_t df, std::string_view n) :
MMDSOp(MSG_MDS_DENTRYUNLINK_ACK, HEAD_VERSION, COMPAT_VERSION),
dirfrag(df), dn(n) {}
~MDentryUnlinkAck() final {}
public:
std::string_view get_type_name() const override { return "dentry_unlink_ack";}
void print(std::ostream& o) const override {
o << "dentry_unlink_ack(" << dirfrag << " " << dn << ")";
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(dirfrag, p);
decode(dn, p);
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(dirfrag, payload);
encode(dn, payload);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 3,369 | 26.622951 | 80 | h |
null | ceph-main/src/messages/MDirUpdate.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MDIRUPDATE_H
#define CEPH_MDIRUPDATE_H
#include "messages/MMDSOp.h"
class MDirUpdate final : public MMDSOp {
public:
mds_rank_t get_source_mds() const { return from_mds; }
dirfrag_t get_dirfrag() const { return dirfrag; }
int get_dir_rep() const { return dir_rep; }
const std::set<int32_t>& get_dir_rep_by() const { return dir_rep_by; }
bool should_discover() const { return discover > tried_discover; }
const filepath& get_path() const { return path; }
bool has_tried_discover() const { return tried_discover > 0; }
void inc_tried_discover() const { ++tried_discover; }
std::string_view get_type_name() const override { return "dir_update"; }
void print(std::ostream& out) const override {
out << "dir_update(" << get_dirfrag() << ")";
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(from_mds, p);
decode(dirfrag, p);
decode(dir_rep, p);
decode(discover, p);
decode(dir_rep_by, p);
decode(path, p);
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(from_mds, payload);
encode(dirfrag, payload);
encode(dir_rep, payload);
encode(discover, payload);
encode(dir_rep_by, payload);
encode(path, payload);
}
protected:
~MDirUpdate() final {}
MDirUpdate() : MMDSOp(MSG_MDS_DIRUPDATE, HEAD_VERSION, COMPAT_VERSION) {}
MDirUpdate(mds_rank_t f,
dirfrag_t dirfrag,
int dir_rep,
const std::set<int32_t>& dir_rep_by,
filepath& path,
bool discover = false) :
MMDSOp(MSG_MDS_DIRUPDATE, HEAD_VERSION, COMPAT_VERSION), from_mds(f), dirfrag(dirfrag),
dir_rep(dir_rep), dir_rep_by(dir_rep_by), path(path) {
this->discover = discover ? 5 : 0;
}
MDirUpdate(const MDirUpdate& m)
: MMDSOp{MSG_MDS_DIRUPDATE},
from_mds(m.from_mds),
dirfrag(m.dirfrag),
dir_rep(m.dir_rep),
discover(m.discover),
dir_rep_by(m.dir_rep_by),
path(m.path),
tried_discover(m.tried_discover)
{}
mds_rank_t from_mds = -1;
dirfrag_t dirfrag;
int32_t dir_rep = 5;
int32_t discover = 5;
std::set<int32_t> dir_rep_by;
filepath path;
mutable int tried_discover = 0; // XXX HACK
private:
static constexpr int HEAD_VERSION = 1;
static constexpr int COMPAT_VERSION = 1;
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 2,972 | 28.435644 | 91 | h |
null | ceph-main/src/messages/MDiscover.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MDISCOVER_H
#define CEPH_MDISCOVER_H
#include "include/filepath.h"
#include "messages/MMDSOp.h"
#include <string>
class MDiscover final : public MMDSOp {
private:
static constexpr int HEAD_VERSION = 1;
static constexpr int COMPAT_VERSION = 1;
inodeno_t base_ino; // 1 -> root
frag_t base_dir_frag;
snapid_t snapid;
filepath want; // ... [/]need/this/stuff
bool want_base_dir = true;
bool path_locked = false;
public:
inodeno_t get_base_ino() const { return base_ino; }
frag_t get_base_dir_frag() const { return base_dir_frag; }
snapid_t get_snapid() const { return snapid; }
const filepath& get_want() const { return want; }
const std::string& get_dentry(int n) const { return want[n]; }
bool wants_base_dir() const { return want_base_dir; }
bool is_path_locked() const { return path_locked; }
void set_base_dir_frag(frag_t f) { base_dir_frag = f; }
protected:
MDiscover() : MMDSOp(MSG_MDS_DISCOVER, HEAD_VERSION, COMPAT_VERSION) { }
MDiscover(inodeno_t base_ino_,
frag_t base_frag_,
snapid_t s,
filepath& want_path_,
bool want_base_dir_ = true,
bool path_locked_ = false) :
MMDSOp{MSG_MDS_DISCOVER},
base_ino(base_ino_),
base_dir_frag(base_frag_),
snapid(s),
want(want_path_),
want_base_dir(want_base_dir_),
path_locked(path_locked_) { }
~MDiscover() final {}
public:
std::string_view get_type_name() const override { return "Dis"; }
void print(std::ostream &out) const override {
out << "discover(" << header.tid << " " << base_ino << "." << base_dir_frag
<< " " << want << ")";
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(base_ino, p);
decode(base_dir_frag, p);
decode(snapid, p);
decode(want, p);
decode(want_base_dir, p);
decode(path_locked, p);
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(base_ino, payload);
encode(base_dir_frag, payload);
encode(snapid, payload);
encode(want, payload);
encode(want_base_dir, payload);
encode(path_locked, payload);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 2,849 | 26.669903 | 79 | h |
null | ceph-main/src/messages/MDiscoverReply.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MDISCOVERREPLY_H
#define CEPH_MDISCOVERREPLY_H
#include "include/filepath.h"
#include "messages/MMDSOp.h"
#include <string>
/**
* MDiscoverReply - return new replicas (of inodes, dirs, dentries)
*
* we group returned items by (dir, dentry, inode). each
* item in each set shares an index (it's "depth").
*
* we can start and end with any type.
* no_base_dir = true if the first group has an inode but no dir
* no_base_dentry = true if the first group has an inode but no dentry
* they are false if there is no returned data, ie the first group is empty.
*
* we also return errors:
* error_flag_dn(std::string) - the specified dentry dne
* error_flag_dir - the last item wasn't a dir, so we couldn't continue.
*
* and sometimes,
* dir_auth_hint - where we think the dir auth is
*
* depth() gives us the number of depth units/indices for which we have
* information. this INCLUDES those for which we have errors but no data.
*
* see MDCache::handle_discover, handle_discover_reply.
*
*
* so basically, we get
*
* dir den ino i
* x 0
* x x x 1
* or
* x x 0
* x x x 1
* or
* x x x 0
* x x x 1
* ...and trail off however we want.
*
*
*/
class MDiscoverReply final : public MMDSOp {
private:
static constexpr int HEAD_VERSION = 2;
static constexpr int COMPAT_VERSION = 2;
// info about original request
inodeno_t base_ino;
frag_t base_dir_frag;
bool wanted_base_dir = false;
bool path_locked = false;
snapid_t wanted_snapid;
// and the response
bool flag_error_dn = false;
bool flag_error_dir = false;
std::string error_dentry; // dentry that was not found (to trigger waiters on asker)
bool unsolicited = false;
mds_rank_t dir_auth_hint = 0;
public:
__u8 starts_with = 0;
ceph::buffer::list trace;
enum { DIR, DENTRY, INODE };
// accessors
inodeno_t get_base_ino() const { return base_ino; }
frag_t get_base_dir_frag() const { return base_dir_frag; }
bool get_wanted_base_dir() const { return wanted_base_dir; }
bool is_path_locked() const { return path_locked; }
snapid_t get_wanted_snapid() const { return wanted_snapid; }
bool is_flag_error_dn() const { return flag_error_dn; }
bool is_flag_error_dir() const { return flag_error_dir; }
const std::string& get_error_dentry() const { return error_dentry; }
int get_starts_with() const { return starts_with; }
mds_rank_t get_dir_auth_hint() const { return dir_auth_hint; }
bool is_unsolicited() const { return unsolicited; }
void mark_unsolicited() { unsolicited = true; }
void set_base_dir_frag(frag_t df) { base_dir_frag = df; }
protected:
MDiscoverReply() : MMDSOp{MSG_MDS_DISCOVERREPLY, HEAD_VERSION, COMPAT_VERSION} { }
MDiscoverReply(const MDiscover &dis) :
MMDSOp{MSG_MDS_DISCOVERREPLY, HEAD_VERSION, COMPAT_VERSION},
base_ino(dis.get_base_ino()),
base_dir_frag(dis.get_base_dir_frag()),
wanted_base_dir(dis.wants_base_dir()),
path_locked(dis.is_path_locked()),
wanted_snapid(dis.get_snapid()),
flag_error_dn(false),
flag_error_dir(false),
unsolicited(false),
dir_auth_hint(CDIR_AUTH_UNKNOWN),
starts_with(DIR)
{
header.tid = dis.get_tid();
}
MDiscoverReply(dirfrag_t df) :
MMDSOp{MSG_MDS_DISCOVERREPLY, HEAD_VERSION, COMPAT_VERSION},
base_ino(df.ino),
base_dir_frag(df.frag),
wanted_base_dir(false),
path_locked(false),
wanted_snapid(CEPH_NOSNAP),
flag_error_dn(false),
flag_error_dir(false),
unsolicited(false),
dir_auth_hint(CDIR_AUTH_UNKNOWN),
starts_with(DIR)
{
header.tid = 0;
}
~MDiscoverReply() final {}
public:
std::string_view get_type_name() const override { return "discover_reply"; }
void print(std::ostream& out) const override {
out << "discover_reply(" << header.tid << " " << base_ino << ")";
}
// builders
bool is_empty() const {
return trace.length() == 0 &&
!flag_error_dn &&
!flag_error_dir &&
dir_auth_hint == CDIR_AUTH_UNKNOWN;
}
// void set_flag_forward() { flag_forward = true; }
void set_flag_error_dn(std::string_view dn) {
flag_error_dn = true;
error_dentry = dn;
}
void set_flag_error_dir() {
flag_error_dir = true;
}
void set_dir_auth_hint(int a) {
dir_auth_hint = a;
}
void set_error_dentry(std::string_view dn) {
error_dentry = dn;
}
// ...
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(base_ino, p);
decode(base_dir_frag, p);
decode(wanted_base_dir, p);
decode(path_locked, p);
decode(wanted_snapid, p);
decode(flag_error_dn, p);
decode(flag_error_dir, p);
decode(error_dentry, p);
decode(dir_auth_hint, p);
decode(unsolicited, p);
decode(starts_with, p);
decode(trace, p);
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(base_ino, payload);
encode(base_dir_frag, payload);
encode(wanted_base_dir, payload);
encode(path_locked, payload);
encode(wanted_snapid, payload);
encode(flag_error_dn, payload);
encode(flag_error_dir, payload);
encode(error_dentry, payload);
encode(dir_auth_hint, payload);
encode(unsolicited, payload);
encode(starts_with, payload);
encode(trace, payload);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 6,051 | 26.761468 | 88 | h |
null | ceph-main/src/messages/MExportCaps.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MEXPORTCAPS_H
#define CEPH_MEXPORTCAPS_H
#include "messages/MMDSOp.h"
class MExportCaps final : public MMDSOp {
private:
static constexpr int HEAD_VERSION = 2;
static constexpr int COMPAT_VERSION = 1;
public:
inodeno_t ino;
ceph::buffer::list cap_bl;
std::map<client_t,entity_inst_t> client_map;
std::map<client_t,client_metadata_t> client_metadata_map;
protected:
MExportCaps() :
MMDSOp{MSG_MDS_EXPORTCAPS, HEAD_VERSION, COMPAT_VERSION} {}
~MExportCaps() final {}
public:
std::string_view get_type_name() const override { return "export_caps"; }
void print(std::ostream& o) const override {
o << "export_caps(" << ino << ")";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(ino, payload);
encode(cap_bl, payload);
encode(client_map, payload, features);
encode(client_metadata_map, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(ino, p);
decode(cap_bl, p);
decode(client_map, p);
if (header.version >= 2)
decode(client_metadata_map, p);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 1,783 | 25.626866 | 75 | h |
null | ceph-main/src/messages/MExportCapsAck.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MEXPORTCAPSACK_H
#define CEPH_MEXPORTCAPSACK_H
#include "messages/MMDSOp.h"
class MExportCapsAck final : public MMDSOp {
static constexpr int HEAD_VERSION = 1;
static constexpr int COMPAT_VERSION = 1;
public:
inodeno_t ino;
ceph::buffer::list cap_bl;
protected:
MExportCapsAck() :
MMDSOp{MSG_MDS_EXPORTCAPSACK, HEAD_VERSION, COMPAT_VERSION} {}
MExportCapsAck(inodeno_t i) :
MMDSOp{MSG_MDS_EXPORTCAPSACK, HEAD_VERSION, COMPAT_VERSION}, ino(i) {}
~MExportCapsAck() final {}
public:
std::string_view get_type_name() const override { return "export_caps_ack"; }
void print(std::ostream& o) const override {
o << "export_caps_ack(" << ino << ")";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(ino, payload);
encode(cap_bl, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(ino, p);
decode(cap_bl, p);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 1,619 | 25.557377 | 79 | h |
null | ceph-main/src/messages/MExportDir.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MEXPORTDIR_H
#define CEPH_MEXPORTDIR_H
#include "messages/MMDSOp.h"
class MExportDir final : public MMDSOp {
public:
dirfrag_t dirfrag;
ceph::buffer::list export_data;
std::vector<dirfrag_t> bounds;
ceph::buffer::list client_map;
protected:
MExportDir() : MMDSOp{MSG_MDS_EXPORTDIR} {}
MExportDir(dirfrag_t df, uint64_t tid) :
MMDSOp{MSG_MDS_EXPORTDIR}, dirfrag(df) {
set_tid(tid);
}
~MExportDir() final {}
public:
std::string_view get_type_name() const override { return "Ex"; }
void print(std::ostream& o) const override {
o << "export(" << dirfrag << ")";
}
void add_export(dirfrag_t df) {
bounds.push_back(df);
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(dirfrag, payload);
encode(bounds, payload);
encode(export_data, payload);
encode(client_map, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(dirfrag, p);
decode(bounds, p);
decode(export_data, p);
decode(client_map, p);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 1,733 | 24.130435 | 71 | h |
null | ceph-main/src/messages/MExportDirAck.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MEXPORTDIRACK_H
#define CEPH_MEXPORTDIRACK_H
#include "MExportDir.h"
#include "messages/MMDSOp.h"
class MExportDirAck final : public MMDSOp {
public:
dirfrag_t dirfrag;
ceph::buffer::list imported_caps;
dirfrag_t get_dirfrag() const { return dirfrag; }
protected:
MExportDirAck() : MMDSOp{MSG_MDS_EXPORTDIRACK} {}
MExportDirAck(dirfrag_t df, uint64_t tid) :
MMDSOp{MSG_MDS_EXPORTDIRACK}, dirfrag(df) {
set_tid(tid);
}
~MExportDirAck() final {}
public:
std::string_view get_type_name() const override { return "ExAck"; }
void print(std::ostream& o) const override {
o << "export_ack(" << dirfrag << ")";
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(dirfrag, p);
decode(imported_caps, p);
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(dirfrag, payload);
encode(imported_caps, payload);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 1,603 | 25.295082 | 71 | h |
null | ceph-main/src/messages/MExportDirCancel.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MEXPORTDIRCANCEL_H
#define CEPH_MEXPORTDIRCANCEL_H
#include "include/types.h"
#include "messages/MMDSOp.h"
class MExportDirCancel final : public MMDSOp {
private:
static constexpr int HEAD_VERSION = 1;
static constexpr int COMPAT_VERSION = 1;
dirfrag_t dirfrag;
public:
dirfrag_t get_dirfrag() const { return dirfrag; }
protected:
MExportDirCancel() : MMDSOp{MSG_MDS_EXPORTDIRCANCEL, HEAD_VERSION, COMPAT_VERSION} {}
MExportDirCancel(dirfrag_t df, uint64_t tid) :
MMDSOp{MSG_MDS_EXPORTDIRCANCEL, HEAD_VERSION, COMPAT_VERSION}, dirfrag(df) {
set_tid(tid);
}
~MExportDirCancel() final {}
public:
std::string_view get_type_name() const override { return "ExCancel"; }
void print(std::ostream& o) const override {
o << "export_cancel(" << dirfrag << ")";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(dirfrag, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(dirfrag, p);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 1,686 | 26.655738 | 87 | h |
null | ceph-main/src/messages/MExportDirDiscover.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MEXPORTDIRDISCOVER_H
#define CEPH_MEXPORTDIRDISCOVER_H
#include "include/types.h"
#include "messages/MMDSOp.h"
class MExportDirDiscover final : public MMDSOp {
private:
static constexpr int HEAD_VERSION = 1;
static constexpr int COMPAT_VERSION = 1;
mds_rank_t from = -1;
dirfrag_t dirfrag;
filepath path;
public:
mds_rank_t get_source_mds() const { return from; }
inodeno_t get_ino() const { return dirfrag.ino; }
dirfrag_t get_dirfrag() const { return dirfrag; }
const filepath& get_path() const { return path; }
bool started;
protected:
MExportDirDiscover() :
MMDSOp{MSG_MDS_EXPORTDIRDISCOVER, HEAD_VERSION, COMPAT_VERSION},
started(false) { }
MExportDirDiscover(dirfrag_t df, filepath& p, mds_rank_t f, uint64_t tid) :
MMDSOp{MSG_MDS_EXPORTDIRDISCOVER, HEAD_VERSION, COMPAT_VERSION},
from(f), dirfrag(df), path(p), started(false) {
set_tid(tid);
}
~MExportDirDiscover() final {}
public:
std::string_view get_type_name() const override { return "ExDis"; }
void print(std::ostream& o) const override {
o << "export_discover(" << dirfrag << " " << path << ")";
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(from, p);
decode(dirfrag, p);
decode(path, p);
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(from, payload);
encode(dirfrag, payload);
encode(path, payload);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 2,123 | 26.947368 | 77 | h |
null | ceph-main/src/messages/MExportDirDiscoverAck.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MEXPORTDIRDISCOVERACK_H
#define CEPH_MEXPORTDIRDISCOVERACK_H
#include "include/types.h"
#include "messages/MMDSOp.h"
class MExportDirDiscoverAck final : public MMDSOp {
private:
static constexpr int HEAD_VERSION = 1;
static constexpr int COMPAT_VERSION = 1;
dirfrag_t dirfrag;
bool success;
public:
inodeno_t get_ino() const { return dirfrag.ino; }
dirfrag_t get_dirfrag() const { return dirfrag; }
bool is_success() const { return success; }
protected:
MExportDirDiscoverAck() : MMDSOp{MSG_MDS_EXPORTDIRDISCOVERACK, HEAD_VERSION, COMPAT_VERSION} {}
MExportDirDiscoverAck(dirfrag_t df, uint64_t tid, bool s=true) :
MMDSOp{MSG_MDS_EXPORTDIRDISCOVERACK, HEAD_VERSION, COMPAT_VERSION},
dirfrag(df), success(s) {
set_tid(tid);
}
~MExportDirDiscoverAck() final {}
public:
std::string_view get_type_name() const override { return "ExDisA"; }
void print(std::ostream& o) const override {
o << "export_discover_ack(" << dirfrag;
if (success)
o << " success)";
else
o << " failure)";
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(dirfrag, p);
decode(success, p);
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(dirfrag, payload);
encode(success, payload);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 1,996 | 26.736111 | 97 | h |
null | ceph-main/src/messages/MExportDirFinish.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MEXPORTDIRFINISH_H
#define CEPH_MEXPORTDIRFINISH_H
#include "messages/MMDSOp.h"
class MExportDirFinish final : public MMDSOp {
private:
static constexpr int HEAD_VERSION = 1;
static constexpr int COMPAT_VERSION = 1;
dirfrag_t dirfrag;
bool last;
public:
dirfrag_t get_dirfrag() const { return dirfrag; }
bool is_last() const { return last; }
protected:
MExportDirFinish() :
MMDSOp{MSG_MDS_EXPORTDIRFINISH, HEAD_VERSION, COMPAT_VERSION}, last(false) {}
MExportDirFinish(dirfrag_t df, bool l, uint64_t tid) :
MMDSOp{MSG_MDS_EXPORTDIRFINISH, HEAD_VERSION, COMPAT_VERSION}, dirfrag(df), last(l) {
set_tid(tid);
}
~MExportDirFinish() final {}
public:
std::string_view get_type_name() const override { return "ExFin"; }
void print(std::ostream& o) const override {
o << "export_finish(" << dirfrag << (last ? " last" : "") << ")";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(dirfrag, payload);
encode(last, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(dirfrag, p);
decode(last, p);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 1,821 | 26.606061 | 89 | h |
null | ceph-main/src/messages/MExportDirNotify.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MEXPORTDIRNOTIFY_H
#define CEPH_MEXPORTDIRNOTIFY_H
#include "messages/MMDSOp.h"
class MExportDirNotify final : public MMDSOp {
private:
static constexpr int HEAD_VERSION = 1;
static constexpr int COMPAT_VERSION = 1;
dirfrag_t base;
bool ack;
std::pair<__s32,__s32> old_auth, new_auth;
std::list<dirfrag_t> bounds; // bounds; these dirs are _not_ included (tho the dirfragdes are)
public:
dirfrag_t get_dirfrag() const { return base; }
std::pair<__s32,__s32> get_old_auth() const { return old_auth; }
std::pair<__s32,__s32> get_new_auth() const { return new_auth; }
bool wants_ack() const { return ack; }
const std::list<dirfrag_t>& get_bounds() const { return bounds; }
std::list<dirfrag_t>& get_bounds() { return bounds; }
protected:
MExportDirNotify() :
MMDSOp{MSG_MDS_EXPORTDIRNOTIFY, HEAD_VERSION, COMPAT_VERSION} {}
MExportDirNotify(dirfrag_t i, uint64_t tid, bool a, std::pair<__s32,__s32> oa,
std::pair<__s32,__s32> na) :
MMDSOp{MSG_MDS_EXPORTDIRNOTIFY, HEAD_VERSION, COMPAT_VERSION},
base(i), ack(a), old_auth(oa), new_auth(na) {
set_tid(tid);
}
~MExportDirNotify() final {}
public:
std::string_view get_type_name() const override { return "ExNot"; }
void print(std::ostream& o) const override {
o << "export_notify(" << base;
o << " " << old_auth << " -> " << new_auth;
if (ack)
o << " ack)";
else
o << " no ack)";
}
void copy_bounds(std::list<dirfrag_t>& ex) {
this->bounds = ex;
}
void copy_bounds(std::set<dirfrag_t>& ex) {
for (auto i = ex.begin(); i != ex.end(); ++i)
bounds.push_back(*i);
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(base, payload);
encode(ack, payload);
encode(old_auth, payload);
encode(new_auth, payload);
encode(bounds, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(base, p);
decode(ack, p);
decode(old_auth, p);
decode(new_auth, p);
decode(bounds, p);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 2,724 | 28.301075 | 97 | h |
null | ceph-main/src/messages/MExportDirNotifyAck.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MEXPORTDIRNOTIFYACK_H
#define CEPH_MEXPORTDIRNOTIFYACK_H
#include "messages/MMDSOp.h"
class MExportDirNotifyAck final : public MMDSOp {
private:
static constexpr int HEAD_VERSION = 1;
static constexpr int COMPAT_VERSION = 1;
dirfrag_t dirfrag;
std::pair<__s32,__s32> new_auth;
public:
dirfrag_t get_dirfrag() const { return dirfrag; }
std::pair<__s32,__s32> get_new_auth() const { return new_auth; }
protected:
MExportDirNotifyAck() :
MMDSOp{MSG_MDS_EXPORTDIRNOTIFYACK, HEAD_VERSION, COMPAT_VERSION} {}
MExportDirNotifyAck(dirfrag_t df, uint64_t tid, std::pair<__s32,__s32> na) :
MMDSOp{MSG_MDS_EXPORTDIRNOTIFYACK, HEAD_VERSION, COMPAT_VERSION}, dirfrag(df), new_auth(na) {
set_tid(tid);
}
~MExportDirNotifyAck() final {}
public:
std::string_view get_type_name() const override { return "ExNotA"; }
void print(std::ostream& o) const override {
o << "export_notify_ack(" << dirfrag << ")";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(dirfrag, payload);
encode(new_auth, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(dirfrag, p);
decode(new_auth, p);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 1,891 | 27.666667 | 97 | h |
null | ceph-main/src/messages/MExportDirPrep.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MEXPORTDIRPREP_H
#define CEPH_MEXPORTDIRPREP_H
#include "include/types.h"
#include "messages/MMDSOp.h"
class MExportDirPrep final : public MMDSOp {
private:
static constexpr int HEAD_VERSION = 1;
static constexpr int COMPAT_VERSION = 1;
dirfrag_t dirfrag;
public:
ceph::buffer::list basedir;
std::list<dirfrag_t> bounds;
std::list<ceph::buffer::list> traces;
private:
std::set<mds_rank_t> bystanders;
bool b_did_assim = false;
public:
dirfrag_t get_dirfrag() const { return dirfrag; }
const std::list<dirfrag_t>& get_bounds() const { return bounds; }
const std::set<mds_rank_t> &get_bystanders() const { return bystanders; }
bool did_assim() const { return b_did_assim; }
void mark_assim() { b_did_assim = true; }
protected:
MExportDirPrep() = default;
MExportDirPrep(dirfrag_t df, uint64_t tid) :
MMDSOp{MSG_MDS_EXPORTDIRPREP, HEAD_VERSION, COMPAT_VERSION},
dirfrag(df)
{
set_tid(tid);
}
~MExportDirPrep() final {}
public:
std::string_view get_type_name() const override { return "ExP"; }
void print(std::ostream& o) const override {
o << "export_prep(" << dirfrag << ")";
}
void add_bound(dirfrag_t df) {
bounds.push_back( df );
}
void add_trace(ceph::buffer::list& bl) {
traces.push_back(bl);
}
void add_bystander(mds_rank_t who) {
bystanders.insert(who);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(dirfrag, p);
decode(basedir, p);
decode(bounds, p);
decode(traces, p);
decode(bystanders, p);
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(dirfrag, payload);
encode(basedir, payload);
encode(bounds, payload);
encode(traces, payload);
encode(bystanders, payload);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 2,464 | 24.677083 | 75 | h |
null | ceph-main/src/messages/MExportDirPrepAck.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MEXPORTDIRPREPACK_H
#define CEPH_MEXPORTDIRPREPACK_H
#include "include/types.h"
#include "messages/MMDSOp.h"
class MExportDirPrepAck final : public MMDSOp {
private:
static constexpr int HEAD_VERSION = 1;
static constexpr int COMPAT_VERSION = 1;
dirfrag_t dirfrag;
bool success = false;
public:
dirfrag_t get_dirfrag() const { return dirfrag; }
protected:
MExportDirPrepAck() :
MMDSOp{MSG_MDS_EXPORTDIRPREPACK, HEAD_VERSION, COMPAT_VERSION} {}
MExportDirPrepAck(dirfrag_t df, bool s, uint64_t tid) :
MMDSOp{MSG_MDS_EXPORTDIRPREPACK, HEAD_VERSION, COMPAT_VERSION}, dirfrag(df), success(s) {
set_tid(tid);
}
~MExportDirPrepAck() final {}
public:
bool is_success() const { return success; }
std::string_view get_type_name() const override { return "ExPAck"; }
void print(std::ostream& o) const override {
o << "export_prep_ack(" << dirfrag << (success ? " success)" : " fail)");
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(dirfrag, p);
decode(success, p);
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(dirfrag, payload);
encode(success, payload);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 1,876 | 27.014925 | 93 | h |
null | ceph-main/src/messages/MFSMap.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MFSMAP_H
#define CEPH_MFSMAP_H
#include "msg/Message.h"
#include "mds/FSMap.h"
#include "include/ceph_features.h"
class MFSMap final : public Message {
public:
epoch_t epoch;
version_t get_epoch() const { return epoch; }
const FSMap& get_fsmap() const {return fsmap;}
MFSMap() :
Message{CEPH_MSG_FS_MAP}, epoch(0) {}
MFSMap(const uuid_d &f, const FSMap &fsmap_) :
Message{CEPH_MSG_FS_MAP},
epoch(fsmap_.get_epoch()),
fsmap{fsmap_}
{}
private:
FSMap fsmap;
~MFSMap() final {}
public:
std::string_view get_type_name() const override { return "fsmap"; }
void print(std::ostream& out) const override {
out << "fsmap(e " << epoch << ")";
}
// marshalling
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(epoch, p);
decode(fsmap, p);
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(epoch, payload);
encode(fsmap, payload, features);
}
};
#endif
| 1,440 | 21.873016 | 71 | h |
null | ceph-main/src/messages/MFSMapUser.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*/
#ifndef CEPH_MFSMAPCOMPACT_H
#define CEPH_MFSMAPCOMPACT_H
#include "msg/Message.h"
#include "mds/FSMapUser.h"
#include "include/ceph_features.h"
class MFSMapUser final : public Message {
public:
epoch_t epoch;
version_t get_epoch() const { return epoch; }
const FSMapUser& get_fsmap() const { return fsmap; }
MFSMapUser() :
Message{CEPH_MSG_FS_MAP_USER}, epoch(0) {}
MFSMapUser(const uuid_d &f, const FSMapUser &fsmap_) :
Message{CEPH_MSG_FS_MAP_USER},
epoch(fsmap_.epoch),
fsmap{fsmap_}
{}
private:
FSMapUser fsmap;
~MFSMapUser() final {}
public:
std::string_view get_type_name() const override { return "fsmap.user"; }
void print(std::ostream& out) const override {
out << "fsmap.user(e " << epoch << ")";
}
// marshalling
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(epoch, p);
decode(fsmap, p);
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(epoch, payload);
encode(fsmap, payload, features);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
};
#endif
| 1,611 | 23.8 | 74 | h |
null | ceph-main/src/messages/MForward.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2010 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
* Client requests often need to get forwarded from some monitor
* to the leader. This class encapsulates the original message
* along with the client's caps so the leader can do proper permissions
* checking.
*/
#ifndef CEPH_MFORWARD_H
#define CEPH_MFORWARD_H
#include "msg/Message.h"
#include "mon/MonCap.h"
#include "include/encoding.h"
#include "include/stringify.h"
class MForward final : public Message {
public:
uint64_t tid;
uint8_t client_type;
entity_addrvec_t client_addrs;
entity_addr_t client_socket_addr;
MonCap client_caps;
uint64_t con_features;
EntityName entity_name;
PaxosServiceMessage *msg; // incoming or outgoing message
std::string msg_desc; // for operator<< only
static constexpr int HEAD_VERSION = 4;
static constexpr int COMPAT_VERSION = 4;
MForward() : Message{MSG_FORWARD, HEAD_VERSION, COMPAT_VERSION},
tid(0), con_features(0), msg(NULL) {}
MForward(uint64_t t, PaxosServiceMessage *m, uint64_t feat,
const MonCap& caps) :
Message{MSG_FORWARD, HEAD_VERSION, COMPAT_VERSION},
tid(t), client_caps(caps), msg(NULL) {
client_type = m->get_source().type();
client_addrs = m->get_source_addrs();
#ifdef WITH_SEASTAR
ceph_abort("In crimson, conn is independently maintained outside Message");
#else
if (auto &con = m->get_connection()) {
client_socket_addr = con->get_peer_socket_addr();
}
#endif
con_features = feat;
msg = (PaxosServiceMessage*)m->get();
}
private:
~MForward() final {
if (msg) {
// message was unclaimed
msg->put();
msg = NULL;
}
}
public:
void encode_payload(uint64_t features) override {
using ceph::encode;
if (!HAVE_FEATURE(features, SERVER_NAUTILUS)) {
header.version = 3;
header.compat_version = 3;
encode(tid, payload);
entity_inst_t client;
client.name = entity_name_t(client_type, -1);
client.addr = client_addrs.legacy_addr();
encode(client, payload, features);
encode(client_caps, payload, features);
// Encode client message with intersection of target and source
// features. This could matter if the semantics of the encoded
// message are changed when reencoding with more features than the
// client had originally. That should never happen, but we may as
// well be defensive here.
if (con_features != features) {
msg->clear_payload();
}
encode_message(msg, features & con_features, payload);
encode(con_features, payload);
encode(entity_name, payload);
return;
}
header.version = HEAD_VERSION;
header.compat_version = COMPAT_VERSION;
encode(tid, payload);
encode(client_type, payload, features);
encode(client_addrs, payload, features);
encode(client_socket_addr, payload, features);
encode(client_caps, payload, features);
// Encode client message with intersection of target and source
// features. This could matter if the semantics of the encoded
// message are changed when reencoding with more features than the
// client had originally. That should never happen, but we may as
// well be defensive here.
if (con_features != features) {
msg->clear_payload();
}
encode_message(msg, features & con_features, payload);
encode(con_features, payload);
encode(entity_name, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(tid, p);
if (header.version < 4) {
entity_inst_t client;
decode(client, p);
client_type = client.name.type();
client_addrs = entity_addrvec_t(client.addr);
client_socket_addr = client.addr;
} else {
decode(client_type, p);
decode(client_addrs, p);
decode(client_socket_addr, p);
}
decode(client_caps, p);
msg = (PaxosServiceMessage *)decode_message(NULL, 0, p);
decode(con_features, p);
decode(entity_name, p);
}
PaxosServiceMessage *claim_message() {
// let whoever is claiming the message deal with putting it.
ceph_assert(msg);
msg_desc = stringify(*msg);
PaxosServiceMessage *m = msg;
msg = NULL;
return m;
}
std::string_view get_type_name() const override { return "forward"; }
void print(std::ostream& o) const override {
o << "forward(";
if (msg) {
o << *msg;
} else {
o << msg_desc;
}
o << " caps " << client_caps
<< " tid " << tid
<< " con_features " << con_features << ")";
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
};
#endif
| 5,094 | 30.257669 | 79 | h |
null | ceph-main/src/messages/MGatherCaps.h | #ifndef CEPH_MGATHERCAPS_H
#define CEPH_MGATHERCAPS_H
#include "messages/MMDSOp.h"
class MGatherCaps final : public MMDSOp {
static constexpr int HEAD_VERSION = 1;
static constexpr int COMPAT_VERSION = 1;
public:
inodeno_t ino;
protected:
MGatherCaps() :
MMDSOp{MSG_MDS_GATHERCAPS, HEAD_VERSION, COMPAT_VERSION} {}
~MGatherCaps() final {}
public:
std::string_view get_type_name() const override { return "gather_caps"; }
void print(std::ostream& o) const override {
o << "gather_caps(" << ino << ")";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(ino, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(ino, p);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 976 | 22.261905 | 75 | h |
null | ceph-main/src/messages/MGenericMessage.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MGENERICMESSAGE_H
#define CEPH_MGENERICMESSAGE_H
#include "msg/Message.h"
class MGenericMessage : public Message {
private:
char tname[20];
//long pcid;
public:
MGenericMessage(int t=0) : Message{t} {
snprintf(tname, sizeof(tname), "generic%d", get_type());
}
//void set_pcid(long pcid) { this->pcid = pcid; }
//long get_pcid() { return pcid; }
std::string_view get_type_name() const override { return tname; }
void decode_payload() override { }
void encode_payload(uint64_t features) override { }
};
#endif
| 981 | 22.95122 | 71 | h |
null | ceph-main/src/messages/MGetConfig.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
#pragma once
#include "msg/Message.h"
class MGetConfig : public Message {
public:
static constexpr int HEAD_VERSION = 1;
static constexpr int COMPAT_VERSION = 1;
EntityName name; ///< e.g., mon.a, client.foo
std::string host; ///< our hostname
std::string device_class;
MGetConfig() : Message{MSG_GET_CONFIG, HEAD_VERSION, COMPAT_VERSION} { }
MGetConfig(const EntityName& n, const std::string& h)
: Message{MSG_GET_CONFIG, HEAD_VERSION, COMPAT_VERSION},
name(n),
host(h) {}
std::string_view get_type_name() const override {
return "get_config";
}
void print(std::ostream& o) const override {
o << "get_config(" << name << "@" << host;
if (device_class.size()) {
o << " device_class " << device_class;
}
o << ")";
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(name, p);
decode(host, p);
decode(device_class, p);
}
void encode_payload(uint64_t) override {
using ceph::encode;
encode(name, payload);
encode(host, payload);
encode(device_class, payload);
}
};
| 1,219 | 23.897959 | 74 | h |
null | ceph-main/src/messages/MGetPoolStats.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MGETPOOLSTATS_H
#define CEPH_MGETPOOLSTATS_H
#include "messages/PaxosServiceMessage.h"
class MGetPoolStats final : public PaxosServiceMessage {
public:
uuid_d fsid;
std::vector<std::string> pools;
MGetPoolStats() : PaxosServiceMessage{MSG_GETPOOLSTATS, 0} {}
MGetPoolStats(const uuid_d& f, ceph_tid_t t, std::vector<std::string>& ls, version_t l) :
PaxosServiceMessage{MSG_GETPOOLSTATS, l},
fsid(f), pools(ls) {
set_tid(t);
}
private:
~MGetPoolStats() final {}
public:
std::string_view get_type_name() const override { return "getpoolstats"; }
void print(std::ostream& out) const override {
out << "getpoolstats(" << get_tid() << " " << pools << " v" << version << ")";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
paxos_encode();
encode(fsid, payload);
encode(pools, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
paxos_decode(p);
decode(fsid, p);
decode(pools, p);
}
};
#endif
| 1,479 | 24.517241 | 91 | h |
null | ceph-main/src/messages/MGetPoolStatsReply.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MGETPOOLSTATSREPLY_H
#define CEPH_MGETPOOLSTATSREPLY_H
class MGetPoolStatsReply final : public PaxosServiceMessage {
static constexpr int HEAD_VERSION = 2;
static constexpr int COMPAT_VERSION = 1;
public:
uuid_d fsid;
boost::container::flat_map<std::string, pool_stat_t> pool_stats;
bool per_pool = false;
MGetPoolStatsReply() : PaxosServiceMessage{MSG_GETPOOLSTATSREPLY, 0,
HEAD_VERSION, COMPAT_VERSION} {}
MGetPoolStatsReply(uuid_d& f, ceph_tid_t t, version_t v) :
PaxosServiceMessage{MSG_GETPOOLSTATSREPLY, v,
HEAD_VERSION, COMPAT_VERSION},
fsid(f) {
set_tid(t);
}
private:
~MGetPoolStatsReply() final {}
public:
std::string_view get_type_name() const override { return "getpoolstats"; }
void print(std::ostream& out) const override {
out << "getpoolstatsreply(" << get_tid();
if (per_pool)
out << " per_pool";
out << " v" << version << ")";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
paxos_encode();
encode(fsid, payload);
encode(pool_stats, payload, features);
encode(per_pool, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
paxos_decode(p);
decode(fsid, p);
decode(pool_stats, p);
if (header.version >= 2) {
decode(per_pool, p);
} else {
per_pool = false;
}
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
};
#endif
| 1,956 | 25.445946 | 76 | h |
null | ceph-main/src/messages/MHeartbeat.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MHEARTBEAT_H
#define CEPH_MHEARTBEAT_H
#include "include/types.h"
#include "common/DecayCounter.h"
#include "messages/MMDSOp.h"
class MHeartbeat final : public MMDSOp {
private:
mds_load_t load;
__s32 beat = 0;
std::map<mds_rank_t, float> import_map;
public:
const mds_load_t& get_load() const { return load; }
int get_beat() const { return beat; }
const std::map<mds_rank_t, float>& get_import_map() const { return import_map; }
std::map<mds_rank_t, float>& get_import_map() { return import_map; }
protected:
MHeartbeat() : MMDSOp(MSG_MDS_HEARTBEAT), load(DecayRate()) {}
MHeartbeat(mds_load_t& load, int beat)
: MMDSOp(MSG_MDS_HEARTBEAT),
load(load),
beat(beat)
{}
~MHeartbeat() final {}
public:
std::string_view get_type_name() const override { return "HB"; }
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(load, payload);
encode(beat, payload);
encode(import_map, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(load, p);
decode(beat, p);
decode(import_map, p);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 1,806 | 25.188406 | 82 | h |
null | ceph-main/src/messages/MInodeFileCaps.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MINODEFILECAPS_H
#define CEPH_MINODEFILECAPS_H
#include "messages/MMDSOp.h"
class MInodeFileCaps final : public MMDSOp {
private:
static constexpr int HEAD_VERSION = 1;
static constexpr int COMPAT_VERSION = 1;
inodeno_t ino;
__u32 caps = 0;
public:
inodeno_t get_ino() const { return ino; }
int get_caps() const { return caps; }
protected:
MInodeFileCaps() : MMDSOp(MSG_MDS_INODEFILECAPS, HEAD_VERSION, COMPAT_VERSION) {}
MInodeFileCaps(inodeno_t ino, int caps) :
MMDSOp(MSG_MDS_INODEFILECAPS, HEAD_VERSION, COMPAT_VERSION) {
this->ino = ino;
this->caps = caps;
}
~MInodeFileCaps() final {}
public:
std::string_view get_type_name() const override { return "inode_file_caps";}
void print(std::ostream& out) const override {
out << "inode_file_caps(" << ino << " " << ccap_string(caps) << ")";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(ino, payload);
encode(caps, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(ino, p);
decode(caps, p);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 1,787 | 26.090909 | 83 | h |
null | ceph-main/src/messages/MKVData.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
#pragma once
#include "msg/Message.h"
class MKVData : public Message {
public:
static constexpr int HEAD_VERSION = 1;
static constexpr int COMPAT_VERSION = 1;
version_t version;
std::string prefix;
bool incremental = false;
// use transparent comparator so we can lookup in it by std::string_view keys
std::map<std::string,std::optional<bufferlist>,std::less<>> data;
MKVData() : Message{MSG_KV_DATA, HEAD_VERSION, COMPAT_VERSION} { }
std::string_view get_type_name() const override {
return "kv_data";
}
void print(std::ostream& o) const override {
o << "kv_data(v" << version
<< " prefix " << prefix << ", "
<< (incremental ? "incremental, " : "full, ")
<< data.size() << " keys" << ")";
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(version, p);
decode(prefix, p);
decode(incremental, p);
decode(data, p);
}
void encode_payload(uint64_t) override {
using ceph::encode;
encode(version, payload);
encode(prefix, payload);
encode(incremental, payload);
encode(data, payload);
}
};
| 1,233 | 24.183673 | 79 | h |
null | ceph-main/src/messages/MLock.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MLOCK_H
#define CEPH_MLOCK_H
#include "mds/locks.h"
#include "mds/SimpleLock.h"
#include "messages/MMDSOp.h"
class MLock final : public MMDSOp {
private:
static constexpr int HEAD_VERSION = 1;
static constexpr int COMPAT_VERSION = 1;
int32_t action = 0; // action type
mds_rank_t asker = 0; // who is initiating this request
metareqid_t reqid; // for remote lock requests
__u16 lock_type = 0; // lock object type
MDSCacheObjectInfo object_info;
ceph::buffer::list lockdata; // and possibly some data
public:
ceph::buffer::list& get_data() { return lockdata; }
const ceph::buffer::list& get_data() const { return lockdata; }
int get_asker() const { return asker; }
int get_action() const { return action; }
metareqid_t get_reqid() const { return reqid; }
int get_lock_type() const { return lock_type; }
const MDSCacheObjectInfo &get_object_info() const { return object_info; }
MDSCacheObjectInfo &get_object_info() { return object_info; }
protected:
MLock() : MMDSOp{MSG_MDS_LOCK, HEAD_VERSION, COMPAT_VERSION} {}
MLock(int ac, mds_rank_t as) :
MMDSOp{MSG_MDS_LOCK, HEAD_VERSION, COMPAT_VERSION},
action(ac), asker(as),
lock_type(0) { }
MLock(SimpleLock *lock, int ac, mds_rank_t as) :
MMDSOp{MSG_MDS_LOCK, HEAD_VERSION, COMPAT_VERSION},
action(ac), asker(as),
lock_type(lock->get_type()) {
lock->get_parent()->set_object_info(object_info);
}
MLock(SimpleLock *lock, int ac, mds_rank_t as, ceph::buffer::list& bl) :
MMDSOp{MSG_MDS_LOCK, HEAD_VERSION, COMPAT_VERSION},
action(ac), asker(as), lock_type(lock->get_type()) {
lock->get_parent()->set_object_info(object_info);
lockdata = std::move(bl);
}
~MLock() final {}
public:
std::string_view get_type_name() const override { return "ILock"; }
void print(std::ostream& out) const override {
out << "lock(a=" << SimpleLock::get_lock_action_name(action)
<< " " << SimpleLock::get_lock_type_name(lock_type)
<< " " << object_info
<< ")";
}
void set_reqid(metareqid_t ri) { reqid = ri; }
void set_data(const ceph::buffer::list& lockdata) {
this->lockdata = lockdata;
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(asker, p);
decode(action, p);
decode(reqid, p);
decode(lock_type, p);
decode(object_info, p);
decode(lockdata, p);
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(asker, payload);
encode(action, payload);
encode(reqid, payload);
encode(lock_type, payload);
encode(object_info, payload);
encode(lockdata, payload);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 3,334 | 29.59633 | 75 | h |
null | ceph-main/src/messages/MLog.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MLOG_H
#define CEPH_MLOG_H
#include "common/LogEntry.h"
#include "messages/PaxosServiceMessage.h"
#include <deque>
class MLog final : public PaxosServiceMessage {
public:
uuid_d fsid;
std::deque<LogEntry> entries;
MLog() : PaxosServiceMessage{MSG_LOG, 0} {}
MLog(const uuid_d& f, std::deque<LogEntry>&& e)
: PaxosServiceMessage{MSG_LOG, 0}, fsid(f), entries{std::move(e)} { }
MLog(const uuid_d& f) : PaxosServiceMessage(MSG_LOG, 0), fsid(f) { }
private:
~MLog() final {}
public:
std::string_view get_type_name() const override { return "log"; }
void print(std::ostream& out) const override {
out << "log(";
if (entries.size())
out << entries.size() << " entries from seq " << entries.front().seq
<< " at " << entries.front().stamp;
out << ")";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
paxos_encode();
encode(fsid, payload);
encode(entries, payload, features);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
paxos_decode(p);
decode(fsid, p);
decode(entries, p);
}
};
#endif
| 1,575 | 24.836066 | 74 | h |
null | ceph-main/src/messages/MLogAck.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MLOGACK_H
#define CEPH_MLOGACK_H
#include <iostream>
#include <string>
#include <string_view>
#include "include/uuid.h"
#include "msg/Message.h"
class MLogAck final : public Message {
public:
uuid_d fsid;
version_t last = 0;
std::string channel;
MLogAck() : Message{MSG_LOGACK} {}
MLogAck(uuid_d& f, version_t l) : Message{MSG_LOGACK}, fsid(f), last(l) {}
private:
~MLogAck() final {}
public:
std::string_view get_type_name() const override { return "log_ack"; }
void print(std::ostream& out) const override {
out << "log(last " << last << ")";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(fsid, payload);
encode(last, payload);
encode(channel, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(fsid, p);
decode(last, p);
if (!p.end())
decode(channel, p);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
};
#endif
| 1,489 | 22.650794 | 76 | h |
null | ceph-main/src/messages/MMDSBeacon.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MMDSBEACON_H
#define CEPH_MMDSBEACON_H
#include <string_view>
#include "msg/Message.h"
#include "messages/PaxosServiceMessage.h"
#include "include/types.h"
#include "mds/MDSMap.h"
/**
* Unique ID for each type of metric we can send to the mon, so that if the mon
* knows about the IDs then it can implement special behaviour for certain
* messages.
*/
enum mds_metric_t {
MDS_HEALTH_NULL = 0,
MDS_HEALTH_TRIM,
MDS_HEALTH_CLIENT_RECALL,
MDS_HEALTH_CLIENT_LATE_RELEASE,
MDS_HEALTH_CLIENT_RECALL_MANY,
MDS_HEALTH_CLIENT_LATE_RELEASE_MANY,
MDS_HEALTH_CLIENT_OLDEST_TID,
MDS_HEALTH_CLIENT_OLDEST_TID_MANY,
MDS_HEALTH_DAMAGE,
MDS_HEALTH_READ_ONLY,
MDS_HEALTH_SLOW_REQUEST,
MDS_HEALTH_CACHE_OVERSIZED,
MDS_HEALTH_SLOW_METADATA_IO,
MDS_HEALTH_CLIENTS_LAGGY,
MDS_HEALTH_DUMMY, // not a real health warning, for testing
};
inline const char *mds_metric_name(mds_metric_t m)
{
switch (m) {
case MDS_HEALTH_TRIM: return "MDS_TRIM";
case MDS_HEALTH_CLIENT_RECALL: return "MDS_CLIENT_RECALL";
case MDS_HEALTH_CLIENT_LATE_RELEASE: return "MDS_CLIENT_LATE_RELEASE";
case MDS_HEALTH_CLIENT_RECALL_MANY: return "MDS_CLIENT_RECALL_MANY";
case MDS_HEALTH_CLIENT_LATE_RELEASE_MANY: return "MDS_CLIENT_LATE_RELEASE_MANY";
case MDS_HEALTH_CLIENT_OLDEST_TID: return "MDS_CLIENT_OLDEST_TID";
case MDS_HEALTH_CLIENT_OLDEST_TID_MANY: return "MDS_CLIENT_OLDEST_TID_MANY";
case MDS_HEALTH_DAMAGE: return "MDS_DAMAGE";
case MDS_HEALTH_READ_ONLY: return "MDS_READ_ONLY";
case MDS_HEALTH_SLOW_REQUEST: return "MDS_SLOW_REQUEST";
case MDS_HEALTH_CACHE_OVERSIZED: return "MDS_CACHE_OVERSIZED";
case MDS_HEALTH_SLOW_METADATA_IO: return "MDS_SLOW_METADATA_IO";
case MDS_HEALTH_CLIENTS_LAGGY: return "MDS_CLIENTS_LAGGY";
case MDS_HEALTH_DUMMY: return "MDS_DUMMY";
default:
return "???";
}
}
inline const char *mds_metric_summary(mds_metric_t m)
{
switch (m) {
case MDS_HEALTH_TRIM:
return "%num% MDSs behind on trimming";
case MDS_HEALTH_CLIENT_RECALL:
return "%num% clients failing to respond to cache pressure";
case MDS_HEALTH_CLIENT_LATE_RELEASE:
return "%num% clients failing to respond to capability release";
case MDS_HEALTH_CLIENT_RECALL_MANY:
return "%num% MDSs have many clients failing to respond to cache pressure";
case MDS_HEALTH_CLIENT_LATE_RELEASE_MANY:
return "%num% MDSs have many clients failing to respond to capability "
"release";
case MDS_HEALTH_CLIENT_OLDEST_TID:
return "%num% clients failing to advance oldest client/flush tid";
case MDS_HEALTH_CLIENT_OLDEST_TID_MANY:
return "%num% MDSs have clients failing to advance oldest client/flush tid";
case MDS_HEALTH_DAMAGE:
return "%num% MDSs report damaged metadata";
case MDS_HEALTH_READ_ONLY:
return "%num% MDSs are read only";
case MDS_HEALTH_SLOW_REQUEST:
return "%num% MDSs report slow requests";
case MDS_HEALTH_CACHE_OVERSIZED:
return "%num% MDSs report oversized cache";
case MDS_HEALTH_SLOW_METADATA_IO:
return "%num% MDSs report slow metadata IOs";
case MDS_HEALTH_CLIENTS_LAGGY:
return "%num% client(s) laggy due to laggy OSDs";
default:
return "???";
}
}
/**
* This structure is designed to allow some flexibility in how we emit health
* complaints, such that:
* - The mon doesn't have to have foreknowledge of all possible metrics: we can
* implement new messages in the MDS and have the mon pass them through to the user
* (enables us to do complex checks inside the MDS, and allows mon to be older version
* than MDS)
* - The mon has enough information to perform reductions on some types of metric, for
* example complaints about the same client from multiple MDSs where we might want
* to reduce three "client X is stale on MDS y" metrics into one "client X is stale
* on 3 MDSs" message.
*/
struct MDSHealthMetric
{
mds_metric_t type;
health_status_t sev;
std::string message;
std::map<std::string, std::string> metadata;
void encode(ceph::buffer::list& bl) const {
ENCODE_START(1, 1, bl);
ceph_assert(type != MDS_HEALTH_NULL);
encode((uint16_t)type, bl);
encode((uint8_t)sev, bl);
encode(message, bl);
encode(metadata, bl);
ENCODE_FINISH(bl);
}
void decode(ceph::buffer::list::const_iterator& bl) {
DECODE_START(1, bl);
uint16_t raw_type;
decode(raw_type, bl);
type = (mds_metric_t)raw_type;
ceph_assert(type != MDS_HEALTH_NULL);
uint8_t raw_sev;
decode(raw_sev, bl);
sev = (health_status_t)raw_sev;
decode(message, bl);
decode(metadata, bl);
DECODE_FINISH(bl);
}
bool operator==(MDSHealthMetric const &other) const
{
return (type == other.type && sev == other.sev && message == other.message);
}
MDSHealthMetric() : type(MDS_HEALTH_NULL), sev(HEALTH_OK) {}
MDSHealthMetric(mds_metric_t type_, health_status_t sev_, std::string_view message_)
: type(type_), sev(sev_), message(message_) {}
};
WRITE_CLASS_ENCODER(MDSHealthMetric)
/**
* Health metrics send by the MDS to the mon, so that the mon can generate
* user friendly warnings about undesirable states.
*/
struct MDSHealth
{
std::vector<MDSHealthMetric> metrics;
void encode(ceph::buffer::list& bl) const {
ENCODE_START(1, 1, bl);
encode(metrics, bl);
ENCODE_FINISH(bl);
}
void decode(ceph::buffer::list::const_iterator& bl) {
DECODE_START(1, bl);
decode(metrics, bl);
DECODE_FINISH(bl);
}
bool operator==(MDSHealth const &other) const
{
return metrics == other.metrics;
}
};
WRITE_CLASS_ENCODER(MDSHealth)
class MMDSBeacon final : public PaxosServiceMessage {
private:
static constexpr int HEAD_VERSION = 8;
static constexpr int COMPAT_VERSION = 6;
uuid_d fsid;
mds_gid_t global_id = MDS_GID_NONE;
std::string name;
MDSMap::DaemonState state = MDSMap::STATE_NULL;
version_t seq = 0;
CompatSet compat;
MDSHealth health;
std::map<std::string, std::string> sys_info;
uint64_t mds_features = 0;
std::string fs;
protected:
MMDSBeacon() : PaxosServiceMessage(MSG_MDS_BEACON, 0, HEAD_VERSION, COMPAT_VERSION)
{
set_priority(CEPH_MSG_PRIO_HIGH);
}
MMDSBeacon(const uuid_d &f, mds_gid_t g, const std::string& n, epoch_t les,
MDSMap::DaemonState st, version_t se, uint64_t feat) :
PaxosServiceMessage(MSG_MDS_BEACON, les, HEAD_VERSION, COMPAT_VERSION),
fsid(f), global_id(g), name(n), state(st), seq(se),
mds_features(feat) {
set_priority(CEPH_MSG_PRIO_HIGH);
}
~MMDSBeacon() final {}
public:
const uuid_d& get_fsid() const { return fsid; }
mds_gid_t get_global_id() const { return global_id; }
const std::string& get_name() const { return name; }
epoch_t get_last_epoch_seen() const { return version; }
MDSMap::DaemonState get_state() const { return state; }
version_t get_seq() const { return seq; }
std::string_view get_type_name() const override { return "mdsbeacon"; }
uint64_t get_mds_features() const { return mds_features; }
CompatSet const& get_compat() const { return compat; }
void set_compat(const CompatSet& c) { compat = c; }
MDSHealth const& get_health() const { return health; }
void set_health(const MDSHealth &h) { health = h; }
const std::string& get_fs() const { return fs; }
void set_fs(std::string_view s) { fs = s; }
const std::map<std::string, std::string>& get_sys_info() const { return sys_info; }
void set_sys_info(const std::map<std::string, std::string>& i) { sys_info = i; }
void print(std::ostream& out) const override {
out << "mdsbeacon(" << global_id << "/" << name
<< " " << ceph_mds_state_name(state);
if (fs.size()) {
out << " fs=" << fs;
}
out << " seq=" << seq << " v" << version << ")";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
paxos_encode();
encode(fsid, payload);
encode(global_id, payload);
encode((__u32)state, payload);
encode(seq, payload);
encode(name, payload);
encode(MDS_RANK_NONE, payload);
encode(std::string(), payload);
encode(compat, payload);
encode(health, payload);
if (state == MDSMap::STATE_BOOT) {
encode(sys_info, payload);
}
encode(mds_features, payload);
encode(FS_CLUSTER_ID_NONE, payload);
encode(false, payload);
encode(fs, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
paxos_decode(p);
decode(fsid, p);
decode(global_id, p);
__u32 raw_state;
decode(raw_state, p);
state = (MDSMap::DaemonState)raw_state;
decode(seq, p);
decode(name, p);
{
mds_rank_t standby_for_rank;
decode(standby_for_rank, p);
}
{
std::string standby_for_name;
decode(standby_for_name, p);
}
decode(compat, p);
decode(health, p);
if (state == MDSMap::STATE_BOOT) {
decode(sys_info, p);
}
decode(mds_features, p);
{
fs_cluster_id_t standby_for_fscid;
decode(standby_for_fscid, p);
}
if (header.version >= 7) {
bool standby_replay;
decode(standby_replay, p);
}
if (header.version < 7 && state == MDSMap::STATE_STANDBY_REPLAY) {
// Old MDS daemons request the state, instead of explicitly
// advertising that they are configured as a replay daemon.
state = MDSMap::STATE_STANDBY;
}
if (header.version >= 8) {
decode(fs, p);
}
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 10,079 | 29.453172 | 88 | h |
null | ceph-main/src/messages/MMDSFindIno.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2011 New Dream Network
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MDSFINDINO_H
#define CEPH_MDSFINDINO_H
#include "include/filepath.h"
#include "messages/MMDSOp.h"
class MMDSFindIno final : public MMDSOp {
static constexpr int HEAD_VERSION = 1;
static constexpr int COMPAT_VERSION = 1;
public:
ceph_tid_t tid {0};
inodeno_t ino;
protected:
MMDSFindIno() : MMDSOp{MSG_MDS_FINDINO, HEAD_VERSION, COMPAT_VERSION} {}
MMDSFindIno(ceph_tid_t t, inodeno_t i) : MMDSOp{MSG_MDS_FINDINO, HEAD_VERSION, COMPAT_VERSION}, tid(t), ino(i) {}
~MMDSFindIno() final {}
public:
std::string_view get_type_name() const override { return "findino"; }
void print(std::ostream &out) const override {
out << "findino(" << tid << " " << ino << ")";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(tid, payload);
encode(ino, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(tid, p);
decode(ino, p);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 1,601 | 26.62069 | 115 | h |
null | ceph-main/src/messages/MMDSFindInoReply.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2011 New Dream Network
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MDSFINDINOREPLY_H
#define CEPH_MDSFINDINOREPLY_H
#include "include/filepath.h"
#include "messages/MMDSOp.h"
class MMDSFindInoReply final : public MMDSOp {
static constexpr int HEAD_VERSION = 1;
static constexpr int COMPAT_VERSION = 1;
public:
ceph_tid_t tid = 0;
filepath path;
protected:
MMDSFindInoReply() : MMDSOp{MSG_MDS_FINDINOREPLY, HEAD_VERSION, COMPAT_VERSION} {}
MMDSFindInoReply(ceph_tid_t t) : MMDSOp{MSG_MDS_FINDINOREPLY, HEAD_VERSION, COMPAT_VERSION}, tid(t) {}
~MMDSFindInoReply() final {}
public:
std::string_view get_type_name() const override { return "findinoreply"; }
void print(std::ostream &out) const override {
out << "findinoreply(" << tid << " " << path << ")";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(tid, payload);
encode(path, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(tid, p);
decode(path, p);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 1,633 | 27.172414 | 104 | h |
null | ceph-main/src/messages/MMDSFragmentNotify.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MMDSFRAGMENTNOTIFY_H
#define CEPH_MMDSFRAGMENTNOTIFY_H
#include "messages/MMDSOp.h"
class MMDSFragmentNotify final : public MMDSOp {
private:
static constexpr int HEAD_VERSION = 2;
static constexpr int COMPAT_VERSION = 1;
dirfrag_t base_dirfrag;
int8_t bits = 0;
bool ack_wanted = false;
public:
inodeno_t get_ino() const { return base_dirfrag.ino; }
frag_t get_basefrag() const { return base_dirfrag.frag; }
dirfrag_t get_base_dirfrag() const { return base_dirfrag; }
int get_bits() const { return bits; }
bool is_ack_wanted() const { return ack_wanted; }
void mark_ack_wanted() { ack_wanted = true; }
ceph::buffer::list basebl;
protected:
MMDSFragmentNotify() :
MMDSOp{MSG_MDS_FRAGMENTNOTIFY, HEAD_VERSION, COMPAT_VERSION} {}
MMDSFragmentNotify(dirfrag_t df, int b, uint64_t tid) :
MMDSOp{MSG_MDS_FRAGMENTNOTIFY, HEAD_VERSION, COMPAT_VERSION},
base_dirfrag(df), bits(b) {
set_tid(tid);
}
~MMDSFragmentNotify() final {}
public:
std::string_view get_type_name() const override { return "fragment_notify"; }
void print(std::ostream& o) const override {
o << "fragment_notify(" << base_dirfrag << " " << (int)bits << ")";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(base_dirfrag, payload);
encode(bits, payload);
encode(basebl, payload);
encode(ack_wanted, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(base_dirfrag, p);
decode(bits, p);
decode(basebl, p);
if (header.version >= 2)
decode(ack_wanted, p);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 2,285 | 27.936709 | 79 | h |
null | ceph-main/src/messages/MMDSFragmentNotifyAck.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MMDSFRAGMENTNOTIFYAck_H
#define CEPH_MMDSFRAGMENTNOTIFYAck_H
#include "messages/MMDSOp.h"
class MMDSFragmentNotifyAck final : public MMDSOp {
private:
dirfrag_t base_dirfrag;
int8_t bits = 0;
public:
dirfrag_t get_base_dirfrag() const { return base_dirfrag; }
int get_bits() const { return bits; }
ceph::buffer::list basebl;
protected:
MMDSFragmentNotifyAck() : MMDSOp{MSG_MDS_FRAGMENTNOTIFYACK} {}
MMDSFragmentNotifyAck(dirfrag_t df, int b, uint64_t tid) :
MMDSOp{MSG_MDS_FRAGMENTNOTIFYACK},
base_dirfrag(df), bits(b) {
set_tid(tid);
}
~MMDSFragmentNotifyAck() final {}
public:
std::string_view get_type_name() const override { return "fragment_notify_ack"; }
void print(std::ostream& o) const override {
o << "fragment_notify_ack(" << base_dirfrag << " " << (int)bits << ")";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(base_dirfrag, payload);
encode(bits, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(base_dirfrag, p);
decode(bits, p);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 1,778 | 26.369231 | 83 | h |
null | ceph-main/src/messages/MMDSLoadTargets.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2009 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MMDSLoadTargets_H
#define CEPH_MMDSLoadTargets_H
#include "msg/Message.h"
#include "mds/mdstypes.h"
#include "messages/PaxosServiceMessage.h"
#include "include/types.h"
#include <map>
using std::map;
class MMDSLoadTargets final : public PaxosServiceMessage {
public:
mds_gid_t global_id;
std::set<mds_rank_t> targets;
protected:
MMDSLoadTargets() : PaxosServiceMessage(MSG_MDS_OFFLOAD_TARGETS, 0) {}
MMDSLoadTargets(mds_gid_t g, std::set<mds_rank_t>& mds_targets) :
PaxosServiceMessage(MSG_MDS_OFFLOAD_TARGETS, 0),
global_id(g), targets(mds_targets) {}
~MMDSLoadTargets() final {}
public:
std::string_view get_type_name() const override { return "mds_load_targets"; }
void print(std::ostream& o) const override {
o << "mds_load_targets(" << global_id << " " << targets << ")";
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
paxos_decode(p);
decode(global_id, p);
decode(targets, p);
}
void encode_payload(uint64_t features) override {
using ceph::encode;
paxos_encode();
encode(global_id, payload);
encode(targets, payload);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 1,800 | 26.287879 | 80 | h |
null | ceph-main/src/messages/MMDSMap.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MMDSMAP_H
#define CEPH_MMDSMAP_H
#include "msg/Message.h"
#include "mds/MDSMap.h"
#include "include/ceph_features.h"
class MMDSMap final : public SafeMessage {
private:
static constexpr int HEAD_VERSION = 2;
static constexpr int COMPAT_VERSION = 1;
public:
uuid_d fsid;
epoch_t epoch = 0;
ceph::buffer::list encoded;
// don't really need map_fs_name. it was accidentally added in 51af2346fdf
// set it to empty string.
std::string map_fs_name = std::string();
version_t get_epoch() const { return epoch; }
const ceph::buffer::list& get_encoded() const { return encoded; }
protected:
MMDSMap() :
SafeMessage{CEPH_MSG_MDS_MAP, HEAD_VERSION, COMPAT_VERSION} {}
MMDSMap(const uuid_d &f, const MDSMap &mm) :
SafeMessage{CEPH_MSG_MDS_MAP, HEAD_VERSION, COMPAT_VERSION},
fsid(f) {
epoch = mm.get_epoch();
mm.encode(encoded, -1); // we will reencode with fewer features as necessary
}
~MMDSMap() final {}
public:
std::string_view get_type_name() const override { return "mdsmap"; }
void print(std::ostream& out) const override {
out << "mdsmap(e " << epoch << ")";
}
// marshalling
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(fsid, p);
decode(epoch, p);
decode(encoded, p);
if (header.version >= 2) {
decode(map_fs_name, p);
}
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(fsid, payload);
encode(epoch, payload);
if ((features & CEPH_FEATURE_PGID64) == 0 ||
(features & CEPH_FEATURE_MDSENC) == 0 ||
(features & CEPH_FEATURE_MSG_ADDR2) == 0 ||
!HAVE_FEATURE(features, SERVER_NAUTILUS)) {
// reencode for old clients.
MDSMap m;
m.decode(encoded);
encoded.clear();
m.encode(encoded, features);
}
encode(encoded, payload);
encode(map_fs_name, payload);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 2,557 | 26.505376 | 81 | h |
null | ceph-main/src/messages/MMDSMetrics.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
#ifndef CEPH_MDS_METRICS_H
#define CEPH_MDS_METRICS_H
#include "messages/MMDSOp.h"
#include "mds/MDSPerfMetricTypes.h"
class MMDSMetrics final : public MMDSOp {
private:
static constexpr int HEAD_VERSION = 1;
static constexpr int COMPAT_VERSION = 1;
public:
// metrics messsage (client -> metrics map, rank, etc..)
metrics_message_t metrics_message;
protected:
MMDSMetrics() : MMDSOp(MSG_MDS_METRICS, HEAD_VERSION, COMPAT_VERSION) {
}
MMDSMetrics(metrics_message_t metrics_message)
: MMDSOp(MSG_MDS_METRICS, HEAD_VERSION, COMPAT_VERSION),
metrics_message(metrics_message) {
}
~MMDSMetrics() final {}
public:
std::string_view get_type_name() const override {
return "mds_metrics";
}
void print(std::ostream &out) const override {
out << "mds_metrics from rank=" << metrics_message.rank << " carrying "
<< metrics_message.client_metrics_map.size() << " metric updates";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(metrics_message, payload, features);
}
void decode_payload() override {
using ceph::decode;
auto iter = payload.cbegin();
decode(metrics_message, iter);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif // CEPH_MDS_METRICS_H
| 1,533 | 26.392857 | 75 | h |
null | ceph-main/src/messages/MMDSOpenIno.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2011 New Dream Network
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MDSOPENINO_H
#define CEPH_MDSOPENINO_H
#include "messages/MMDSOp.h"
class MMDSOpenIno final : public MMDSOp {
static constexpr int HEAD_VERSION = 1;
static constexpr int COMPAT_VERSION = 1;
public:
inodeno_t ino;
std::vector<inode_backpointer_t> ancestors;
protected:
MMDSOpenIno() : MMDSOp{MSG_MDS_OPENINO, HEAD_VERSION, COMPAT_VERSION} {}
MMDSOpenIno(ceph_tid_t t, inodeno_t i, std::vector<inode_backpointer_t>* pa) :
MMDSOp{MSG_MDS_OPENINO, HEAD_VERSION, COMPAT_VERSION}, ino(i) {
header.tid = t;
if (pa)
ancestors = *pa;
}
~MMDSOpenIno() final {}
public:
std::string_view get_type_name() const override { return "openino"; }
void print(std::ostream &out) const override {
out << "openino(" << header.tid << " " << ino << " " << ancestors << ")";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(ino, payload);
encode(ancestors, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(ino, p);
decode(ancestors, p);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 1,723 | 26.806452 | 80 | h |
null | ceph-main/src/messages/MMDSOpenInoReply.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2011 New Dream Network
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MDSOPENINOREPLY_H
#define CEPH_MDSOPENINOREPLY_H
#include "messages/MMDSOp.h"
class MMDSOpenInoReply final : public MMDSOp {
public:
static constexpr int HEAD_VERSION = 1;
static constexpr int COMPAT_VERSION = 1;
inodeno_t ino;
std::vector<inode_backpointer_t> ancestors;
mds_rank_t hint;
int32_t error;
protected:
MMDSOpenInoReply() : MMDSOp{MSG_MDS_OPENINOREPLY, HEAD_VERSION, COMPAT_VERSION}, error(0) {}
MMDSOpenInoReply(ceph_tid_t t, inodeno_t i, mds_rank_t h=MDS_RANK_NONE, int e=0) :
MMDSOp{MSG_MDS_OPENINOREPLY, HEAD_VERSION, COMPAT_VERSION}, ino(i), hint(h), error(e) {
header.tid = t;
}
public:
std::string_view get_type_name() const override { return "openinoreply"; }
void print(std::ostream &out) const override {
out << "openinoreply(" << header.tid << " "
<< ino << " " << hint << " " << ancestors << ")";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(ino, payload);
encode(ancestors, payload);
encode(hint, payload);
encode(error, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(ino, p);
decode(ancestors, p);
decode(hint, p);
decode(error, p);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 1,886 | 27.164179 | 94 | h |
null | ceph-main/src/messages/MMDSPeerRequest.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MMDSPEERREQUEST_H
#define CEPH_MMDSPEERREQUEST_H
#include "mds/mdstypes.h"
#include "messages/MMDSOp.h"
class MMDSPeerRequest final : public MMDSOp {
static constexpr int HEAD_VERSION = 1;
static constexpr int COMPAT_VERSION = 1;
public:
static constexpr int OP_XLOCK = 1;
static constexpr int OP_XLOCKACK = -1;
static constexpr int OP_UNXLOCK = 2;
static constexpr int OP_AUTHPIN = 3;
static constexpr int OP_AUTHPINACK = -3;
static constexpr int OP_LINKPREP = 4;
static constexpr int OP_UNLINKPREP = 5;
static constexpr int OP_LINKPREPACK = -4;
static constexpr int OP_RENAMEPREP = 7;
static constexpr int OP_RENAMEPREPACK = -7;
static constexpr int OP_WRLOCK = 8;
static constexpr int OP_WRLOCKACK = -8;
static constexpr int OP_UNWRLOCK = 9;
static constexpr int OP_RMDIRPREP = 10;
static constexpr int OP_RMDIRPREPACK = -10;
static constexpr int OP_DROPLOCKS = 11;
static constexpr int OP_RENAMENOTIFY = 12;
static constexpr int OP_RENAMENOTIFYACK = -12;
static constexpr int OP_FINISH = 17;
static constexpr int OP_COMMITTED = -18;
static constexpr int OP_ABORT = 20; // used for recovery only
//static constexpr int OP_COMMIT = 21; // used for recovery only
static const char *get_opname(int o) {
switch (o) {
case OP_XLOCK: return "xlock";
case OP_XLOCKACK: return "xlock_ack";
case OP_UNXLOCK: return "unxlock";
case OP_AUTHPIN: return "authpin";
case OP_AUTHPINACK: return "authpin_ack";
case OP_LINKPREP: return "link_prep";
case OP_LINKPREPACK: return "link_prep_ack";
case OP_UNLINKPREP: return "unlink_prep";
case OP_RENAMEPREP: return "rename_prep";
case OP_RENAMEPREPACK: return "rename_prep_ack";
case OP_FINISH: return "finish"; // commit
case OP_COMMITTED: return "committed";
case OP_WRLOCK: return "wrlock";
case OP_WRLOCKACK: return "wrlock_ack";
case OP_UNWRLOCK: return "unwrlock";
case OP_RMDIRPREP: return "rmdir_prep";
case OP_RMDIRPREPACK: return "rmdir_prep_ack";
case OP_DROPLOCKS: return "drop_locks";
case OP_RENAMENOTIFY: return "rename_notify";
case OP_RENAMENOTIFYACK: return "rename_notify_ack";
case OP_ABORT: return "abort";
//case OP_COMMIT: return "commit";
default: ceph_abort(); return 0;
}
}
private:
metareqid_t reqid;
__u32 attempt;
__s16 op;
mutable __u16 flags; /* XXX HACK for mark_interrupted */
static constexpr unsigned FLAG_NONBLOCKING = 1<<0;
static constexpr unsigned FLAG_WOULDBLOCK = 1<<1;
static constexpr unsigned FLAG_NOTJOURNALED = 1<<2;
static constexpr unsigned FLAG_EROFS = 1<<3;
static constexpr unsigned FLAG_ABORT = 1<<4;
static constexpr unsigned FLAG_INTERRUPTED = 1<<5;
static constexpr unsigned FLAG_NOTIFYBLOCKING = 1<<6;
static constexpr unsigned FLAG_REQBLOCKED = 1<<7;
// for locking
__u16 lock_type; // lock object type
MDSCacheObjectInfo object_info;
// for authpins
std::vector<MDSCacheObjectInfo> authpins;
public:
// for rename prep
filepath srcdnpath;
filepath destdnpath;
std::string alternate_name;
std::set<mds_rank_t> witnesses;
ceph::buffer::list inode_export;
version_t inode_export_v;
mds_rank_t srcdn_auth;
utime_t op_stamp;
mutable ceph::buffer::list straybl; // stray dir + dentry
ceph::buffer::list srci_snapbl;
ceph::buffer::list desti_snapbl;
public:
metareqid_t get_reqid() const { return reqid; }
__u32 get_attempt() const { return attempt; }
int get_op() const { return op; }
bool is_reply() const { return op < 0; }
int get_lock_type() const { return lock_type; }
const MDSCacheObjectInfo &get_object_info() const { return object_info; }
MDSCacheObjectInfo &get_object_info() { return object_info; }
const MDSCacheObjectInfo &get_authpin_freeze() const { return object_info; }
MDSCacheObjectInfo &get_authpin_freeze() { return object_info; }
const std::vector<MDSCacheObjectInfo>& get_authpins() const { return authpins; }
std::vector<MDSCacheObjectInfo>& get_authpins() { return authpins; }
void mark_nonblocking() { flags |= FLAG_NONBLOCKING; }
bool is_nonblocking() const { return (flags & FLAG_NONBLOCKING); }
void mark_error_wouldblock() { flags |= FLAG_WOULDBLOCK; }
bool is_error_wouldblock() const { return (flags & FLAG_WOULDBLOCK); }
void mark_not_journaled() { flags |= FLAG_NOTJOURNALED; }
bool is_not_journaled() const { return (flags & FLAG_NOTJOURNALED); }
void mark_error_rofs() { flags |= FLAG_EROFS; }
bool is_error_rofs() const { return (flags & FLAG_EROFS); }
bool is_abort() const { return (flags & FLAG_ABORT); }
void mark_abort() { flags |= FLAG_ABORT; }
bool is_interrupted() const { return (flags & FLAG_INTERRUPTED); }
void mark_interrupted() const { flags |= FLAG_INTERRUPTED; }
bool should_notify_blocking() const { return (flags & FLAG_NOTIFYBLOCKING); }
void mark_notify_blocking() { flags |= FLAG_NOTIFYBLOCKING; }
void clear_notify_blocking() const { flags &= ~FLAG_NOTIFYBLOCKING; }
bool is_req_blocked() const { return (flags & FLAG_REQBLOCKED); }
void mark_req_blocked() { flags |= FLAG_REQBLOCKED; }
void set_lock_type(int t) { lock_type = t; }
const ceph::buffer::list& get_lock_data() const { return inode_export; }
ceph::buffer::list& get_lock_data() { return inode_export; }
protected:
MMDSPeerRequest() : MMDSOp{MSG_MDS_PEER_REQUEST, HEAD_VERSION, COMPAT_VERSION} { }
MMDSPeerRequest(metareqid_t ri, __u32 att, int o) :
MMDSOp{MSG_MDS_PEER_REQUEST, HEAD_VERSION, COMPAT_VERSION},
reqid(ri), attempt(att), op(o), flags(0), lock_type(0),
inode_export_v(0), srcdn_auth(MDS_RANK_NONE) { }
~MMDSPeerRequest() final {}
public:
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(reqid, payload);
encode(attempt, payload);
encode(op, payload);
encode(flags, payload);
encode(lock_type, payload);
encode(object_info, payload);
encode(authpins, payload);
encode(srcdnpath, payload);
encode(destdnpath, payload);
encode(witnesses, payload);
encode(op_stamp, payload);
encode(inode_export, payload);
encode(inode_export_v, payload);
encode(srcdn_auth, payload);
encode(straybl, payload);
encode(srci_snapbl, payload);
encode(desti_snapbl, payload);
encode(alternate_name, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(reqid, p);
decode(attempt, p);
decode(op, p);
decode(flags, p);
decode(lock_type, p);
decode(object_info, p);
decode(authpins, p);
decode(srcdnpath, p);
decode(destdnpath, p);
decode(witnesses, p);
decode(op_stamp, p);
decode(inode_export, p);
decode(inode_export_v, p);
decode(srcdn_auth, p);
decode(straybl, p);
decode(srci_snapbl, p);
decode(desti_snapbl, p);
decode(alternate_name, p);
}
std::string_view get_type_name() const override { return "peer_request"; }
void print(std::ostream& out) const override {
out << "peer_request(" << reqid
<< "." << attempt
<< " " << get_opname(op)
<< ")";
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 7,821 | 32.144068 | 84 | h |
null | ceph-main/src/messages/MMDSPing.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
#ifndef CEPH_MESSAGES_MMDSPING_H
#define CEPH_MESSAGES_MMDSPING_H
#include "include/types.h"
#include "messages/MMDSOp.h"
class MMDSPing final : public MMDSOp {
private:
static constexpr int HEAD_VERSION = 1;
static constexpr int COMPAT_VERSION = 1;
public:
version_t seq;
protected:
MMDSPing() : MMDSOp(MSG_MDS_PING, HEAD_VERSION, COMPAT_VERSION) {
}
MMDSPing(version_t seq)
: MMDSOp(MSG_MDS_PING, HEAD_VERSION, COMPAT_VERSION), seq(seq) {
}
~MMDSPing() final {}
public:
std::string_view get_type_name() const override {
return "mdsping";
}
void print(std::ostream &out) const override {
out << "mdsping";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(seq, payload);
}
void decode_payload() override {
using ceph::decode;
auto iter = payload.cbegin();
decode(seq, iter);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif // CEPH_MESSAGES_MMDSPING_H
| 1,228 | 22.188679 | 70 | h |
null | ceph-main/src/messages/MMDSResolve.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MMDSRESOLVE_H
#define CEPH_MMDSRESOLVE_H
#include "include/types.h"
#include "mds/Capability.h"
#include "messages/MMDSOp.h"
class MMDSResolve final : public MMDSOp {
static constexpr int HEAD_VERSION = 1;
static constexpr int COMPAT_VERSION = 1;
public:
std::map<dirfrag_t, std::vector<dirfrag_t>> subtrees;
std::map<dirfrag_t, std::vector<dirfrag_t>> ambiguous_imports;
class peer_inode_cap {
public:
inodeno_t ino;
std::map<client_t,Capability::Export> cap_exports;
peer_inode_cap() {}
peer_inode_cap(inodeno_t a, std::map<client_t, Capability::Export> b) : ino(a), cap_exports(b) {}
void encode(ceph::buffer::list &bl) const
{
ENCODE_START(1, 1, bl);
encode(ino, bl);
encode(cap_exports, bl);
ENCODE_FINISH(bl);
}
void decode(ceph::buffer::list::const_iterator &blp)
{
DECODE_START(1, blp);
decode(ino, blp);
decode(cap_exports, blp);
DECODE_FINISH(blp);
}
};
WRITE_CLASS_ENCODER(peer_inode_cap)
struct peer_request {
ceph::buffer::list inode_caps;
bool committing;
peer_request() : committing(false) {}
void encode(ceph::buffer::list &bl) const {
ENCODE_START(1, 1, bl);
encode(inode_caps, bl);
encode(committing, bl);
ENCODE_FINISH(bl);
}
void decode(ceph::buffer::list::const_iterator &blp) {
DECODE_START(1, blp);
decode(inode_caps, blp);
decode(committing, blp);
DECODE_FINISH(blp);
}
};
std::map<metareqid_t, peer_request> peer_requests;
// table client information
struct table_client {
__u8 type;
std::set<version_t> pending_commits;
table_client() : type(0) {}
table_client(int _type, const std::set<version_t>& commits)
: type(_type), pending_commits(commits) {}
void encode(ceph::buffer::list& bl) const {
using ceph::encode;
encode(type, bl);
encode(pending_commits, bl);
}
void decode(ceph::buffer::list::const_iterator& bl) {
using ceph::decode;
decode(type, bl);
decode(pending_commits, bl);
}
};
std::list<table_client> table_clients;
protected:
MMDSResolve() : MMDSOp{MSG_MDS_RESOLVE, HEAD_VERSION, COMPAT_VERSION}
{}
~MMDSResolve() final {}
public:
std::string_view get_type_name() const override { return "mds_resolve"; }
void print(std::ostream& out) const override {
out << "mds_resolve(" << subtrees.size()
<< "+" << ambiguous_imports.size()
<< " subtrees +" << peer_requests.size() << " peer requests)";
}
void add_subtree(dirfrag_t im) {
subtrees[im].clear();
}
void add_subtree_bound(dirfrag_t im, dirfrag_t ex) {
subtrees[im].push_back(ex);
}
void add_ambiguous_import(dirfrag_t im, const std::vector<dirfrag_t>& m) {
ambiguous_imports[im] = m;
}
void add_peer_request(metareqid_t reqid, bool committing) {
peer_requests[reqid].committing = committing;
}
void add_peer_request(metareqid_t reqid, ceph::buffer::list& bl) {
peer_requests[reqid].inode_caps = std::move(bl);
}
void add_table_commits(int table, const std::set<version_t>& pending_commits) {
table_clients.push_back(table_client(table, pending_commits));
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(subtrees, payload);
encode(ambiguous_imports, payload);
encode(peer_requests, payload);
encode(table_clients, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(subtrees, p);
decode(ambiguous_imports, p);
decode(peer_requests, p);
decode(table_clients, p);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
inline std::ostream& operator<<(std::ostream& out, const MMDSResolve::peer_request&) {
return out;
}
WRITE_CLASS_ENCODER(MMDSResolve::peer_request)
WRITE_CLASS_ENCODER(MMDSResolve::table_client)
WRITE_CLASS_ENCODER(MMDSResolve::peer_inode_cap)
#endif
| 4,552 | 26.932515 | 101 | h |
null | ceph-main/src/messages/MMDSResolveAck.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MMDSRESOLVEACK_H
#define CEPH_MMDSRESOLVEACK_H
#include "include/types.h"
#include "messages/MMDSOp.h"
class MMDSResolveAck final : public MMDSOp {
static constexpr int HEAD_VERSION = 1;
static constexpr int COMPAT_VERSION = 1;
public:
std::map<metareqid_t, ceph::buffer::list> commit;
std::vector<metareqid_t> abort;
protected:
MMDSResolveAck() : MMDSOp{MSG_MDS_RESOLVEACK, HEAD_VERSION, COMPAT_VERSION} {}
~MMDSResolveAck() final {}
public:
std::string_view get_type_name() const override { return "resolve_ack"; }
/*void print(ostream& out) const {
out << "resolve_ack.size()
<< "+" << ambiguous_imap.size()
<< " imports +" << peer_requests.size() << " peer requests)";
}
*/
void add_commit(metareqid_t r) {
commit[r].clear();
}
void add_abort(metareqid_t r) {
abort.push_back(r);
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(commit, payload);
encode(abort, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(commit, p);
decode(abort, p);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 1,777 | 25.147059 | 80 | h |
null | ceph-main/src/messages/MMDSScrub.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MMDSSCRUB_H
#define CEPH_MMDSSCRUB_H
#include "messages/MMDSOp.h"
#include "include/types.h"
#include "include/frag.h"
class MMDSScrub : public MMDSOp {
public:
static constexpr int OP_QUEUEDIR = 1;
static constexpr int OP_QUEUEDIR_ACK = -1;
static constexpr int OP_QUEUEINO = 2;
static constexpr int OP_QUEUEINO_ACK = -2;
static constexpr int OP_ABORT = 3;
static constexpr int OP_PAUSE = 4;
static constexpr int OP_RESUME = 5;
static const char *get_opname(int o) {
switch (o) {
case OP_QUEUEDIR: return "queue_dir";
case OP_QUEUEDIR_ACK: return "queue_dir_ack";
case OP_QUEUEINO: return "queue_ino";
case OP_QUEUEINO_ACK: return "queue_ino_ack";
case OP_ABORT: return "abort";
case OP_PAUSE: return "pause";
case OP_RESUME: return "resume";
default: ceph_abort(); return nullptr;
}
}
std::string_view get_type_name() const override { return "mds_scrub"; }
void print(std::ostream& out) const override {
out << "mds_scrub(" << get_opname(op) << " "
<< ino << " " << frags << " " << tag;
if (is_force()) out << " force";
if (is_recursive()) out << " recursive";
if (is_repair()) out << " repair";
out << ")";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(op, payload);
encode(ino, payload);
encode(frags, payload);
encode(tag, payload);
encode(origin, payload);
encode(flags, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(op, p);
decode(ino, p);
decode(frags, p);
decode(tag, p);
decode(origin, p);
decode(flags, p);
}
inodeno_t get_ino() const {
return ino;
}
const fragset_t& get_frags() const {
return frags;
}
const std::string& get_tag() const {
return tag;
}
inodeno_t get_origin() const {
return origin;
}
int get_op() const {
return op;
}
bool is_internal_tag() const {
return flags & FLAG_INTERNAL_TAG;
}
bool is_force() const {
return flags & FLAG_FORCE;
}
bool is_recursive() const {
return flags & FLAG_RECURSIVE;
}
bool is_repair() const {
return flags & FLAG_REPAIR;
}
protected:
static constexpr int HEAD_VERSION = 1;
static constexpr int COMPAT_VERSION = 1;
MMDSScrub() : MMDSOp(MSG_MDS_SCRUB, HEAD_VERSION, COMPAT_VERSION) {}
MMDSScrub(int o)
: MMDSOp(MSG_MDS_SCRUB, HEAD_VERSION, COMPAT_VERSION), op(o) {}
MMDSScrub(int o, inodeno_t i, fragset_t&& _frags, std::string_view _tag,
inodeno_t _origin=inodeno_t(), bool internal_tag=false,
bool force=false, bool recursive=false, bool repair=false)
: MMDSOp(MSG_MDS_SCRUB, HEAD_VERSION, COMPAT_VERSION),
op(o), ino(i), frags(std::move(_frags)), tag(_tag), origin(_origin) {
if (internal_tag) flags |= FLAG_INTERNAL_TAG;
if (force) flags |= FLAG_FORCE;
if (recursive) flags |= FLAG_RECURSIVE;
if (repair) flags |= FLAG_REPAIR;
}
~MMDSScrub() override {}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
static constexpr unsigned FLAG_INTERNAL_TAG = 1<<0;
static constexpr unsigned FLAG_FORCE = 1<<1;
static constexpr unsigned FLAG_RECURSIVE = 1<<2;
static constexpr unsigned FLAG_REPAIR = 1<<3;
int op;
inodeno_t ino;
fragset_t frags;
std::string tag;
inodeno_t origin;
unsigned flags = 0;
};
#endif // CEPH_MMDSSCRUB_H
| 3,983 | 27.255319 | 74 | h |
null | ceph-main/src/messages/MMDSScrubStats.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MMDSSCRUBSTATS_H
#define CEPH_MMDSSCRUBSTATS_H
#include "messages/MMDSOp.h"
class MMDSScrubStats : public MMDSOp {
static constexpr int HEAD_VERSION = 1;
static constexpr int COMPAT_VERSION = 1;
public:
std::string_view get_type_name() const override { return "mds_scrub_stats"; }
void print(std::ostream& o) const override {
o << "mds_scrub_stats(e" << epoch;
if (update_scrubbing)
o << " [" << scrubbing_tags << "]";
if (aborting)
o << " aborting";
o << ")";
}
unsigned get_epoch() const { return epoch; }
const auto& get_scrubbing_tags() const { return scrubbing_tags; }
bool is_aborting() const { return aborting; }
bool is_finished(const std::string& tag) const {
return update_scrubbing && !scrubbing_tags.count(tag);
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(epoch, payload);
encode(scrubbing_tags, payload);
encode(update_scrubbing, payload);
encode(aborting, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(epoch, p);
decode(scrubbing_tags, p);
decode(update_scrubbing, p);
decode(aborting, p);
}
protected:
MMDSScrubStats(unsigned e=0) :
MMDSOp(MSG_MDS_SCRUB_STATS, HEAD_VERSION, COMPAT_VERSION),
epoch(e) {}
MMDSScrubStats(unsigned e, std::set<std::string>&& tags, bool abrt=false) :
MMDSOp(MSG_MDS_SCRUB_STATS, HEAD_VERSION, COMPAT_VERSION),
epoch(e), scrubbing_tags(std::move(tags)), update_scrubbing(true), aborting(abrt) {}
MMDSScrubStats(unsigned e, const std::set<std::string>& tags, bool abrt=false) :
MMDSOp(MSG_MDS_SCRUB_STATS, HEAD_VERSION, COMPAT_VERSION),
epoch(e), scrubbing_tags(tags), update_scrubbing(true), aborting(abrt) {}
~MMDSScrubStats() override {}
private:
unsigned epoch;
std::set<std::string> scrubbing_tags;
bool update_scrubbing = false;
bool aborting = false;
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 2,592 | 30.240964 | 88 | h |
null | ceph-main/src/messages/MMDSSnapUpdate.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MMDSSNAPUPDATE_H
#define CEPH_MMDSSNAPUPDATE_H
#include "messages/MMDSOp.h"
class MMDSSnapUpdate final : public MMDSOp {
private:
inodeno_t ino;
__s16 snap_op;
public:
inodeno_t get_ino() const { return ino; }
int get_snap_op() const { return snap_op; }
ceph::buffer::list snap_blob;
protected:
MMDSSnapUpdate() : MMDSOp{MSG_MDS_SNAPUPDATE} {}
MMDSSnapUpdate(inodeno_t i, version_t tid, int op) :
MMDSOp{MSG_MDS_SNAPUPDATE}, ino(i), snap_op(op) {
set_tid(tid);
}
~MMDSSnapUpdate() final {}
public:
std::string_view get_type_name() const override { return "snap_update"; }
void print(std::ostream& o) const override {
o << "snap_update(" << ino << " table_tid " << get_tid() << ")";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(ino, payload);
encode(snap_op, payload);
encode(snap_blob, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(ino, p);
decode(snap_op, p);
decode(snap_blob, p);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 1,724 | 25.136364 | 75 | h |
null | ceph-main/src/messages/MMDSTableRequest.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MMDSTABLEREQUEST_H
#define CEPH_MMDSTABLEREQUEST_H
#include "mds/mds_table_types.h"
#include "messages/MMDSOp.h"
class MMDSTableRequest final : public MMDSOp {
public:
__u16 table = 0;
__s16 op = 0;
uint64_t reqid = 0;
ceph::buffer::list bl;
protected:
MMDSTableRequest() : MMDSOp{MSG_MDS_TABLE_REQUEST} {}
MMDSTableRequest(int tab, int o, uint64_t r, version_t v=0) :
MMDSOp{MSG_MDS_TABLE_REQUEST},
table(tab), op(o), reqid(r) {
set_tid(v);
}
~MMDSTableRequest() final {}
public:
std::string_view get_type_name() const override { return "mds_table_request"; }
void print(std::ostream& o) const override {
o << "mds_table_request(" << get_mdstable_name(table)
<< " " << get_mdstableserver_opname(op);
if (reqid) o << " " << reqid;
if (get_tid()) o << " tid " << get_tid();
if (bl.length()) o << " " << bl.length() << " bytes";
o << ")";
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(table, p);
decode(op, p);
decode(reqid, p);
decode(bl, p);
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(table, payload);
encode(op, payload);
encode(reqid, payload);
encode(bl, payload);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 1,933 | 25.493151 | 81 | h |
null | ceph-main/src/messages/MMgrBeacon.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MMGRBEACON_H
#define CEPH_MMGRBEACON_H
#include "messages/PaxosServiceMessage.h"
#include "mon/MonCommand.h"
#include "mon/MgrMap.h"
#include "include/types.h"
class MMgrBeacon final : public PaxosServiceMessage {
private:
static constexpr int HEAD_VERSION = 11;
static constexpr int COMPAT_VERSION = 8;
protected:
uint64_t gid;
entity_addrvec_t server_addrs;
bool available;
std::string name;
uuid_d fsid;
// From active daemon to populate MgrMap::services
std::map<std::string, std::string> services;
// Only populated during activation
std::vector<MonCommand> command_descs;
// Information about the modules found locally on this daemon
std::vector<MgrMap::ModuleInfo> modules;
std::map<std::string,std::string> metadata; ///< misc metadata about this osd
std::multimap<std::string, entity_addrvec_t> clients;
uint64_t mgr_features = 0; ///< reporting mgr's features
public:
MMgrBeacon()
: PaxosServiceMessage{MSG_MGR_BEACON, 0, HEAD_VERSION, COMPAT_VERSION},
gid(0), available(false)
{}
MMgrBeacon(const uuid_d& fsid_, uint64_t gid_, const std::string &name_,
entity_addrvec_t server_addrs_, bool available_,
std::vector<MgrMap::ModuleInfo>&& modules_,
std::map<std::string,std::string>&& metadata_,
std::multimap<std::string, entity_addrvec_t>&& clients_,
uint64_t feat)
: PaxosServiceMessage{MSG_MGR_BEACON, 0, HEAD_VERSION, COMPAT_VERSION},
gid(gid_), server_addrs(server_addrs_), available(available_), name(name_),
fsid(fsid_), modules(std::move(modules_)), metadata(std::move(metadata_)),
clients(std::move(clients_)),
mgr_features(feat)
{
}
uint64_t get_gid() const { return gid; }
entity_addrvec_t get_server_addrs() const { return server_addrs; }
bool get_available() const { return available; }
const std::string& get_name() const { return name; }
const uuid_d& get_fsid() const { return fsid; }
const std::map<std::string,std::string>& get_metadata() const {
return metadata;
}
const std::map<std::string,std::string>& get_services() const {
return services;
}
uint64_t get_mgr_features() const { return mgr_features; }
void set_services(const std::map<std::string, std::string> &svcs)
{
services = svcs;
}
void set_command_descs(const std::vector<MonCommand> &cmds)
{
command_descs = cmds;
}
const std::vector<MonCommand> &get_command_descs()
{
return command_descs;
}
const std::vector<MgrMap::ModuleInfo> &get_available_modules() const
{
return modules;
}
const auto& get_clients() const
{
return clients;
}
private:
~MMgrBeacon() final {}
public:
std::string_view get_type_name() const override { return "mgrbeacon"; }
void print(std::ostream& out) const override {
out << get_type_name() << " mgr." << name << "(" << fsid << ","
<< gid << ", " << server_addrs << ", " << available
<< ")";
}
void encode_payload(uint64_t features) override {
header.version = HEAD_VERSION;
header.compat_version = COMPAT_VERSION;
using ceph::encode;
paxos_encode();
assert(HAVE_FEATURE(features, SERVER_NAUTILUS));
encode(server_addrs, payload, features);
encode(gid, payload);
encode(available, payload);
encode(name, payload);
encode(fsid, payload);
// Fill out old-style list of module names (deprecated by
// later field of full ModuleInfos)
std::set<std::string> module_names;
for (const auto &info : modules) {
module_names.insert(info.name);
}
encode(module_names, payload);
encode(command_descs, payload);
encode(metadata, payload);
encode(services, payload);
encode(modules, payload);
encode(mgr_features, payload);
std::vector<std::string> clients_names;
std::vector<entity_addrvec_t> clients_addrs;
for (const auto& i : clients) {
clients_names.push_back(i.first);
clients_addrs.push_back(i.second);
}
// The address vector needs to be encoded first to produce a
// backwards compatible messsage for older monitors.
encode(clients_addrs, payload, features);
encode(clients_names, payload, features);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
paxos_decode(p);
assert(header.version >= 8);
decode(server_addrs, p); // entity_addr_t for version < 8
decode(gid, p);
decode(available, p);
decode(name, p);
decode(fsid, p);
std::set<std::string> module_name_list;
decode(module_name_list, p);
decode(command_descs, p);
decode(metadata, p);
decode(services, p);
decode(modules, p);
if (header.version >= 9) {
decode(mgr_features, p);
}
if (header.version >= 10) {
std::vector<entity_addrvec_t> clients_addrs;
decode(clients_addrs, p);
clients.clear();
if (header.version >= 11) {
std::vector<std::string> clients_names;
decode(clients_names, p);
if (clients_names.size() != clients_addrs.size()) {
throw ceph::buffer::malformed_input(
"clients_names.size() != clients_addrs.size()");
}
auto cn = clients_names.begin();
auto ca = clients_addrs.begin();
for(; cn != clients_names.end(); ++cn, ++ca) {
clients.emplace(*cn, *ca);
}
} else {
for (const auto& i : clients_addrs) {
clients.emplace("", i);
}
}
}
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
};
#endif
| 5,955 | 27.227488 | 81 | h |
null | ceph-main/src/messages/MMgrClose.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
#pragma once
#include "msg/Message.h"
class MMgrClose : public Message {
private:
static constexpr int HEAD_VERSION = 1;
static constexpr int COMPAT_VERSION = 1;
public:
std::string daemon_name;
std::string service_name; // optional; otherwise infer from entity type
void decode_payload() override
{
using ceph::decode;
auto p = payload.cbegin();
decode(daemon_name, p);
decode(service_name, p);
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(daemon_name, payload);
encode(service_name, payload);
}
std::string_view get_type_name() const override { return "mgrclose"; }
void print(std::ostream& out) const override {
out << get_type_name() << "(";
if (service_name.length()) {
out << service_name;
} else {
out << ceph_entity_type_name(get_source().type());
}
out << "." << daemon_name;
out << ")";
}
MMgrClose()
: Message{MSG_MGR_CLOSE, HEAD_VERSION, COMPAT_VERSION}
{}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
};
| 1,227 | 22.615385 | 74 | h |
null | ceph-main/src/messages/MMgrCommand.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
#pragma once
#include <vector>
#include "msg/Message.h"
class MMgrCommand final : public Message {
public:
uuid_d fsid;
std::vector<std::string> cmd;
MMgrCommand()
: Message{MSG_MGR_COMMAND} {}
MMgrCommand(const uuid_d &f)
: Message{MSG_MGR_COMMAND},
fsid(f) { }
private:
~MMgrCommand() final {}
public:
std::string_view get_type_name() const override { return "mgr_command"; }
void print(std::ostream& o) const override {
o << "mgr_command(tid " << get_tid() << ": ";
for (unsigned i=0; i<cmd.size(); i++) {
if (i) o << ' ';
o << cmd[i];
}
o << ")";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(fsid, payload);
encode(cmd, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(fsid, p);
decode(cmd, p);
}
};
| 988 | 20.042553 | 75 | h |
null | ceph-main/src/messages/MMgrCommandReply.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
#pragma once
#include <string_view>
#include "msg/Message.h"
#include "MMgrCommand.h"
class MMgrCommandReply final : public Message {
public:
errorcode32_t r;
std::string rs;
MMgrCommandReply()
: Message{MSG_MGR_COMMAND_REPLY} {}
MMgrCommandReply(MMgrCommand *m, int _r)
: Message{MSG_MGR_COMMAND_REPLY}, r(_r) {
header.tid = m->get_tid();
}
MMgrCommandReply(int _r, std::string_view s)
: Message{MSG_MGR_COMMAND_REPLY},
r(_r), rs(s) { }
private:
~MMgrCommandReply() final {}
public:
std::string_view get_type_name() const override { return "mgr_command_reply"; }
void print(std::ostream& o) const override {
o << "mgr_command_reply(tid " << get_tid() << ": " << r << " " << rs << ")";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(r, payload);
encode(rs, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(r, p);
decode(rs, p);
}
};
| 1,102 | 22.978261 | 81 | h |
null | ceph-main/src/messages/MMgrConfigure.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2016 John Spray <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*/
#ifndef CEPH_MMGRCONFIGURE_H_
#define CEPH_MMGRCONFIGURE_H_
#include "msg/Message.h"
#include "mgr/MetricTypes.h"
#include "mgr/OSDPerfMetricTypes.h"
/**
* This message is sent from ceph-mgr to MgrClient, instructing it
* it about what data to send back to ceph-mgr at what frequency.
*/
class MMgrConfigure : public Message {
private:
static constexpr int HEAD_VERSION = 4;
static constexpr int COMPAT_VERSION = 1;
public:
uint32_t stats_period = 0;
// Default 0 means if unspecified will include all stats
uint32_t stats_threshold = 0;
std::map<OSDPerfMetricQuery, OSDPerfMetricLimits> osd_perf_metric_queries;
boost::optional<MetricConfigMessage> metric_config_message;
void decode_payload() override
{
using ceph::decode;
auto p = payload.cbegin();
decode(stats_period, p);
if (header.version >= 2) {
decode(stats_threshold, p);
}
if (header.version >= 3) {
decode(osd_perf_metric_queries, p);
}
if (header.version >= 4) {
decode(metric_config_message, p);
}
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(stats_period, payload);
encode(stats_threshold, payload);
encode(osd_perf_metric_queries, payload);
if (metric_config_message && metric_config_message->should_encode(features)) {
encode(metric_config_message, payload);
} else {
boost::optional<MetricConfigMessage> empty;
encode(empty, payload);
}
}
std::string_view get_type_name() const override { return "mgrconfigure"; }
void print(std::ostream& out) const override {
out << get_type_name() << "(period=" << stats_period
<< ", threshold=" << stats_threshold << ")";
}
private:
MMgrConfigure()
: Message{MSG_MGR_CONFIGURE, HEAD_VERSION, COMPAT_VERSION}
{}
using RefCountedObject::put;
using RefCountedObject::get;
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 2,512 | 26.922222 | 82 | h |
null | ceph-main/src/messages/MMgrDigest.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MMGRDIGEST_H
#define CEPH_MMGRDIGEST_H
#include "msg/Message.h"
/**
* The mgr digest is a way for the mgr to subscribe to things
* other than the cluster maps, which are needed by
*/
class MMgrDigest final : public Message {
public:
ceph::buffer::list mon_status_json;
ceph::buffer::list health_json;
std::string_view get_type_name() const override { return "mgrdigest"; }
void print(std::ostream& out) const override {
out << get_type_name();
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(mon_status_json, p);
decode(health_json, p);
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(mon_status_json, payload);
encode(health_json, payload);
}
private:
MMgrDigest() :
Message{MSG_MGR_DIGEST} {}
~MMgrDigest() final {}
using RefCountedObject::put;
using RefCountedObject::get;
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 1,576 | 24.852459 | 73 | h |
null | ceph-main/src/messages/MMgrMap.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MMGRMAP_H
#define CEPH_MMGRMAP_H
#include "msg/Message.h"
#include "mon/MgrMap.h"
class MMgrMap final : public Message {
protected:
MgrMap map;
public:
const MgrMap & get_map() {return map;}
private:
MMgrMap() :
Message{MSG_MGR_MAP} {}
MMgrMap(const MgrMap &map_) :
Message{MSG_MGR_MAP}, map(map_)
{}
~MMgrMap() final {}
public:
std::string_view get_type_name() const override { return "mgrmap"; }
void print(std::ostream& out) const override {
out << get_type_name() << "(e " << map.epoch << ")";
}
void decode_payload() override {
auto p = payload.cbegin();
decode(map, p);
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(map, payload, features);
}
private:
using RefCountedObject::put;
using RefCountedObject::get;
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 1,470 | 23.114754 | 71 | h |
null | ceph-main/src/messages/MMgrOpen.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2016 John Spray <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*/
#ifndef CEPH_MMGROPEN_H_
#define CEPH_MMGROPEN_H_
#include "msg/Message.h"
class MMgrOpen : public Message {
private:
static constexpr int HEAD_VERSION = 3;
static constexpr int COMPAT_VERSION = 1;
public:
std::string daemon_name;
std::string service_name; // optional; otherwise infer from entity type
bool service_daemon = false;
std::map<std::string,std::string> daemon_metadata;
std::map<std::string,std::string> daemon_status;
// encode map<string,map<int32_t,string>> of current config
ceph::buffer::list config_bl;
// encode map<string,string> of compiled-in defaults
ceph::buffer::list config_defaults_bl;
void decode_payload() override
{
using ceph::decode;
auto p = payload.cbegin();
decode(daemon_name, p);
if (header.version >= 2) {
decode(service_name, p);
decode(service_daemon, p);
if (service_daemon) {
decode(daemon_metadata, p);
decode(daemon_status, p);
}
}
if (header.version >= 3) {
decode(config_bl, p);
decode(config_defaults_bl, p);
}
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(daemon_name, payload);
encode(service_name, payload);
encode(service_daemon, payload);
if (service_daemon) {
encode(daemon_metadata, payload);
encode(daemon_status, payload);
}
encode(config_bl, payload);
encode(config_defaults_bl, payload);
}
std::string_view get_type_name() const override { return "mgropen"; }
void print(std::ostream& out) const override {
out << get_type_name() << "(";
if (service_name.length()) {
out << service_name;
} else {
out << ceph_entity_type_name(get_source().type());
}
out << "." << daemon_name;
if (service_daemon) {
out << " daemon";
}
out << ")";
}
private:
MMgrOpen()
: Message{MSG_MGR_OPEN, HEAD_VERSION, COMPAT_VERSION}
{}
using RefCountedObject::put;
using RefCountedObject::get;
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 2,620 | 24.950495 | 74 | h |
null | ceph-main/src/messages/MMgrReport.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2016 John Spray <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*/
#ifndef CEPH_MMGRREPORT_H_
#define CEPH_MMGRREPORT_H_
#include <boost/optional.hpp>
#include "msg/Message.h"
#include "mgr/MetricTypes.h"
#include "mgr/OSDPerfMetricTypes.h"
#include "common/perf_counters.h"
#include "include/common_fwd.h"
#include "mgr/DaemonHealthMetric.h"
class PerfCounterType
{
public:
std::string path;
std::string description;
std::string nick;
enum perfcounter_type_d type;
// For older clients that did not send priority, pretend everything
// is "useful" so that mgr plugins filtering on prio will get some
// data (albeit probably more than they wanted)
uint8_t priority = PerfCountersBuilder::PRIO_USEFUL;
enum unit_t unit;
void encode(ceph::buffer::list &bl) const
{
// TODO: decide whether to drop the per-type
// encoding here, we could rely on the MgrReport
// verisoning instead.
ENCODE_START(3, 1, bl);
encode(path, bl);
encode(description, bl);
encode(nick, bl);
static_assert(sizeof(type) == 1, "perfcounter_type_d must be one byte");
encode((uint8_t)type, bl);
encode(priority, bl);
encode((uint8_t)unit, bl);
ENCODE_FINISH(bl);
}
void decode(ceph::buffer::list::const_iterator &p)
{
DECODE_START(3, p);
decode(path, p);
decode(description, p);
decode(nick, p);
uint8_t raw_type;
decode(raw_type, p);
type = (enum perfcounter_type_d)raw_type;
if (struct_v >= 2) {
decode(priority, p);
}
if (struct_v >= 3) {
uint8_t raw_unit;
decode(raw_unit, p);
unit = (enum unit_t)raw_unit;
}
DECODE_FINISH(p);
}
};
WRITE_CLASS_ENCODER(PerfCounterType)
class MMgrReport : public Message {
private:
static constexpr int HEAD_VERSION = 9;
static constexpr int COMPAT_VERSION = 1;
public:
/**
* Client is responsible for remembering whether it has introduced
* each perf counter to the server. When first sending a particular
* counter, it must inline the counter's schema here.
*/
std::vector<PerfCounterType> declare_types;
std::vector<std::string> undeclare_types;
// For all counters present, sorted by idx, output
// as many bytes as are needed to represent them
// Decode: iterate over the types we know about, sorted by idx,
// and use the current type's type to decide how to decode
// the next bytes from the ceph::buffer::list.
ceph::buffer::list packed;
std::string daemon_name;
std::string service_name; // optional; otherwise infer from entity type
// for service registration
boost::optional<std::map<std::string,std::string>> daemon_status;
boost::optional<std::map<std::string,std::string>> task_status;
std::vector<DaemonHealthMetric> daemon_health_metrics;
// encode map<string,map<int32_t,string>> of current config
ceph::buffer::list config_bl;
std::map<OSDPerfMetricQuery, OSDPerfMetricReport> osd_perf_metric_reports;
boost::optional<MetricReportMessage> metric_report_message;
void decode_payload() override
{
using ceph::decode;
auto p = payload.cbegin();
decode(daemon_name, p);
decode(declare_types, p);
decode(packed, p);
if (header.version >= 2)
decode(undeclare_types, p);
if (header.version >= 3) {
decode(service_name, p);
decode(daemon_status, p);
}
if (header.version >= 5) {
decode(daemon_health_metrics, p);
}
if (header.version >= 6) {
decode(config_bl, p);
}
if (header.version >= 7) {
decode(osd_perf_metric_reports, p);
}
if (header.version >= 8) {
decode(task_status, p);
}
if (header.version >= 9) {
decode(metric_report_message, p);
}
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(daemon_name, payload);
encode(declare_types, payload);
encode(packed, payload);
encode(undeclare_types, payload);
encode(service_name, payload);
encode(daemon_status, payload);
encode(daemon_health_metrics, payload);
encode(config_bl, payload);
encode(osd_perf_metric_reports, payload);
encode(task_status, payload);
if (metric_report_message && metric_report_message->should_encode(features)) {
encode(metric_report_message, payload);
} else {
boost::optional<MetricReportMessage> empty;
encode(empty, payload);
}
}
std::string_view get_type_name() const override { return "mgrreport"; }
void print(std::ostream& out) const override {
out << get_type_name() << "(";
if (service_name.length()) {
out << service_name;
} else {
out << ceph_entity_type_name(get_source().type());
}
out << "." << daemon_name
<< " +" << declare_types.size()
<< "-" << undeclare_types.size()
<< " packed " << packed.length();
if (daemon_status) {
out << " status=" << daemon_status->size();
}
if (!daemon_health_metrics.empty()) {
out << " daemon_metrics=" << daemon_health_metrics.size();
}
if (task_status) {
out << " task_status=" << task_status->size();
}
out << ")";
}
private:
MMgrReport()
: Message{MSG_MGR_REPORT, HEAD_VERSION, COMPAT_VERSION}
{}
using RefCountedObject::put;
using RefCountedObject::get;
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
template<class T, typename... Args>
friend MURef<T> crimson::make_message(Args&&... args);
};
#endif
| 5,845 | 27.517073 | 82 | h |
null | ceph-main/src/messages/MMgrUpdate.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2022 Prashant D <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*/
#ifndef CEPH_MMGRUPDATE_H_
#define CEPH_MMGRUPDATE_H_
#include "msg/Message.h"
class MMgrUpdate : public Message {
private:
static constexpr int HEAD_VERSION = 2;
static constexpr int COMPAT_VERSION = 1;
public:
std::string daemon_name;
std::string service_name; // optional; otherwise infer from entity type
std::map<std::string,std::string> daemon_metadata;
std::map<std::string,std::string> daemon_status;
bool need_metadata_update = false;
void decode_payload() override
{
using ceph::decode;
auto p = payload.cbegin();
decode(daemon_name, p);
if (header.version >= 2) {
decode(service_name, p);
decode(need_metadata_update, p);
if (need_metadata_update) {
decode(daemon_metadata, p);
decode(daemon_status, p);
}
}
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(daemon_name, payload);
encode(service_name, payload);
encode(need_metadata_update, payload);
if (need_metadata_update) {
encode(daemon_metadata, payload);
encode(daemon_status, payload);
}
}
std::string_view get_type_name() const override { return "mgrupdate"; }
void print(std::ostream& out) const override {
out << get_type_name() << "(";
if (service_name.length()) {
out << service_name;
} else {
out << ceph_entity_type_name(get_source().type());
}
out << "." << daemon_name;
out << ")";
}
private:
MMgrUpdate()
: Message{MSG_MGR_UPDATE, HEAD_VERSION, COMPAT_VERSION}
{}
using RefCountedObject::put;
using RefCountedObject::get;
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
};
#endif
| 2,142 | 24.211765 | 74 | h |
null | ceph-main/src/messages/MMonCommand.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MMONCOMMAND_H
#define CEPH_MMONCOMMAND_H
#include "messages/PaxosServiceMessage.h"
#include <vector>
#include <string>
using ceph::common::cmdmap_from_json;
using ceph::common::cmd_getval;
class MMonCommand final : public PaxosServiceMessage {
public:
// weird note: prior to octopus, MgrClient would leave fsid blank when
// sending commands to the mgr. Starting with octopus, this is either
// populated with a valid fsid (tell command) or an MMgrCommand is sent
// instead.
uuid_d fsid;
std::vector<std::string> cmd;
MMonCommand() : PaxosServiceMessage{MSG_MON_COMMAND, 0} {}
MMonCommand(const uuid_d &f)
: PaxosServiceMessage{MSG_MON_COMMAND, 0},
fsid(f)
{ }
MMonCommand(const MMonCommand &other)
: PaxosServiceMessage(MSG_MON_COMMAND, 0),
fsid(other.fsid),
cmd(other.cmd) {
set_tid(other.get_tid());
set_data(other.get_data());
}
~MMonCommand() final {}
public:
std::string_view get_type_name() const override { return "mon_command"; }
void print(std::ostream& o) const override {
cmdmap_t cmdmap;
std::ostringstream ss;
std::string prefix;
cmdmap_from_json(cmd, &cmdmap, ss);
cmd_getval(cmdmap, "prefix", prefix);
// Some config values contain sensitive data, so don't log them
o << "mon_command(";
if (prefix == "config set") {
std::string name;
cmd_getval(cmdmap, "name", name);
o << "[{prefix=" << prefix << ", name=" << name << "}]";
} else if (prefix == "config-key set") {
std::string key;
cmd_getval(cmdmap, "key", key);
o << "[{prefix=" << prefix << ", key=" << key << "}]";
} else {
for (unsigned i=0; i<cmd.size(); i++) {
if (i) o << ' ';
o << cmd[i];
}
}
o << " v " << version << ")";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
paxos_encode();
encode(fsid, payload);
encode(cmd, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
paxos_decode(p);
decode(fsid, p);
decode(cmd, p);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
};
#endif
| 2,669 | 26.244898 | 75 | h |
null | ceph-main/src/messages/MMonCommandAck.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MMONCOMMANDACK_H
#define CEPH_MMONCOMMANDACK_H
#include "messages/PaxosServiceMessage.h"
using ceph::common::cmdmap_from_json;
using ceph::common::cmd_getval;
class MMonCommandAck final : public PaxosServiceMessage {
public:
std::vector<std::string> cmd;
errorcode32_t r;
std::string rs;
MMonCommandAck() : PaxosServiceMessage{MSG_MON_COMMAND_ACK, 0} {}
MMonCommandAck(const std::vector<std::string>& c, int _r, std::string s, version_t v) :
PaxosServiceMessage{MSG_MON_COMMAND_ACK, v},
cmd(c), r(_r), rs(s) { }
private:
~MMonCommandAck() final {}
public:
std::string_view get_type_name() const override { return "mon_command"; }
void print(std::ostream& o) const override {
cmdmap_t cmdmap;
std::ostringstream ss;
std::string prefix;
cmdmap_from_json(cmd, &cmdmap, ss);
cmd_getval(cmdmap, "prefix", prefix);
// Some config values contain sensitive data, so don't log them
o << "mon_command_ack(";
if (prefix == "config set") {
std::string name;
cmd_getval(cmdmap, "name", name);
o << "[{prefix=" << prefix
<< ", name=" << name << "}]"
<< "=" << r << " " << rs << " v" << version << ")";
} else if (prefix == "config-key set") {
std::string key;
cmd_getval(cmdmap, "key", key);
o << "[{prefix=" << prefix << ", key=" << key << "}]"
<< "=" << r << " " << rs << " v" << version << ")";
} else {
o << cmd;
}
o << "=" << r << " " << rs << " v" << version << ")";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
paxos_encode();
encode(r, payload);
encode(rs, payload);
encode(cmd, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
paxos_decode(p);
decode(r, p);
decode(rs, p);
decode(cmd, p);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
};
#endif
| 2,425 | 27.880952 | 89 | h |
null | ceph-main/src/messages/MMonElection.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MMONELECTION_H
#define CEPH_MMONELECTION_H
#include "common/ceph_releases.h"
#include "msg/Message.h"
#include "mon/MonMap.h"
#include "mon/mon_types.h"
class MMonElection final : public Message {
private:
static constexpr int HEAD_VERSION = 9;
static constexpr int COMPAT_VERSION = 5;
public:
static constexpr int OP_PROPOSE = 1;
static constexpr int OP_ACK = 2;
static constexpr int OP_NAK = 3;
static constexpr int OP_VICTORY = 4;
static const char *get_opname(int o) {
switch (o) {
case OP_PROPOSE: return "propose";
case OP_ACK: return "ack";
case OP_NAK: return "nak";
case OP_VICTORY: return "victory";
default: ceph_abort(); return 0;
}
}
uuid_d fsid;
int32_t op;
epoch_t epoch;
ceph::buffer::list monmap_bl;
std::set<int32_t> quorum;
uint64_t quorum_features;
mon_feature_t mon_features;
ceph_release_t mon_release{ceph_release_t::unknown};
ceph::buffer::list sharing_bl;
ceph::buffer::list scoring_bl;
uint8_t strategy;
std::map<std::string,std::string> metadata;
MMonElection() : Message{MSG_MON_ELECTION, HEAD_VERSION, COMPAT_VERSION},
op(0), epoch(0),
quorum_features(0),
mon_features(0),
strategy(0)
{ }
MMonElection(int o, epoch_t e, const bufferlist& bl, uint8_t s, MonMap *m)
: Message{MSG_MON_ELECTION, HEAD_VERSION, COMPAT_VERSION},
fsid(m->fsid), op(o), epoch(e),
quorum_features(0),
mon_features(0), scoring_bl(bl), strategy(s)
{
// encode using full feature set; we will reencode for dest later,
// if necessary
m->encode(monmap_bl, CEPH_FEATURES_ALL);
}
private:
~MMonElection() final {}
public:
std::string_view get_type_name() const override { return "election"; }
void print(std::ostream& out) const override {
out << "election(" << fsid << " " << get_opname(op)
<< " rel " << (int)mon_release << " e" << epoch << ")";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
if (monmap_bl.length() && (features != CEPH_FEATURES_ALL)) {
// reencode old-format monmap
MonMap t;
t.decode(monmap_bl);
monmap_bl.clear();
t.encode(monmap_bl, features);
}
encode(fsid, payload);
encode(op, payload);
encode(epoch, payload);
encode(monmap_bl, payload);
encode(quorum, payload);
encode(quorum_features, payload);
encode((version_t)0, payload); // defunct
encode((version_t)0, payload); // defunct
encode(sharing_bl, payload);
encode(mon_features, payload);
encode(metadata, payload);
encode(mon_release, payload);
encode(scoring_bl, payload);
encode(strategy, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(fsid, p);
decode(op, p);
decode(epoch, p);
decode(monmap_bl, p);
decode(quorum, p);
decode(quorum_features, p);
{
version_t v; // defunct fields from old encoding
decode(v, p);
decode(v, p);
}
decode(sharing_bl, p);
if (header.version >= 6)
decode(mon_features, p);
if (header.version >= 7)
decode(metadata, p);
if (header.version >= 8)
decode(mon_release, p);
else
mon_release = infer_ceph_release_from_mon_features(mon_features);
if (header.version >= 9) {
decode(scoring_bl, p);
decode(strategy, p);
} else {
strategy = MonMap::election_strategy::CLASSIC;
}
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
};
#endif
| 4,026 | 26.772414 | 76 | h |
null | ceph-main/src/messages/MMonGetMap.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MMONGETMAP_H
#define CEPH_MMONGETMAP_H
#include "msg/Message.h"
#include "include/types.h"
class MMonGetMap final : public Message {
public:
MMonGetMap() : Message{CEPH_MSG_MON_GET_MAP} { }
private:
~MMonGetMap() final {}
public:
std::string_view get_type_name() const override { return "mon_getmap"; }
void encode_payload(uint64_t features) override { }
void decode_payload() override { }
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
};
#endif
| 977 | 23.45 | 74 | h |
null | ceph-main/src/messages/MMonGetOSDMap.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2014 Red Hat
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MMONGETOSDMAP_H
#define CEPH_MMONGETOSDMAP_H
#include <iostream>
#include <string>
#include <string_view>
#include "msg/Message.h"
#include "include/types.h"
class MMonGetOSDMap final : public PaxosServiceMessage {
private:
epoch_t full_first, full_last;
epoch_t inc_first, inc_last;
public:
MMonGetOSDMap()
: PaxosServiceMessage{CEPH_MSG_MON_GET_OSDMAP, 0},
full_first(0),
full_last(0),
inc_first(0),
inc_last(0) { }
private:
~MMonGetOSDMap() final {}
public:
void request_full(epoch_t first, epoch_t last) {
ceph_assert(last >= first);
full_first = first;
full_last = last;
}
void request_inc(epoch_t first, epoch_t last) {
ceph_assert(last >= first);
inc_first = first;
inc_last = last;
}
epoch_t get_full_first() const {
return full_first;
}
epoch_t get_full_last() const {
return full_last;
}
epoch_t get_inc_first() const {
return inc_first;
}
epoch_t get_inc_last() const {
return inc_last;
}
std::string_view get_type_name() const override { return "mon_get_osdmap"; }
void print(std::ostream& out) const override {
out << "mon_get_osdmap(";
if (full_first && full_last)
out << "full " << full_first << "-" << full_last;
if (inc_first && inc_last)
out << " inc" << inc_first << "-" << inc_last;
out << ")";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
paxos_encode();
encode(full_first, payload);
encode(full_last, payload);
encode(inc_first, payload);
encode(inc_last, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
paxos_decode(p);
decode(full_first, p);
decode(full_last, p);
decode(inc_first, p);
decode(inc_last, p);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
};
#endif
| 2,345 | 22.938776 | 78 | h |
null | ceph-main/src/messages/MMonGetPurgedSnaps.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
#pragma once
#include "PaxosServiceMessage.h"
#include "include/types.h"
class MMonGetPurgedSnaps final : public PaxosServiceMessage {
public:
epoch_t start, last;
MMonGetPurgedSnaps(epoch_t s=0, epoch_t l=0)
: PaxosServiceMessage{MSG_MON_GET_PURGED_SNAPS, 0},
start(s),
last(l) {}
private:
~MMonGetPurgedSnaps() final {}
public:
std::string_view get_type_name() const override {
return "mon_get_purged_snaps";
}
void print(std::ostream& out) const override {
out << "mon_get_purged_snaps([" << start << "," << last << "])";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
paxos_encode();
encode(start, payload);
encode(last, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
paxos_decode(p);
decode(start, p);
decode(last, p);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
};
| 1,102 | 22.978261 | 70 | h |
null | ceph-main/src/messages/MMonGetPurgedSnapsReply.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
#pragma once
#include "PaxosServiceMessage.h"
#include "osd/osd_types.h"
#include "include/types.h"
class MMonGetPurgedSnapsReply final : public PaxosServiceMessage {
public:
epoch_t start, last;
std::map<epoch_t,mempool::osdmap::map<int64_t,snap_interval_set_t>> purged_snaps;
MMonGetPurgedSnapsReply(epoch_t s=0, epoch_t l=0)
: PaxosServiceMessage{MSG_MON_GET_PURGED_SNAPS_REPLY, 0},
start(s),
last(l) {}
private:
~MMonGetPurgedSnapsReply() final {}
public:
std::string_view get_type_name() const override {
return "mon_get_purged_snaps_reply";
}
void print(std::ostream& out) const override {
out << "mon_get_purged_snaps_reply([" << start << "," << last << "])";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
paxos_encode();
encode(start, payload);
encode(last, payload);
encode(purged_snaps, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
paxos_decode(p);
decode(start, p);
decode(last, p);
decode(purged_snaps, p);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
};
| 1,310 | 25.22 | 83 | h |
null | ceph-main/src/messages/MMonGetVersion.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2011 New Dream Network
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MMONGETVERSION_H
#define CEPH_MMONGETVERSION_H
#include "msg/Message.h"
#include "include/types.h"
/*
* This message is sent to the monitors to verify that the client's
* version of the map(s) is the latest available. For example, this
* can be used to determine whether a pool actually does not exist, or
* if it may have been created but the map was not received yet.
*/
class MMonGetVersion final : public Message {
public:
MMonGetVersion() : Message{CEPH_MSG_MON_GET_VERSION} {}
std::string_view get_type_name() const override {
return "mon_get_version";
}
void print(std::ostream& o) const override {
o << "mon_get_version(what=" << what << " handle=" << handle << ")";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(handle, payload);
encode(what, payload);
}
void decode_payload() override {
auto p = payload.cbegin();
using ceph::decode;
decode(handle, p);
decode(what, p);
}
ceph_tid_t handle = 0;
std::string what;
private:
~MMonGetVersion() final {}
};
#endif
| 1,500 | 23.606557 | 72 | h |
null | ceph-main/src/messages/MMonGetVersionReply.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2011 New Dream Network
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MMONGETVERSIONREPLY_H
#define CEPH_MMONGETVERSIONREPLY_H
#include "msg/Message.h"
#include "include/types.h"
/*
* This message is sent from the monitors to clients in response to a
* MMonGetVersion. The latest version of the requested thing is sent
* back.
*/
class MMonGetVersionReply final : public Message {
private:
static constexpr int HEAD_VERSION = 2;
public:
MMonGetVersionReply() : Message{CEPH_MSG_MON_GET_VERSION_REPLY, HEAD_VERSION} { }
std::string_view get_type_name() const override {
return "mon_get_version_reply";
}
void print(std::ostream& o) const override {
o << "mon_get_version_reply(handle=" << handle << " version=" << version << ")";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(handle, payload);
encode(version, payload);
encode(oldest_version, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(handle, p);
decode(version, p);
if (header.version >= 2)
decode(oldest_version, p);
}
ceph_tid_t handle = 0;
version_t version = 0;
version_t oldest_version = 0;
private:
~MMonGetVersionReply() final {}
};
#endif
| 1,633 | 23.38806 | 84 | h |
null | ceph-main/src/messages/MMonGlobalID.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MMONGLOBALID_H
#define CEPH_MMONGLOBALID_H
#include "messages/PaxosServiceMessage.h"
class MMonGlobalID final : public PaxosServiceMessage {
public:
uint64_t old_max_id = 0;
MMonGlobalID() : PaxosServiceMessage{MSG_MON_GLOBAL_ID, 0}
{}
private:
~MMonGlobalID() final {}
public:
std::string_view get_type_name() const override { return "global_id"; }
void print(std::ostream& out) const override {
out << "global_id (" << old_max_id << ")";
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
paxos_decode(p);
decode(old_max_id, p);
}
void encode_payload(uint64_t features) override {
using ceph::encode;
paxos_encode();
encode(old_max_id, payload);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
};
#endif
| 1,309 | 24.686275 | 73 | h |
null | ceph-main/src/messages/MMonHealth.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2012 Inktank, Inc.
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MMON_HEALTH_H
#define CEPH_MMON_HEALTH_H
#include "msg/Message.h"
#include "messages/MMonQuorumService.h"
#include "mon/mon_types.h"
class MMonHealth final : public MMonQuorumService {
public:
static constexpr int HEAD_VERSION = 1;
int service_type = 0;
int service_op = 0;
// service specific data
DataStats data_stats;
MMonHealth() : MMonQuorumService{MSG_MON_HEALTH, HEAD_VERSION} { }
private:
~MMonHealth() final { }
public:
std::string_view get_type_name() const override { return "mon_health"; }
void print(std::ostream &o) const override {
o << "mon_health("
<< " e " << get_epoch()
<< " r " << get_round()
<< " )";
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
service_decode(p);
decode(service_type, p);
decode(service_op, p);
decode(data_stats, p);
}
void encode_payload(uint64_t features) override {
using ceph::encode;
service_encode();
encode(service_type, payload);
encode(service_op, payload);
encode(data_stats, payload);
}
};
#endif /* CEPH_MMON_HEALTH_H */
| 1,532 | 22.953125 | 74 | h |
null | ceph-main/src/messages/MMonHealthChecks.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
#ifndef CEPH_MMON_HEALTH_CHECKS_H
#define CEPH_MMON_HEALTH_CHECKS_H
#include "messages/PaxosServiceMessage.h"
#include "mon/health_check.h"
class MMonHealthChecks final : public PaxosServiceMessage {
public:
static constexpr int HEAD_VERSION = 1;
static constexpr int COMPAT_VERSION = 1;
health_check_map_t health_checks;
MMonHealthChecks()
: PaxosServiceMessage{MSG_MON_HEALTH_CHECKS, HEAD_VERSION, COMPAT_VERSION} {
}
MMonHealthChecks(health_check_map_t& m)
: PaxosServiceMessage{MSG_MON_HEALTH_CHECKS, HEAD_VERSION, COMPAT_VERSION},
health_checks(m)
{}
private:
~MMonHealthChecks() final { }
public:
std::string_view get_type_name() const override { return "mon_health_checks"; }
void print(std::ostream &o) const override {
o << "mon_health_checks(" << health_checks.checks.size() << " checks)";
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
paxos_decode(p);
decode(health_checks, p);
}
void encode_payload(uint64_t features) override {
using ceph::encode;
paxos_encode();
encode(health_checks, payload);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
};
#endif
| 1,357 | 25.115385 | 81 | h |
null | ceph-main/src/messages/MMonJoin.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MMONJOIN_H
#define CEPH_MMONJOIN_H
#include "messages/PaxosServiceMessage.h"
class MMonJoin final : public PaxosServiceMessage {
public:
static constexpr int HEAD_VERSION = 3;
static constexpr int COMPAT_VERSION = 2;
uuid_d fsid;
std::string name;
entity_addrvec_t addrs;
/* The location members are for stretch mode. crush_loc is the location
* (generally just a "datacenter=<foo>" statement) of the monitor. The
* force_loc is whether the mon cluster should replace a previously-known
* location. Generally the monitor will force an update if it's given a
* location from the CLI on boot-up, and then never force again (so that it
* can be moved/updated via the ceph tool from elsewhere). */
std::map<std::string,std::string> crush_loc;
bool force_loc{false};
MMonJoin() : PaxosServiceMessage{MSG_MON_JOIN, 0, HEAD_VERSION, COMPAT_VERSION} {}
MMonJoin(uuid_d &f, std::string n, const entity_addrvec_t& av)
: PaxosServiceMessage{MSG_MON_JOIN, 0, HEAD_VERSION, COMPAT_VERSION},
fsid(f), name(n), addrs(av)
{ }
MMonJoin(uuid_d &f, std::string n, const entity_addrvec_t& av,
const std::map<std::string,std::string>& cloc, bool force)
: PaxosServiceMessage{MSG_MON_JOIN, 0, HEAD_VERSION, COMPAT_VERSION},
fsid(f), name(n), addrs(av), crush_loc(cloc), force_loc(force)
{ }
private:
~MMonJoin() final {}
public:
std::string_view get_type_name() const override { return "mon_join"; }
void print(std::ostream& o) const override {
o << "mon_join(" << name << " " << addrs << " " << crush_loc << ")";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
paxos_encode();
encode(fsid, payload);
encode(name, payload);
assert(HAVE_FEATURE(features, SERVER_NAUTILUS));
header.version = HEAD_VERSION;
header.compat_version = COMPAT_VERSION;
encode(addrs, payload, features);
encode(crush_loc, payload);
encode(force_loc, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
paxos_decode(p);
decode(fsid, p);
decode(name, p);
assert(header.version > 1);
decode(addrs, p);
if (header.version >= 3) {
decode(crush_loc, p);
decode(force_loc, p);
}
}
};
#endif
| 2,725 | 31.070588 | 84 | h |
null | ceph-main/src/messages/MMonMap.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MMONMAP_H
#define CEPH_MMONMAP_H
#include "include/encoding.h"
#include "include/ceph_features.h"
#include "msg/Message.h"
#include "msg/MessageRef.h"
#include "mon/MonMap.h"
class MMonMap final : public Message {
public:
ceph::buffer::list monmapbl;
MMonMap() : Message{CEPH_MSG_MON_MAP} { }
explicit MMonMap(ceph::buffer::list &bl) : Message{CEPH_MSG_MON_MAP} {
monmapbl = std::move(bl);
}
private:
~MMonMap() final {}
public:
std::string_view get_type_name() const override { return "mon_map"; }
void encode_payload(uint64_t features) override {
if (monmapbl.length() &&
((features & CEPH_FEATURE_MONENC) == 0 ||
(features & CEPH_FEATURE_MSG_ADDR2) == 0)) {
// reencode old-format monmap
MonMap t;
t.decode(monmapbl);
monmapbl.clear();
t.encode(monmapbl, features);
}
using ceph::encode;
encode(monmapbl, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(monmapbl, p);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
};
#endif
| 1,585 | 24.174603 | 72 | h |
null | ceph-main/src/messages/MMonMgrReport.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2017 Greg Farnum/Red Hat <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MMONMGRREPORT_H
#define CEPH_MMONMGRREPORT_H
#include "messages/PaxosServiceMessage.h"
#include "include/types.h"
#include "include/health.h"
#include "mon/health_check.h"
#include "mon/PGMap.h"
class MMonMgrReport final : public PaxosServiceMessage {
private:
static constexpr int HEAD_VERSION = 3;
static constexpr int COMPAT_VERSION = 1;
public:
// PGMapDigest is in data payload
health_check_map_t health_checks;
ceph::buffer::list service_map_bl; // encoded ServiceMap
std::map<std::string,ProgressEvent> progress_events;
uint64_t gid = 0;
MMonMgrReport()
: PaxosServiceMessage{MSG_MON_MGR_REPORT, 0, HEAD_VERSION, COMPAT_VERSION}
{}
private:
~MMonMgrReport() final {}
public:
std::string_view get_type_name() const override { return "monmgrreport"; }
void print(std::ostream& out) const override {
out << get_type_name() << "(gid " << gid
<< ", " << health_checks.checks.size() << " checks, "
<< progress_events.size() << " progress events)";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
paxos_encode();
encode(health_checks, payload);
encode(service_map_bl, payload);
encode(progress_events, payload);
encode(gid, payload);
if (!HAVE_FEATURE(features, SERVER_NAUTILUS) ||
!HAVE_FEATURE(features, SERVER_MIMIC)) {
// PGMapDigest had a backwards-incompatible change between
// luminous and mimic, and conditionally encodes based on
// provided features, so reencode the one in our data payload.
// The mgr isn't able to do this at the time the encoded
// PGMapDigest is constructed because we don't know which mon we
// will target. Note that this only triggers if the user
// upgrades ceph-mgr before ceph-mon (tsk tsk).
PGMapDigest digest;
auto p = data.cbegin();
decode(digest, p);
ceph::buffer::list bl;
encode(digest, bl, features);
set_data(bl);
}
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
paxos_decode(p);
decode(health_checks, p);
decode(service_map_bl, p);
if (header.version >= 2) {
decode(progress_events, p);
}
if (header.version >= 3) {
decode(gid, p);
}
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
};
#endif
| 2,827 | 28.768421 | 78 | h |
null | ceph-main/src/messages/MMonPaxos.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MMONPAXOS_H
#define CEPH_MMONPAXOS_H
#include "messages/PaxosServiceMessage.h"
#include "mon/mon_types.h"
#include "include/ceph_features.h"
class MMonPaxos final : public Message {
private:
static constexpr int HEAD_VERSION = 4;
static constexpr int COMPAT_VERSION = 3;
public:
// op types
static constexpr int OP_COLLECT = 1; // proposer: propose round
static constexpr int OP_LAST = 2; // voter: accept proposed round
static constexpr int OP_BEGIN = 3; // proposer: value proposed for this round
static constexpr int OP_ACCEPT = 4; // voter: accept propsed value
static constexpr int OP_COMMIT = 5; // proposer: notify learners of agreed value
static constexpr int OP_LEASE = 6; // leader: extend peon lease
static constexpr int OP_LEASE_ACK = 7; // peon: lease ack
static const char *get_opname(int op) {
switch (op) {
case OP_COLLECT: return "collect";
case OP_LAST: return "last";
case OP_BEGIN: return "begin";
case OP_ACCEPT: return "accept";
case OP_COMMIT: return "commit";
case OP_LEASE: return "lease";
case OP_LEASE_ACK: return "lease_ack";
default: ceph_abort(); return 0;
}
}
epoch_t epoch = 0; // monitor epoch
__s32 op = 0; // paxos op
version_t first_committed = 0; // i've committed to
version_t last_committed = 0; // i've committed to
version_t pn_from = 0; // i promise to accept after
version_t pn = 0; // with with proposal
version_t uncommitted_pn = 0; // previous pn, if we are a LAST with an uncommitted value
utime_t lease_timestamp;
utime_t sent_timestamp;
version_t latest_version = 0;
ceph::buffer::list latest_value;
std::map<version_t,ceph::buffer::list> values;
ceph::buffer::list feature_map;
MMonPaxos() : Message{MSG_MON_PAXOS, HEAD_VERSION, COMPAT_VERSION} { }
MMonPaxos(epoch_t e, int o, utime_t now) :
Message{MSG_MON_PAXOS, HEAD_VERSION, COMPAT_VERSION},
epoch(e),
op(o),
first_committed(0), last_committed(0), pn_from(0), pn(0), uncommitted_pn(0),
sent_timestamp(now),
latest_version(0) {
}
private:
~MMonPaxos() final {}
public:
std::string_view get_type_name() const override { return "paxos"; }
void print(std::ostream& out) const override {
out << "paxos(" << get_opname(op)
<< " lc " << last_committed
<< " fc " << first_committed
<< " pn " << pn << " opn " << uncommitted_pn;
if (latest_version)
out << " latest " << latest_version << " (" << latest_value.length() << " bytes)";
out << ")";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
header.version = HEAD_VERSION;
encode(epoch, payload);
encode(op, payload);
encode(first_committed, payload);
encode(last_committed, payload);
encode(pn_from, payload);
encode(pn, payload);
encode(uncommitted_pn, payload);
encode(lease_timestamp, payload);
encode(sent_timestamp, payload);
encode(latest_version, payload);
encode(latest_value, payload);
encode(values, payload);
encode(feature_map, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(epoch, p);
decode(op, p);
decode(first_committed, p);
decode(last_committed, p);
decode(pn_from, p);
decode(pn, p);
decode(uncommitted_pn, p);
decode(lease_timestamp, p);
decode(sent_timestamp, p);
decode(latest_version, p);
decode(latest_value, p);
decode(values, p);
if (header.version >= 4) {
decode(feature_map, p);
}
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
};
#endif
| 4,178 | 29.727941 | 94 | h |
null | ceph-main/src/messages/MMonPing.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/**
* This is used to send pings between monitors for
* heartbeat purposes. We include a timestamp and distinguish between
* outgoing pings and responses to those. If you set the
* min_message in the constructor, the message will inflate itself
* to the specified size -- this is good for dealing with network
* issues with jumbo frames. See http://tracker.ceph.com/issues/20087
*
*/
#ifndef CEPH_MMONPING_H
#define CEPH_MMONPING_H
#include "common/Clock.h"
#include "msg/Message.h"
#include "mon/ConnectionTracker.h"
class MMonPing final : public Message {
private:
static constexpr int HEAD_VERSION = 1;
static constexpr int COMPAT_VERSION = 1;
public:
enum {
PING = 1,
PING_REPLY = 2,
};
const char *get_op_name(int op) const {
switch (op) {
case PING: return "ping";
case PING_REPLY: return "ping_reply";
default: return "???";
}
}
__u8 op = 0;
utime_t stamp;
bufferlist tracker_bl;
uint32_t min_message_size = 0;
MMonPing(__u8 o, utime_t s, const bufferlist& tbl,
uint32_t min_message)
: Message{MSG_MON_PING, HEAD_VERSION, COMPAT_VERSION},
op(o), stamp(s), tracker_bl(tbl), min_message_size(min_message)
{}
MMonPing(__u8 o, utime_t s, const bufferlist& tbl)
: Message{MSG_MON_PING, HEAD_VERSION, COMPAT_VERSION},
op(o), stamp(s), tracker_bl(tbl) {}
MMonPing()
: Message{MSG_MON_PING, HEAD_VERSION, COMPAT_VERSION}
{}
private:
~MMonPing() final {}
public:
void decode_payload() override {
auto p = payload.cbegin();
decode(op, p);
decode(stamp, p);
decode(tracker_bl, p);
int payload_mid_length = p.get_off();
uint32_t size;
decode(size, p);
p += size;
min_message_size = size + payload_mid_length;
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(op, payload);
encode(stamp, payload);
encode(tracker_bl, payload);
size_t s = 0;
if (min_message_size > payload.length()) {
s = min_message_size - payload.length();
}
encode((uint32_t)s, payload);
if (s) {
// this should be big enough for normal min_message padding sizes. since
// we are targeting jumbo ethernet frames around 9000 bytes, 16k should
// be more than sufficient! the compiler will statically zero this so
// that at runtime we are only adding a bufferptr reference to it.
static char zeros[16384] = {};
while (s > sizeof(zeros)) {
payload.append(buffer::create_static(sizeof(zeros), zeros));
s -= sizeof(zeros);
}
if (s) {
payload.append(buffer::create_static(s, zeros));
}
}
}
std::string_view get_type_name() const override { return "mon_ping"; }
void print(std::ostream& out) const override {
out << "mon_ping(" << get_op_name(op)
<< " stamp " << stamp
<< ")";
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
};
#endif
| 3,080 | 27.009091 | 78 | h |
null | ceph-main/src/messages/MMonProbe.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MMONPROBE_H
#define CEPH_MMONPROBE_H
#include "include/ceph_features.h"
#include "common/ceph_releases.h"
#include "msg/Message.h"
#include "mon/MonMap.h"
class MMonProbe final : public Message {
public:
static constexpr int HEAD_VERSION = 8;
static constexpr int COMPAT_VERSION = 5;
enum {
OP_PROBE = 1,
OP_REPLY = 2,
OP_SLURP = 3,
OP_SLURP_LATEST = 4,
OP_DATA = 5,
OP_MISSING_FEATURES = 6,
};
static const char *get_opname(int o) {
switch (o) {
case OP_PROBE: return "probe";
case OP_REPLY: return "reply";
case OP_SLURP: return "slurp";
case OP_SLURP_LATEST: return "slurp_latest";
case OP_DATA: return "data";
case OP_MISSING_FEATURES: return "missing_features";
default: ceph_abort(); return 0;
}
}
uuid_d fsid;
int32_t op = 0;
std::string name;
std::set<int32_t> quorum;
int leader = -1;
ceph::buffer::list monmap_bl;
version_t paxos_first_version = 0;
version_t paxos_last_version = 0;
bool has_ever_joined = 0;
uint64_t required_features = 0;
ceph_release_t mon_release{ceph_release_t::unknown};
MMonProbe()
: Message{MSG_MON_PROBE, HEAD_VERSION, COMPAT_VERSION} {}
MMonProbe(const uuid_d& f, int o, const std::string& n, bool hej, ceph_release_t mr)
: Message{MSG_MON_PROBE, HEAD_VERSION, COMPAT_VERSION},
fsid(f),
op(o),
name(n),
paxos_first_version(0),
paxos_last_version(0),
has_ever_joined(hej),
required_features(0),
mon_release{mr} {}
private:
~MMonProbe() final {}
public:
std::string_view get_type_name() const override { return "mon_probe"; }
void print(std::ostream& out) const override {
out << "mon_probe(" << get_opname(op) << " " << fsid << " name " << name;
if (quorum.size())
out << " quorum " << quorum;
out << " leader " << leader;
if (op == OP_REPLY) {
out << " paxos("
<< " fc " << paxos_first_version
<< " lc " << paxos_last_version
<< " )";
}
if (!has_ever_joined)
out << " new";
if (required_features)
out << " required_features " << required_features;
if (mon_release != ceph_release_t::unknown)
out << " mon_release " << mon_release;
out << ")";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
if (monmap_bl.length() &&
((features & CEPH_FEATURE_MONENC) == 0 ||
(features & CEPH_FEATURE_MSG_ADDR2) == 0)) {
// reencode old-format monmap
MonMap t;
t.decode(monmap_bl);
monmap_bl.clear();
t.encode(monmap_bl, features);
}
encode(fsid, payload);
encode(op, payload);
encode(name, payload);
encode(quorum, payload);
encode(monmap_bl, payload);
encode(has_ever_joined, payload);
encode(paxos_first_version, payload);
encode(paxos_last_version, payload);
encode(required_features, payload);
encode(mon_release, payload);
encode(leader, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(fsid, p);
decode(op, p);
decode(name, p);
decode(quorum, p);
decode(monmap_bl, p);
decode(has_ever_joined, p);
decode(paxos_first_version, p);
decode(paxos_last_version, p);
if (header.version >= 6)
decode(required_features, p);
else
required_features = 0;
if (header.version >= 7)
decode(mon_release, p);
else
mon_release = ceph_release_t::unknown;
if (header.version >= 8) {
decode(leader, p);
} else if (quorum.size()) {
leader = *quorum.begin();
}
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
};
#endif
| 4,154 | 25.980519 | 86 | h |
null | ceph-main/src/messages/MMonQuorumService.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2012 Inktank, Inc.
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MMON_QUORUM_SERVICE_H
#define CEPH_MMON_QUORUM_SERVICE_H
#include "msg/Message.h"
class MMonQuorumService : public Message {
public:
epoch_t epoch = 0;
version_t round = 0;
protected:
MMonQuorumService(int type, int head)
: Message{type, head, 1}
{}
~MMonQuorumService() override {}
public:
void set_epoch(epoch_t e) {
epoch = e;
}
void set_round(version_t r) {
round = r;
}
epoch_t get_epoch() const {
return epoch;
}
version_t get_round() const {
return round;
}
void service_encode() {
using ceph::encode;
encode(epoch, payload);
encode(round, payload);
}
void service_decode(ceph::buffer::list::const_iterator &p) {
using ceph::decode;
decode(epoch, p);
decode(round, p);
}
void encode_payload(uint64_t features) override {
ceph_abort_msg("MMonQuorumService message must always be a base class");
}
void decode_payload() override {
ceph_abort_msg("MMonQuorumService message must always be a base class");
}
std::string_view get_type_name() const override { return "quorum_service"; }
};
#endif /* CEPH_MMON_QUORUM_SERVICE_H */
| 1,557 | 20.943662 | 78 | h |
null | ceph-main/src/messages/MMonScrub.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2013 Inktank, Inc.
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*/
#ifndef CEPH_MMONSCRUB_H
#define CEPH_MMONSCRUB_H
#include "msg/Message.h"
#include "mon/mon_types.h"
class MMonScrub : public Message {
private:
static constexpr int HEAD_VERSION = 2;
static constexpr int COMPAT_VERSION = 2;
public:
typedef enum {
OP_SCRUB = 1, // leader->peon: scrub (a range of) keys
OP_RESULT = 2, // peon->leader: result of a scrub
} op_type_t;
static const char *get_opname(op_type_t op) {
switch (op) {
case OP_SCRUB: return "scrub";
case OP_RESULT: return "result";
default: ceph_abort_msg("unknown op type"); return NULL;
}
}
op_type_t op = OP_SCRUB;
version_t version = 0;
ScrubResult result;
int32_t num_keys;
std::pair<std::string,std::string> key;
MMonScrub()
: Message{MSG_MON_SCRUB, HEAD_VERSION, COMPAT_VERSION},
num_keys(-1)
{ }
MMonScrub(op_type_t op, version_t v, int32_t num_keys)
: Message{MSG_MON_SCRUB, HEAD_VERSION, COMPAT_VERSION},
op(op), version(v), num_keys(num_keys)
{ }
std::string_view get_type_name() const override { return "mon_scrub"; }
void print(std::ostream& out) const override {
out << "mon_scrub(" << get_opname((op_type_t)op);
out << " v " << version;
if (op == OP_RESULT)
out << " " << result;
out << " num_keys " << num_keys;
out << " key (" << key << ")";
out << ")";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
uint8_t o = op;
encode(o, payload);
encode(version, payload);
encode(result, payload);
encode(num_keys, payload);
encode(key, payload);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
uint8_t o;
decode(o, p);
op = (op_type_t)o;
decode(version, p);
decode(result, p);
decode(num_keys, p);
decode(key, p);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
};
#endif /* CEPH_MMONSCRUB_H */
| 2,395 | 24.763441 | 73 | h |
null | ceph-main/src/messages/MMonSubscribe.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MMONSUBSCRIBE_H
#define CEPH_MMONSUBSCRIBE_H
#include "msg/Message.h"
#include "include/ceph_features.h"
/*
* compatibility with old crap
*/
struct ceph_mon_subscribe_item_old {
ceph_le64 unused;
ceph_le64 have;
__u8 onetime;
} __attribute__ ((packed));
WRITE_RAW_ENCODER(ceph_mon_subscribe_item_old)
class MMonSubscribe final : public Message {
public:
static constexpr int HEAD_VERSION = 3;
static constexpr int COMPAT_VERSION = 1;
std::string hostname;
std::map<std::string, ceph_mon_subscribe_item> what;
MMonSubscribe() : Message{CEPH_MSG_MON_SUBSCRIBE, HEAD_VERSION, COMPAT_VERSION} { }
private:
~MMonSubscribe() final {}
public:
void sub_want(const char *w, version_t start, unsigned flags) {
what[w].start = start;
what[w].flags = flags;
}
std::string_view get_type_name() const override { return "mon_subscribe"; }
void print(std::ostream& o) const override {
o << "mon_subscribe(" << what << ")";
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
if (header.version < 2) {
std::map<std::string, ceph_mon_subscribe_item_old> oldwhat;
decode(oldwhat, p);
what.clear();
for (auto q = oldwhat.begin(); q != oldwhat.end(); q++) {
if (q->second.have)
what[q->first].start = q->second.have + 1;
else
what[q->first].start = 0;
what[q->first].flags = 0;
if (q->second.onetime)
what[q->first].flags |= CEPH_SUBSCRIBE_ONETIME;
}
return;
}
decode(what, p);
if (header.version >= 3) {
decode(hostname, p);
}
}
void encode_payload(uint64_t features) override {
using ceph::encode;
if ((features & CEPH_FEATURE_SUBSCRIBE2) == 0) {
header.version = 0;
std::map<std::string, ceph_mon_subscribe_item_old> oldwhat;
for (auto q = what.begin(); q != what.end(); q++) {
if (q->second.start)
// warning: start=1 -> have=0, which was ambiguous
oldwhat[q->first].have = q->second.start - 1;
else
oldwhat[q->first].have = 0;
oldwhat[q->first].onetime = q->second.flags & CEPH_SUBSCRIBE_ONETIME;
}
encode(oldwhat, payload);
return;
}
header.version = HEAD_VERSION;
encode(what, payload);
encode(hostname, payload);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
};
#endif
| 2,812 | 26.048077 | 85 | h |
null | ceph-main/src/messages/MMonSubscribeAck.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MMONSUBSCRIBEACK_H
#define CEPH_MMONSUBSCRIBEACK_H
#include "msg/Message.h"
class MMonSubscribeAck final : public Message {
public:
__u32 interval;
uuid_d fsid;
MMonSubscribeAck() : Message{CEPH_MSG_MON_SUBSCRIBE_ACK},
interval(0) {
}
MMonSubscribeAck(uuid_d& f, int i) : Message{CEPH_MSG_MON_SUBSCRIBE_ACK},
interval(i), fsid(f) { }
private:
~MMonSubscribeAck() final {}
public:
std::string_view get_type_name() const override { return "mon_subscribe_ack"; }
void print(std::ostream& o) const override {
o << "mon_subscribe_ack(" << interval << "s)";
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(interval, p);
decode(fsid, p);
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(interval, payload);
encode(fsid, payload);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
};
#endif
| 1,450 | 24.910714 | 81 | h |
null | ceph-main/src/messages/MMonSync.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2012 Inktank, Inc.
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*/
#ifndef CEPH_MMONSYNC_H
#define CEPH_MMONSYNC_H
#include "msg/Message.h"
class MMonSync : public Message {
private:
static constexpr int HEAD_VERSION = 2;
static constexpr int COMPAT_VERSION = 2;
public:
/**
* Operation types
*/
enum {
OP_GET_COOKIE_FULL = 1, // -> start a session (full scan)
OP_GET_COOKIE_RECENT = 2, // -> start a session (only recent paxos events)
OP_COOKIE = 3, // <- pass the iterator cookie, or
OP_GET_CHUNK = 4, // -> get some keys
OP_CHUNK = 5, // <- return some keys
OP_LAST_CHUNK = 6, // <- return the last set of keys
OP_NO_COOKIE = 8, // <- sorry, no cookie
};
/**
* Obtain a string corresponding to the operation type @p op
*
* @param op Operation type
* @returns A string
*/
static const char *get_opname(int op) {
switch (op) {
case OP_GET_COOKIE_FULL: return "get_cookie_full";
case OP_GET_COOKIE_RECENT: return "get_cookie_recent";
case OP_COOKIE: return "cookie";
case OP_GET_CHUNK: return "get_chunk";
case OP_CHUNK: return "chunk";
case OP_LAST_CHUNK: return "last_chunk";
case OP_NO_COOKIE: return "no_cookie";
default: ceph_abort_msg("unknown op type"); return NULL;
}
}
uint32_t op = 0;
uint64_t cookie = 0;
version_t last_committed = 0;
std::pair<std::string,std::string> last_key;
ceph::buffer::list chunk_bl;
entity_inst_t reply_to;
MMonSync()
: Message{MSG_MON_SYNC, HEAD_VERSION, COMPAT_VERSION}
{ }
MMonSync(uint32_t op, uint64_t c = 0)
: Message{MSG_MON_SYNC, HEAD_VERSION, COMPAT_VERSION},
op(op),
cookie(c),
last_committed(0)
{ }
std::string_view get_type_name() const override { return "mon_sync"; }
void print(std::ostream& out) const override {
out << "mon_sync(" << get_opname(op);
if (cookie)
out << " cookie " << cookie;
if (last_committed > 0)
out << " lc " << last_committed;
if (chunk_bl.length())
out << " bl " << chunk_bl.length() << " bytes";
if (!last_key.first.empty() || !last_key.second.empty())
out << " last_key " << last_key.first << "," << last_key.second;
out << ")";
}
void encode_payload(uint64_t features) override {
using ceph::encode;
encode(op, payload);
encode(cookie, payload);
encode(last_committed, payload);
encode(last_key.first, payload);
encode(last_key.second, payload);
encode(chunk_bl, payload);
encode(reply_to, payload, features);
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
decode(op, p);
decode(cookie, p);
decode(last_committed, p);
decode(last_key.first, p);
decode(last_key.second, p);
decode(chunk_bl, p);
decode(reply_to, p);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
};
#endif /* CEPH_MMONSYNC_H */
| 3,336 | 27.521368 | 78 | h |
null | ceph-main/src/messages/MMonUsedPendingKeys.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#pragma once
#include "messages/PaxosServiceMessage.h"
class MMonUsedPendingKeys final : public PaxosServiceMessage {
public:
std::map<EntityName,CryptoKey> used_pending_keys;
MMonUsedPendingKeys() : PaxosServiceMessage{MSG_MON_USED_PENDING_KEYS, 0}
{}
private:
~MMonUsedPendingKeys() final {}
public:
std::string_view get_type_name() const override { return "used_pending_keys"; }
void print(std::ostream& out) const override {
out << "used_pending_keys(" << used_pending_keys.size() << " keys)";
}
void decode_payload() override {
using ceph::decode;
auto p = payload.cbegin();
paxos_decode(p);
decode(used_pending_keys, p);
}
void encode_payload(uint64_t features) override {
using ceph::encode;
paxos_encode();
encode(used_pending_keys, payload);
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
};
| 1,362 | 26.816327 | 81 | h |
null | ceph-main/src/messages/MOSDAlive.h | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab
/*
* Ceph - scalable distributed file system
*
* Copyright (C) 2004-2006 Sage Weil <[email protected]>
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software
* Foundation. See file COPYING.
*
*/
#ifndef CEPH_MOSDALIVE_H
#define CEPH_MOSDALIVE_H
#include "messages/PaxosServiceMessage.h"
class MOSDAlive final : public PaxosServiceMessage {
public:
epoch_t want = 0;
MOSDAlive(epoch_t h, epoch_t w) : PaxosServiceMessage{MSG_OSD_ALIVE, h}, want(w) {}
MOSDAlive() : MOSDAlive{0, 0} {}
private:
~MOSDAlive() final {}
public:
void encode_payload(uint64_t features) override {
paxos_encode();
using ceph::encode;
encode(want, payload);
}
void decode_payload() override {
auto p = payload.cbegin();
paxos_decode(p);
using ceph::decode;
decode(want, p);
}
std::string_view get_type_name() const override { return "osd_alive"; }
void print(std::ostream &out) const override {
out << "osd_alive(want up_thru " << want << " have " << version << ")";
}
private:
template<class T, typename... Args>
friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
};
#endif
| 1,364 | 24.277778 | 85 | h |