Skip to content

Commit

Permalink
msg: cleanup factory/ref definition in messages
Browse files Browse the repository at this point in the history
This eliminates duplicate code definitions.

Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
  • Loading branch information
batrick committed Aug 14, 2018
1 parent ddd9059 commit bdc8e4b
Show file tree
Hide file tree
Showing 152 changed files with 458 additions and 900 deletions.
7 changes: 2 additions & 5 deletions src/messages/MAuth.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@

#include "messages/PaxosServiceMessage.h"

class MAuth : public PaxosServiceMessage {
class MAuth : public MessageInstance<MAuth, PaxosServiceMessage> {
public:
typedef boost::intrusive_ptr<MAuth> ref;
typedef boost::intrusive_ptr<MAuth const> const_ref;
using factory = MessageFactory<MAuth>;
friend factory;

__u32 protocol;
Expand All @@ -30,7 +27,7 @@ class MAuth : public PaxosServiceMessage {

/* if protocol == 0, then auth_payload is a set<__u32> listing protocols the client supports */

MAuth() : PaxosServiceMessage(CEPH_MSG_AUTH, 0), protocol(0), monmap_epoch(0) { }
MAuth() : MessageInstance(CEPH_MSG_AUTH, 0), protocol(0), monmap_epoch(0) { }
private:
~MAuth() override {}

Expand Down
9 changes: 3 additions & 6 deletions src/messages/MAuthReply.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@
#include "msg/Message.h"
#include "common/errno.h"

class MAuthReply : public Message {
class MAuthReply : public MessageInstance<MAuthReply> {
public:
typedef boost::intrusive_ptr<MAuthReply> ref;
typedef boost::intrusive_ptr<MAuthReply const> const_ref;
using factory = MessageFactory<MAuthReply>;
friend factory;

__u32 protocol;
Expand All @@ -31,9 +28,9 @@ class MAuthReply : public Message {
string result_msg;
bufferlist result_bl;

MAuthReply() : Message(CEPH_MSG_AUTH_REPLY), protocol(0), result(0), global_id(0) {}
MAuthReply() : MessageInstance(CEPH_MSG_AUTH_REPLY), protocol(0), result(0), global_id(0) {}
MAuthReply(__u32 p, bufferlist *bl = NULL, int r = 0, uint64_t gid=0, const char *msg = "") :
Message(CEPH_MSG_AUTH_REPLY),
MessageInstance(CEPH_MSG_AUTH_REPLY),
protocol(p), result(r), global_id(gid),
result_msg(msg) {
if (bl)
Expand Down
9 changes: 3 additions & 6 deletions src/messages/MBackfillReserve.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@
#include "msg/Message.h"
#include "messages/MOSDPeeringOp.h"

class MBackfillReserve : public MOSDPeeringOp {
class MBackfillReserve : public MessageInstance<MBackfillReserve, MOSDPeeringOp> {
public:
typedef boost::intrusive_ptr<MBackfillReserve> ref;
typedef boost::intrusive_ptr<MBackfillReserve const> const_ref;
using factory = MessageFactory<MBackfillReserve>;
friend factory;
private:
static const int HEAD_VERSION = 4;
Expand Down Expand Up @@ -95,12 +92,12 @@ class MBackfillReserve : public MOSDPeeringOp {
}

MBackfillReserve()
: MOSDPeeringOp(MSG_OSD_BACKFILL_RESERVE, HEAD_VERSION, COMPAT_VERSION),
: MessageInstance(MSG_OSD_BACKFILL_RESERVE, HEAD_VERSION, COMPAT_VERSION),
query_epoch(0), type(-1), priority(-1) {}
MBackfillReserve(int type,
spg_t pgid,
epoch_t query_epoch, unsigned prio = -1)
: MOSDPeeringOp(MSG_OSD_BACKFILL_RESERVE, HEAD_VERSION, COMPAT_VERSION),
: MessageInstance(MSG_OSD_BACKFILL_RESERVE, HEAD_VERSION, COMPAT_VERSION),
pgid(pgid), query_epoch(query_epoch),
type(type), priority(prio) {}

Expand Down
9 changes: 3 additions & 6 deletions src/messages/MCacheExpire.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,8 @@

#include "mds/mdstypes.h"

class MCacheExpire : public Message {
class MCacheExpire : public MessageInstance<MCacheExpire> {
public:
typedef boost::intrusive_ptr<MCacheExpire> ref;
typedef boost::intrusive_ptr<MCacheExpire const> const_ref;
using factory = MessageFactory<MCacheExpire>;
friend factory;
private:
__s32 from;
Expand Down Expand Up @@ -71,9 +68,9 @@ class MCacheExpire : public Message {
int get_from() const { return from; }

protected:
MCacheExpire() : Message(MSG_MDS_CACHEEXPIRE), from(-1) {}
MCacheExpire() : MessageInstance(MSG_MDS_CACHEEXPIRE), from(-1) {}
MCacheExpire(int f) :
Message(MSG_MDS_CACHEEXPIRE),
MessageInstance(MSG_MDS_CACHEEXPIRE),
from(f) { }
~MCacheExpire() override {}

Expand Down
7 changes: 2 additions & 5 deletions src/messages/MClientCapRelease.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@
#include "msg/Message.h"


class MClientCapRelease : public Message {
class MClientCapRelease : public MessageInstance<MClientCapRelease> {
public:
typedef boost::intrusive_ptr<MClientCapRelease> ref;
typedef boost::intrusive_ptr<MClientCapRelease const> const_ref;
using factory = MessageFactory<MClientCapRelease>;
friend factory;

private:
Expand All @@ -38,7 +35,7 @@ class MClientCapRelease : public Message {
epoch_t osd_epoch_barrier;

MClientCapRelease() :
Message(CEPH_MSG_CLIENT_CAPRELEASE, HEAD_VERSION, COMPAT_VERSION),
MessageInstance(CEPH_MSG_CLIENT_CAPRELEASE, HEAD_VERSION, COMPAT_VERSION),
osd_epoch_barrier(0)
{
memset(&head, 0, sizeof(head));
Expand Down
11 changes: 4 additions & 7 deletions src/messages/MClientCaps.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@
#include "msg/Message.h"
#include "include/ceph_features.h"

class MClientCaps : public Message {
class MClientCaps : public MessageInstance<MClientCaps> {
public:
typedef boost::intrusive_ptr<MClientCaps> ref;
typedef boost::intrusive_ptr<MClientCaps const> const_ref;
using factory = MessageFactory<MClientCaps>;
friend factory;
private:

Expand Down Expand Up @@ -133,7 +130,7 @@ class MClientCaps : public Message {

protected:
MClientCaps()
: Message(CEPH_MSG_CLIENT_CAPS, HEAD_VERSION, COMPAT_VERSION) {}
: MessageInstance(CEPH_MSG_CLIENT_CAPS, HEAD_VERSION, COMPAT_VERSION) {}
MClientCaps(int op,
inodeno_t ino,
inodeno_t realm,
Expand All @@ -144,7 +141,7 @@ class MClientCaps : public Message {
int dirty,
int mseq,
epoch_t oeb)
: Message(CEPH_MSG_CLIENT_CAPS, HEAD_VERSION, COMPAT_VERSION),
: MessageInstance(CEPH_MSG_CLIENT_CAPS, HEAD_VERSION, COMPAT_VERSION),
osd_epoch_barrier(oeb) {
memset(&head, 0, sizeof(head));
head.op = op;
Expand All @@ -161,7 +158,7 @@ class MClientCaps : public Message {
MClientCaps(int op,
inodeno_t ino, inodeno_t realm,
uint64_t id, int mseq, epoch_t oeb)
: Message(CEPH_MSG_CLIENT_CAPS, HEAD_VERSION, COMPAT_VERSION),
: MessageInstance(CEPH_MSG_CLIENT_CAPS, HEAD_VERSION, COMPAT_VERSION),
osd_epoch_barrier(oeb) {
memset(&head, 0, sizeof(head));
head.op = op;
Expand Down
13 changes: 5 additions & 8 deletions src/messages/MClientLease.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@

#include "msg/Message.h"

class MClientLease : public Message {
class MClientLease : public MessageInstance<MClientLease> {
public:
typedef boost::intrusive_ptr<MClientLease> ref;
typedef boost::intrusive_ptr<MClientLease const> const_ref;
using factory = MessageFactory<MClientLease>;
friend factory;

struct ceph_mds_lease h;
Expand All @@ -38,13 +35,13 @@ class MClientLease : public Message {
snapid_t get_last() const { return snapid_t(h.last); }

protected:
MClientLease() : Message(CEPH_MSG_CLIENT_LEASE) {}
MClientLease() : MessageInstance(CEPH_MSG_CLIENT_LEASE) {}
MClientLease(const MClientLease& m) :
Message(CEPH_MSG_CLIENT_LEASE),
MessageInstance(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) :
Message(CEPH_MSG_CLIENT_LEASE) {
MessageInstance(CEPH_MSG_CLIENT_LEASE) {
h.action = ac;
h.seq = seq;
h.mask = m;
Expand All @@ -54,7 +51,7 @@ class MClientLease : public Message {
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) :
Message(CEPH_MSG_CLIENT_LEASE),
MessageInstance(CEPH_MSG_CLIENT_LEASE),
dname(d) {
h.action = ac;
h.seq = seq;
Expand Down
7 changes: 2 additions & 5 deletions src/messages/MClientQuota.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@

#include "msg/Message.h"

class MClientQuota : public Message {
class MClientQuota : public MessageInstance<MClientQuota> {
public:
typedef boost::intrusive_ptr<MClientQuota> ref;
typedef boost::intrusive_ptr<MClientQuota const> const_ref;
using factory = MessageFactory<MClientQuota>;
friend factory;

inodeno_t ino;
Expand All @@ -16,7 +13,7 @@ class MClientQuota : public Message {

protected:
MClientQuota() :
Message(CEPH_MSG_CLIENT_QUOTA),
MessageInstance(CEPH_MSG_CLIENT_QUOTA),
ino(0)
{}
~MClientQuota() override {}
Expand Down
7 changes: 2 additions & 5 deletions src/messages/MClientReconnect.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@
#include "include/ceph_features.h"


class MClientReconnect : public Message {
class MClientReconnect : public MessageInstance<MClientReconnect> {
public:
typedef boost::intrusive_ptr<MClientReconnect> ref;
typedef boost::intrusive_ptr<MClientReconnect const> const_ref;
using factory = MessageFactory<MClientReconnect>;
friend factory;
private:
const static int HEAD_VERSION = 3;
Expand All @@ -33,7 +30,7 @@ class MClientReconnect : public Message {
map<inodeno_t, cap_reconnect_t> caps; // only head inodes
vector<ceph_mds_snaprealm_reconnect> realms;

MClientReconnect() : Message(CEPH_MSG_CLIENT_RECONNECT, HEAD_VERSION) { }
MClientReconnect() : MessageInstance(CEPH_MSG_CLIENT_RECONNECT, HEAD_VERSION) { }
private:
~MClientReconnect() override {}

Expand Down
9 changes: 3 additions & 6 deletions src/messages/MClientReply.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,8 @@ struct InodeStat {
};


class MClientReply : public Message {
class MClientReply : public MessageInstance<MClientReply> {
public:
typedef boost::intrusive_ptr<MClientReply> ref;
typedef boost::intrusive_ptr<MClientReply const> const_ref;
using factory = MessageFactory<MClientReply>;
friend factory;

// reply data
Expand All @@ -282,9 +279,9 @@ class MClientReply : public Message {
bool is_safe() const { return head.safe; }

protected:
MClientReply() : Message(CEPH_MSG_CLIENT_REPLY) {}
MClientReply() : MessageInstance(CEPH_MSG_CLIENT_REPLY) {}
MClientReply(const MClientRequest &req, int result = 0) :
Message(CEPH_MSG_CLIENT_REPLY) {
MessageInstance(CEPH_MSG_CLIENT_REPLY) {
memset(&head, 0, sizeof(head));
header.tid = req.get_tid();
head.op = req.get_op();
Expand Down
9 changes: 3 additions & 6 deletions src/messages/MClientRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,8 @@

// metadata ops.

class MClientRequest : public Message {
class MClientRequest : public MessageInstance<MClientRequest> {
public:
typedef boost::intrusive_ptr<MClientRequest> ref;
typedef boost::intrusive_ptr<MClientRequest const> const_ref;
using factory = MessageFactory<MClientRequest>;
friend factory;
private:
static const int HEAD_VERSION = 4;
Expand Down Expand Up @@ -94,9 +91,9 @@ class MClientRequest : public Message {
protected:
// cons
MClientRequest()
: Message(CEPH_MSG_CLIENT_REQUEST, HEAD_VERSION, COMPAT_VERSION) {}
: MessageInstance(CEPH_MSG_CLIENT_REQUEST, HEAD_VERSION, COMPAT_VERSION) {}
MClientRequest(int op)
: Message(CEPH_MSG_CLIENT_REQUEST, HEAD_VERSION, COMPAT_VERSION) {
: MessageInstance(CEPH_MSG_CLIENT_REQUEST, HEAD_VERSION, COMPAT_VERSION) {
memset(&head, 0, sizeof(head));
head.op = op;
}
Expand Down
9 changes: 3 additions & 6 deletions src/messages/MClientRequestForward.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@

#include "msg/Message.h"

class MClientRequestForward : public Message {
class MClientRequestForward : public MessageInstance<MClientRequestForward> {
public:
typedef boost::intrusive_ptr<MClientRequestForward> ref;
typedef boost::intrusive_ptr<MClientRequestForward const> const_ref;
using factory = MessageFactory<MClientRequestForward>;
friend factory;
private:
int32_t dest_mds;
Expand All @@ -31,10 +28,10 @@ class MClientRequestForward : public Message {

protected:
MClientRequestForward()
: Message(CEPH_MSG_CLIENT_REQUEST_FORWARD),
: MessageInstance(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) :
Message(CEPH_MSG_CLIENT_REQUEST_FORWARD),
MessageInstance(CEPH_MSG_CLIENT_REQUEST_FORWARD),
dest_mds(dm), num_fwd(nf), client_must_resend(cmr) {
assert(client_must_resend);
header.tid = t;
Expand Down
11 changes: 4 additions & 7 deletions src/messages/MClientSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@
#include "msg/Message.h"
#include "mds/mdstypes.h"

class MClientSession : public Message {
class MClientSession : public MessageInstance<MClientSession> {
public:
typedef boost::intrusive_ptr<MClientSession> ref;
typedef boost::intrusive_ptr<MClientSession const> const_ref;
using factory = MessageFactory<MClientSession>;
friend factory;
private:
static const int HEAD_VERSION = 3;
Expand All @@ -41,15 +38,15 @@ class MClientSession : public Message {
int get_max_leases() const { return head.max_leases; }

protected:
MClientSession() : Message(CEPH_MSG_CLIENT_SESSION, HEAD_VERSION, COMPAT_VERSION) { }
MClientSession() : MessageInstance(CEPH_MSG_CLIENT_SESSION, HEAD_VERSION, COMPAT_VERSION) { }
MClientSession(int o, version_t s=0) :
Message(CEPH_MSG_CLIENT_SESSION, HEAD_VERSION, COMPAT_VERSION) {
MessageInstance(CEPH_MSG_CLIENT_SESSION, HEAD_VERSION, COMPAT_VERSION) {
memset(&head, 0, sizeof(head));
head.op = o;
head.seq = s;
}
MClientSession(int o, utime_t st) :
Message(CEPH_MSG_CLIENT_SESSION, HEAD_VERSION, COMPAT_VERSION) {
MessageInstance(CEPH_MSG_CLIENT_SESSION, HEAD_VERSION, COMPAT_VERSION) {
memset(&head, 0, sizeof(head));
head.op = o;
head.seq = 0;
Expand Down
7 changes: 2 additions & 5 deletions src/messages/MClientSnap.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@

#include "msg/Message.h"

class MClientSnap : public Message {
class MClientSnap : public MessageInstance<MClientSnap> {
public:
typedef boost::intrusive_ptr<MClientSnap> ref;
typedef boost::intrusive_ptr<MClientSnap const> const_ref;
using factory = MessageFactory<MClientSnap>;
friend factory;

ceph_mds_snap_head head;
Expand All @@ -33,7 +30,7 @@ class MClientSnap : public Message {

protected:
MClientSnap(int o=0) :
Message(CEPH_MSG_CLIENT_SNAP) {
MessageInstance(CEPH_MSG_CLIENT_SNAP) {
memset(&head, 0, sizeof(head));
head.op = o;
}
Expand Down
9 changes: 3 additions & 6 deletions src/messages/MCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,17 @@

#include "msg/Message.h"

class MCommand : public Message {
class MCommand : public MessageInstance<MCommand> {
public:
typedef boost::intrusive_ptr<MCommand> ref;
typedef boost::intrusive_ptr<MCommand const> const_ref;
using factory = MessageFactory<MCommand>;
friend factory;

uuid_d fsid;
std::vector<string> cmd;

MCommand()
: Message(MSG_COMMAND) {}
: MessageInstance(MSG_COMMAND) {}
MCommand(const uuid_d &f)
: Message(MSG_COMMAND),
: MessageInstance(MSG_COMMAND),
fsid(f) { }

private:
Expand Down
Loading

0 comments on commit bdc8e4b

Please sign in to comment.