Define common get_spg() and get_map_epoch() methods.
Signed-off-by: Sage Weil <sage@redhat.com>
#ifndef MOSDECSUBOPREAD_H
#define MOSDECSUBOPREAD_H
-#include "msg/Message.h"
-#include "osd/osd_types.h"
+#include "MOSDFastDispatchOp.h"
#include "osd/ECMsgTypes.h"
-class MOSDECSubOpRead : public Message {
+class MOSDECSubOpRead : public MOSDFastDispatchOp {
static const int HEAD_VERSION = 2;
static const int COMPAT_VERSION = 1;
int get_cost() const {
return 0;
}
+ epoch_t get_map_epoch() const override {
+ return map_epoch;
+ }
+ spg_t get_spg() const override {
+ return pgid;
+ }
- MOSDECSubOpRead() :
- Message(MSG_OSD_EC_READ, HEAD_VERSION, COMPAT_VERSION)
+ MOSDECSubOpRead()
+ : MOSDFastDispatchOp(MSG_OSD_EC_READ, HEAD_VERSION, COMPAT_VERSION)
{}
virtual void decode_payload() {
#ifndef MOSDECSUBOPREADREPLY_H
#define MOSDECSUBOPREADREPLY_H
-#include "msg/Message.h"
-#include "osd/osd_types.h"
+#include "MOSDFastDispatchOp.h"
#include "osd/ECMsgTypes.h"
-class MOSDECSubOpReadReply : public Message {
+class MOSDECSubOpReadReply : public MOSDFastDispatchOp {
static const int HEAD_VERSION = 1;
static const int COMPAT_VERSION = 1;
int get_cost() const {
return 0;
}
+ epoch_t get_map_epoch() const override {
+ return map_epoch;
+ }
+ spg_t get_spg() const override {
+ return pgid;
+ }
- MOSDECSubOpReadReply() :
- Message(MSG_OSD_EC_READ_REPLY, HEAD_VERSION, COMPAT_VERSION)
+ MOSDECSubOpReadReply()
+ : MOSDFastDispatchOp(MSG_OSD_EC_READ_REPLY, HEAD_VERSION, COMPAT_VERSION)
{}
virtual void decode_payload() {
#ifndef MOSDECSUBOPWRITE_H
#define MOSDECSUBOPWRITE_H
-#include "msg/Message.h"
-#include "osd/osd_types.h"
+#include "MOSDFastDispatchOp.h"
#include "osd/ECMsgTypes.h"
-class MOSDECSubOpWrite : public Message {
+class MOSDECSubOpWrite : public MOSDFastDispatchOp {
static const int HEAD_VERSION = 1;
static const int COMPAT_VERSION = 1;
int get_cost() const {
return 0;
}
+ epoch_t get_map_epoch() const override {
+ return map_epoch;
+ }
+ spg_t get_spg() const override {
+ return pgid;
+ }
MOSDECSubOpWrite()
- : Message(MSG_OSD_EC_WRITE, HEAD_VERSION, COMPAT_VERSION)
+ : MOSDFastDispatchOp(MSG_OSD_EC_WRITE, HEAD_VERSION, COMPAT_VERSION)
{}
MOSDECSubOpWrite(ECSubWrite &in_op)
- : Message(MSG_OSD_EC_WRITE, HEAD_VERSION, COMPAT_VERSION) {
+ : MOSDFastDispatchOp(MSG_OSD_EC_WRITE, HEAD_VERSION, COMPAT_VERSION) {
op.claim(in_op);
}
#ifndef MOSDECSUBOPWRITEREPLY_H
#define MOSDECSUBOPWRITEREPLY_H
-#include "msg/Message.h"
-#include "osd/osd_types.h"
+#include "MOSDFastDispatchOp.h"
#include "osd/ECMsgTypes.h"
-class MOSDECSubOpWriteReply : public Message {
+class MOSDECSubOpWriteReply : public MOSDFastDispatchOp {
static const int HEAD_VERSION = 1;
static const int COMPAT_VERSION = 1;
int get_cost() const {
return 0;
}
+ epoch_t get_map_epoch() const override {
+ return map_epoch;
+ }
+ spg_t get_spg() const override {
+ return pgid;
+ }
- MOSDECSubOpWriteReply() :
- Message(MSG_OSD_EC_WRITE_REPLY, HEAD_VERSION, COMPAT_VERSION)
+ MOSDECSubOpWriteReply()
+ : MOSDFastDispatchOp(MSG_OSD_EC_WRITE_REPLY, HEAD_VERSION, COMPAT_VERSION)
{}
virtual void decode_payload() {
--- /dev/null
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#ifndef CEPH_MOSDFASTDISPATCHOP_H
+#define CEPH_MOSDFASTDISPATCHOP_H
+
+#include "msg/Message.h"
+#include "osd/osd_types.h"
+
+class MOSDFastDispatchOp : public Message {
+public:
+ virtual epoch_t get_map_epoch() const = 0;
+ virtual spg_t get_spg() const = 0;
+
+ MOSDFastDispatchOp(int t, int version, int compat_version)
+ : Message(t, version, compat_version) {}
+};
+
+#endif
#ifndef CEPH_MOSDOP_H
#define CEPH_MOSDOP_H
-#include "msg/Message.h"
-#include "osd/osd_types.h"
+#include "MOSDFastDispatchOp.h"
#include "include/ceph_features.h"
#include "common/hobject.h"
#include <atomic>
class OSD;
-class MOSDOp : public Message {
+class MOSDOp : public MOSDFastDispatchOp {
static const int HEAD_VERSION = 8;
static const int COMPAT_VERSION = 3;
assert(!partial_decode_needed);
return pgid.pgid;
}
- spg_t get_spg() const {
+ spg_t get_spg() const override {
assert(!partial_decode_needed);
return pgid;
}
assert(!partial_decode_needed);
return pg_t(hobj.get_hash(), pgid.pgid.pool());
}
- epoch_t get_map_epoch() const {
+ epoch_t get_map_epoch() const override {
assert(!partial_decode_needed);
return osdmap_epoch;
}
}
MOSDOp()
- : Message(CEPH_MSG_OSD_OP, HEAD_VERSION, COMPAT_VERSION),
+ : MOSDFastDispatchOp(CEPH_MSG_OSD_OP, HEAD_VERSION, COMPAT_VERSION),
partial_decode_needed(true),
final_decode_needed(true) { }
MOSDOp(int inc, long tid, const hobject_t& ho, spg_t& _pgid,
epoch_t _osdmap_epoch,
int _flags, uint64_t feat)
- : Message(CEPH_MSG_OSD_OP, HEAD_VERSION, COMPAT_VERSION),
+ : MOSDFastDispatchOp(CEPH_MSG_OSD_OP, HEAD_VERSION, COMPAT_VERSION),
client_inc(inc),
osdmap_epoch(_osdmap_epoch), flags(_flags), retry_attempt(-1),
hobj(ho),
#ifndef CEPH_MOSDPGBACKFILL_H
#define CEPH_MOSDPGBACKFILL_H
-#include "msg/Message.h"
-#include "osd/osd_types.h"
+#include "MOSDFastDispatchOp.h"
-class MOSDPGBackfill : public Message {
+class MOSDPGBackfill : public MOSDFastDispatchOp {
static const int HEAD_VERSION = 3;
static const int COMPAT_VERSION = 1;
public:
bool compat_stat_sum;
pg_stat_t stats;
+ epoch_t get_map_epoch() const override {
+ return map_epoch;
+ }
+ spg_t get_spg() const override {
+ return pgid;
+ }
+
virtual void decode_payload() {
bufferlist::iterator p = payload.begin();
::decode(op, p);
::encode(pgid.shard, payload);
}
- MOSDPGBackfill() :
- Message(MSG_OSD_PG_BACKFILL, HEAD_VERSION, COMPAT_VERSION),
- compat_stat_sum(false) {}
+ MOSDPGBackfill()
+ : MOSDFastDispatchOp(MSG_OSD_PG_BACKFILL, HEAD_VERSION, COMPAT_VERSION),
+ compat_stat_sum(false) {}
MOSDPGBackfill(__u32 o, epoch_t e, epoch_t qe, spg_t p)
- : Message(MSG_OSD_PG_BACKFILL, HEAD_VERSION, COMPAT_VERSION),
+ : MOSDFastDispatchOp(MSG_OSD_PG_BACKFILL, HEAD_VERSION, COMPAT_VERSION),
op(o),
map_epoch(e), query_epoch(e),
pgid(p),
#ifndef MOSDPGPULL_H
#define MOSDPGPULL_H
-#include "msg/Message.h"
-#include "osd/osd_types.h"
+#include "MOSDFastDispatchOp.h"
-class MOSDPGPull : public Message {
+class MOSDPGPull : public MOSDFastDispatchOp {
static const int HEAD_VERSION = 2;
static const int COMPAT_VERSION = 1;
vector<PullOp> pulls;
uint64_t cost;
- MOSDPGPull() :
- Message(MSG_OSD_PG_PULL, HEAD_VERSION, COMPAT_VERSION),
- cost(0)
+ epoch_t get_map_epoch() const override {
+ return map_epoch;
+ }
+ spg_t get_spg() const override {
+ return pgid;
+ }
+
+ MOSDPGPull()
+ : MOSDFastDispatchOp(MSG_OSD_PG_PULL, HEAD_VERSION, COMPAT_VERSION),
+ cost(0)
{}
void compute_cost(CephContext *cct) {
#ifndef MOSDPGPUSH_H
#define MOSDPGPUSH_H
-#include "msg/Message.h"
-#include "osd/osd_types.h"
+#include "MOSDFastDispatchOp.h"
-class MOSDPGPush : public Message {
+class MOSDPGPush : public MOSDFastDispatchOp {
static const int HEAD_VERSION = 2;
static const int COMPAT_VERSION = 1;
return cost;
}
+ epoch_t get_map_epoch() const override {
+ return map_epoch;
+ }
+ spg_t get_spg() const override {
+ return pgid;
+ }
+
void set_cost(uint64_t c) {
cost = c;
}
- MOSDPGPush() :
- Message(MSG_OSD_PG_PUSH, HEAD_VERSION, COMPAT_VERSION),
- cost(0)
+ MOSDPGPush()
+ : MOSDFastDispatchOp(MSG_OSD_PG_PUSH, HEAD_VERSION, COMPAT_VERSION),
+ cost(0)
{}
virtual void decode_payload() {
#ifndef MOSDPGPUSHREPLY_H
#define MOSDPGPUSHREPLY_H
-#include "msg/Message.h"
-#include "osd/osd_types.h"
+#include "MOSDFastDispatchOp.h"
-class MOSDPGPushReply : public Message {
+class MOSDPGPushReply : public MOSDFastDispatchOp {
static const int HEAD_VERSION = 2;
static const int COMPAT_VERSION = 1;
vector<PushReplyOp> replies;
uint64_t cost;
- MOSDPGPushReply() :
- Message(MSG_OSD_PG_PUSH_REPLY, HEAD_VERSION, COMPAT_VERSION),
- cost(0)
+ epoch_t get_map_epoch() const override {
+ return map_epoch;
+ }
+ spg_t get_spg() const override {
+ return pgid;
+ }
+
+ MOSDPGPushReply()
+ : MOSDFastDispatchOp(MSG_OSD_PG_PUSH_REPLY, HEAD_VERSION, COMPAT_VERSION),
+ cost(0)
{}
void compute_cost(CephContext *cct) {
#ifndef CEPH_MOSDPGSCAN_H
#define CEPH_MOSDPGSCAN_H
-#include "msg/Message.h"
-#include "osd/osd_types.h"
+#include "MOSDFastDispatchOp.h"
-class MOSDPGScan : public Message {
+class MOSDPGScan : public MOSDFastDispatchOp {
static const int HEAD_VERSION = 2;
static const int COMPAT_VERSION = 1;
spg_t pgid;
hobject_t begin, end;
+ epoch_t get_map_epoch() const override {
+ return map_epoch;
+ }
+ spg_t get_spg() const override {
+ return pgid;
+ }
+
virtual void decode_payload() {
bufferlist::iterator p = payload.begin();
::decode(op, p);
::encode(pgid.shard, payload);
}
- MOSDPGScan() : Message(MSG_OSD_PG_SCAN, HEAD_VERSION, COMPAT_VERSION) {}
+ MOSDPGScan()
+ : MOSDFastDispatchOp(MSG_OSD_PG_SCAN, HEAD_VERSION, COMPAT_VERSION) {}
MOSDPGScan(__u32 o, pg_shard_t from,
epoch_t e, epoch_t qe, spg_t p, hobject_t be, hobject_t en)
- : Message(MSG_OSD_PG_SCAN, HEAD_VERSION, COMPAT_VERSION),
+ : MOSDFastDispatchOp(MSG_OSD_PG_SCAN, HEAD_VERSION, COMPAT_VERSION),
op(o),
map_epoch(e), query_epoch(e),
from(from),
#ifndef CEPH_MOSDPGUPDATELOGMISSING_H
#define CEPH_MOSDPGUPDATELOGMISSING_H
-#include "msg/Message.h"
+#include "MOSDFastDispatchOp.h"
-class MOSDPGUpdateLogMissing : public Message {
+class MOSDPGUpdateLogMissing : public MOSDFastDispatchOp {
static const int HEAD_VERSION = 1;
static const int COMPAT_VERSION = 1;
spg_t get_pgid() const { return pgid; }
epoch_t get_query_epoch() const { return map_epoch; }
ceph_tid_t get_tid() const { return rep_tid; }
+ epoch_t get_map_epoch() const override {
+ return map_epoch;
+ }
+ spg_t get_spg() const override {
+ return pgid;
+ }
- MOSDPGUpdateLogMissing() :
- Message(MSG_OSD_PG_UPDATE_LOG_MISSING, HEAD_VERSION, COMPAT_VERSION) { }
+ MOSDPGUpdateLogMissing()
+ : MOSDFastDispatchOp(MSG_OSD_PG_UPDATE_LOG_MISSING, HEAD_VERSION,
+ COMPAT_VERSION) { }
MOSDPGUpdateLogMissing(
const mempool::osd::list<pg_log_entry_t> &entries,
spg_t pgid,
shard_id_t from,
epoch_t epoch,
ceph_tid_t rep_tid)
- : Message(MSG_OSD_PG_UPDATE_LOG_MISSING, HEAD_VERSION, COMPAT_VERSION),
+ : MOSDFastDispatchOp(MSG_OSD_PG_UPDATE_LOG_MISSING, HEAD_VERSION,
+ COMPAT_VERSION),
map_epoch(epoch),
pgid(pgid),
from(from),
#ifndef CEPH_MOSDPGUPDATELOGMISSINGREPLY_H
#define CEPH_MOSDPGUPDATELOGMISSINGREPLY_H
-#include "msg/Message.h"
+#include "MOSDFastDispatchOp.h"
-class MOSDPGUpdateLogMissingReply : public Message {
+class MOSDPGUpdateLogMissingReply : public MOSDFastDispatchOp {
static const int HEAD_VERSION = 1;
static const int COMPAT_VERSION = 1;
pg_shard_t get_from() const {
return pg_shard_t(get_source().num(), from);
}
+ epoch_t get_map_epoch() const override {
+ return map_epoch;
+ }
+ spg_t get_spg() const override {
+ return pgid;
+ }
- MOSDPGUpdateLogMissingReply() :
- Message(
+ MOSDPGUpdateLogMissingReply()
+ : MOSDFastDispatchOp(
MSG_OSD_PG_UPDATE_LOG_MISSING_REPLY,
HEAD_VERSION,
COMPAT_VERSION)
shard_id_t from,
epoch_t epoch,
ceph_tid_t rep_tid)
- : Message(
+ : MOSDFastDispatchOp(
MSG_OSD_PG_UPDATE_LOG_MISSING_REPLY,
HEAD_VERSION,
COMPAT_VERSION),
#ifndef CEPH_MOSDREPOP_H
#define CEPH_MOSDREPOP_H
-#include "msg/Message.h"
-#include "osd/osd_types.h"
+#include "MOSDFastDispatchOp.h"
/*
* OSD sub op - for internal ops on pobjects between primary and replicas(/stripes/whatever)
*/
-class MOSDRepOp : public Message {
+class MOSDRepOp : public MOSDFastDispatchOp {
static const int HEAD_VERSION = 1;
static const int COMPAT_VERSION = 1;
/// non-empty if this transaction involves a hit_set history update
boost::optional<pg_hit_set_history_t> updated_hit_set_history;
+ epoch_t get_map_epoch() const override {
+ return map_epoch;
+ }
+ spg_t get_spg() const override {
+ return pgid;
+ }
+
int get_cost() const {
return data.length();
}
}
MOSDRepOp()
- : Message(MSG_OSD_REPOP, HEAD_VERSION, COMPAT_VERSION),
+ : MOSDFastDispatchOp(MSG_OSD_REPOP, HEAD_VERSION, COMPAT_VERSION),
map_epoch(0),
final_decode_needed(true), acks_wanted (0) {}
MOSDRepOp(osd_reqid_t r, pg_shard_t from,
spg_t p, const hobject_t& po, int aw,
epoch_t mape, ceph_tid_t rtid, eversion_t v)
- : Message(MSG_OSD_REPOP, HEAD_VERSION, COMPAT_VERSION),
+ : MOSDFastDispatchOp(MSG_OSD_REPOP, HEAD_VERSION, COMPAT_VERSION),
map_epoch(mape),
reqid(r),
pgid(p),
#ifndef CEPH_MOSDREPOPREPLY_H
#define CEPH_MOSDREPOPREPLY_H
-#include "msg/Message.h"
+#include "MOSDFastDispatchOp.h"
#include "os/ObjectStore.h"
*
*/
-class MOSDRepOpReply : public Message {
+class MOSDRepOpReply : public MOSDFastDispatchOp {
static const int HEAD_VERSION = 1;
static const int COMPAT_VERSION = 1;
public:
// Decoding flags. Decoding is only needed for messages catched by pipe reader.
bool final_decode_needed;
+ epoch_t get_map_epoch() const override {
+ return map_epoch;
+ }
+ spg_t get_spg() const override {
+ return pgid;
+ }
+
virtual void decode_payload() {
p = payload.begin();
::decode(map_epoch, p);
public:
MOSDRepOpReply(
MOSDRepOp *req, pg_shard_t from, int result_, epoch_t e, int at) :
- Message(MSG_OSD_REPOPREPLY, HEAD_VERSION, COMPAT_VERSION),
+ MOSDFastDispatchOp(MSG_OSD_REPOPREPLY, HEAD_VERSION, COMPAT_VERSION),
map_epoch(e),
reqid(req->reqid),
from(from),
set_tid(req->get_tid());
}
MOSDRepOpReply()
- : Message(MSG_OSD_REPOPREPLY), map_epoch(0),
+ : MOSDFastDispatchOp(MSG_OSD_REPOPREPLY, HEAD_VERSION, COMPAT_VERSION),
+ map_epoch(0),
ack_type(0), result(0),
final_decode_needed(true) {}
private:
#ifndef CEPH_MOSDREPSCRUB_H
#define CEPH_MOSDREPSCRUB_H
-#include "msg/Message.h"
+#include "MOSDFastDispatchOp.h"
/*
* instruct an OSD initiate a replica scrub on a specific PG
*/
-struct MOSDRepScrub : public Message {
+struct MOSDRepScrub : public MOSDFastDispatchOp {
static const int HEAD_VERSION = 6;
static const int COMPAT_VERSION = 2;
bool deep; // true if scrub should be deep
uint32_t seed; // seed value for digest calculation
+ epoch_t get_map_epoch() const override {
+ return map_epoch;
+ }
+ spg_t get_spg() const override {
+ return pgid;
+ }
+
MOSDRepScrub()
- : Message(MSG_OSD_REP_SCRUB, HEAD_VERSION, COMPAT_VERSION),
+ : MOSDFastDispatchOp(MSG_OSD_REP_SCRUB, HEAD_VERSION, COMPAT_VERSION),
chunky(false),
deep(false),
seed(0) { }
MOSDRepScrub(spg_t pgid, eversion_t scrub_to, epoch_t map_epoch,
hobject_t start, hobject_t end, bool deep, uint32_t seed)
- : Message(MSG_OSD_REP_SCRUB, HEAD_VERSION, COMPAT_VERSION),
+ : MOSDFastDispatchOp(MSG_OSD_REP_SCRUB, HEAD_VERSION, COMPAT_VERSION),
pgid(pgid),
scrub_to(scrub_to),
map_epoch(map_epoch),
#ifndef CEPH_MOSDSUBOP_H
#define CEPH_MOSDSUBOP_H
-#include "msg/Message.h"
-#include "osd/osd_types.h"
+#include "MOSDFastDispatchOp.h"
#include "include/ceph_features.h"
* OSD sub op - for internal ops on pobjects between primary and replicas(/stripes/whatever)
*/
-class MOSDSubOp : public Message {
+class MOSDSubOp : public MOSDFastDispatchOp {
static const int HEAD_VERSION = 12;
static const int COMPAT_VERSION = 7;
/// non-empty if this transaction involves a hit_set history update
boost::optional<pg_hit_set_history_t> updated_hit_set_history;
+ epoch_t get_map_epoch() const override {
+ return map_epoch;
+ }
+ spg_t get_spg() const override {
+ return pgid;
+ }
+
int get_cost() const {
if (ops.size() == 1 && ops[0].op.op == CEPH_OSD_OP_PULL)
return ops[0].op.extent.length;
}
MOSDSubOp()
- : Message(MSG_OSD_SUBOP, HEAD_VERSION, COMPAT_VERSION) { }
+ : MOSDFastDispatchOp(MSG_OSD_SUBOP, HEAD_VERSION, COMPAT_VERSION) { }
MOSDSubOp(osd_reqid_t r, pg_shard_t from,
spg_t p, const hobject_t& po, int aw,
epoch_t mape, ceph_tid_t rtid, eversion_t v)
- : Message(MSG_OSD_SUBOP, HEAD_VERSION, COMPAT_VERSION),
+ : MOSDFastDispatchOp(MSG_OSD_SUBOP, HEAD_VERSION, COMPAT_VERSION),
map_epoch(mape),
reqid(r),
from(from),
#ifndef CEPH_MOSDSUBOPREPLY_H
#define CEPH_MOSDSUBOPREPLY_H
-#include "msg/Message.h"
+#include "MOSDFastDispatchOp.h"
#include "MOSDSubOp.h"
#include "os/ObjectStore.h"
*
*/
-class MOSDSubOpReply : public Message {
+class MOSDSubOpReply : public MOSDFastDispatchOp {
static const int HEAD_VERSION = 2;
static const int COMPAT_VERSION = 1;
public:
map<string,bufferptr> attrset;
+ epoch_t get_map_epoch() const override {
+ return map_epoch;
+ }
+ spg_t get_spg() const override {
+ return pgid;
+ }
+
virtual void decode_payload() {
bufferlist::iterator p = payload.begin();
::decode(map_epoch, p);
public:
MOSDSubOpReply(
- MOSDSubOp *req, pg_shard_t from, int result_, epoch_t e, int at) :
- Message(MSG_OSD_SUBOPREPLY, HEAD_VERSION, COMPAT_VERSION),
- map_epoch(e),
- reqid(req->reqid),
- from(from),
- pgid(req->pgid.pgid, req->from.shard),
- poid(req->poid),
- ops(req->ops),
- ack_type(at),
- result(result_) {
+ MOSDSubOp *req, pg_shard_t from, int result_, epoch_t e, int at)
+ : MOSDFastDispatchOp(MSG_OSD_SUBOPREPLY, HEAD_VERSION, COMPAT_VERSION),
+ map_epoch(e),
+ reqid(req->reqid),
+ from(from),
+ pgid(req->pgid.pgid, req->from.shard),
+ poid(req->poid),
+ ops(req->ops),
+ ack_type(at),
+ result(result_) {
memset(&peer_stat, 0, sizeof(peer_stat));
set_tid(req->get_tid());
}
- MOSDSubOpReply() : Message(MSG_OSD_SUBOPREPLY) {}
+ MOSDSubOpReply()
+ : MOSDFastDispatchOp(MSG_OSD_SUBOPREPLY, HEAD_VERSION, COMPAT_VERSION) {}
private:
~MOSDSubOpReply() {}