From 2361e9c790306e789393323ef349d8b4a20bc70d Mon Sep 17 00:00:00 2001 From: Taewoong Kim Date: Mon, 21 Nov 2016 21:39:48 +0900 Subject: [PATCH] messages: Change messages for sending and receiving QoS info. Signed-off-by: Taewoong Kim --- src/common/mClockCommon.h | 15 +++++++++++++++ src/include/ceph_features.h | 2 ++ src/messages/MOSDOp.h | 21 ++++++++++++++++----- src/messages/MOSDOpReply.h | 21 +++++++++++++++++---- 4 files changed, 50 insertions(+), 9 deletions(-) diff --git a/src/common/mClockCommon.h b/src/common/mClockCommon.h index 4a8e41749dd..f8bf4b37243 100644 --- a/src/common/mClockCommon.h +++ b/src/common/mClockCommon.h @@ -24,3 +24,18 @@ namespace ceph { namespace dmc = crimson::dmclock; } + +WRITE_RAW_ENCODER(dmc::ReqParams) + +inline void encode(const dmc::PhaseType &phase, bufferlist& bl, + uint64_t features=0) +{ + ::encode(static_cast(phase), bl); +} + +inline void decode(dmc::PhaseType &phase, bufferlist::iterator& p) +{ + uint8_t int_phase; + ::decode((uint8_t&)int_phase, p); + phase = static_cast(int_phase); +} diff --git a/src/include/ceph_features.h b/src/include/ceph_features.h index 1ab26f5342e..7e265bb6008 100644 --- a/src/include/ceph_features.h +++ b/src/include/ceph_features.h @@ -91,6 +91,7 @@ DEFINE_CEPH_FEATURE(15, 1, MONENC) DEFINE_CEPH_FEATURE_RETIRED(16, 1, QUERY_T, JEWEL, LUMINOUS) DEFINE_CEPH_FEATURE(16, 3, SERVER_O) DEFINE_CEPH_FEATURE_RETIRED(17, 1, INDEP_PG_MAP, JEWEL, LUMINOUS) +DEFINE_CEPH_FEATURE(17, 2, QOS_DMC) DEFINE_CEPH_FEATURE(18, 1, CRUSH_TUNABLES) DEFINE_CEPH_FEATURE_RETIRED(19, 1, CHUNKY_SCRUB, JEWEL, LUMINOUS) @@ -186,6 +187,7 @@ DEFINE_CEPH_FEATURE_DEPRECATED(63, 1, RESERVED_BROKEN, LUMINOUS) // client-facin CEPH_FEATURE_OSDREPLYMUX | \ CEPH_FEATURE_OSDENC | \ CEPH_FEATURE_MONENC | \ + CEPH_FEATURE_QOS_DMC | \ CEPH_FEATURE_CRUSH_TUNABLES | \ CEPH_FEATURE_MSG_AUTH | \ CEPH_FEATURE_CRUSH_TUNABLES2 | \ diff --git a/src/messages/MOSDOp.h b/src/messages/MOSDOp.h index e1a9b7f5243..1c16f2a636c 100644 --- a/src/messages/MOSDOp.h +++ b/src/messages/MOSDOp.h @@ -34,7 +34,7 @@ class OSD; class MOSDOp : public MOSDFastDispatchOp { - static const int HEAD_VERSION = 8; + static const int HEAD_VERSION = 9; static const int COMPAT_VERSION = 3; private: @@ -364,14 +364,23 @@ struct ceph_osd_request_head { ::encode(retry_attempt, payload); ::encode(features, payload); } else { - // latest v8 encoding with hobject_t hash separate from pgid, no - // reassert version - header.version = HEAD_VERSION; + // v9 encoding for dmclock use, otherwise v8. + // v8 encoding with hobject_t hash separate from pgid, no + // reassert version. + if (HAVE_FEATURE(features, QOS_DMC)) { + header.version = HEAD_VERSION; + } else { + header.version = 8; + } + ::encode(pgid, payload); ::encode(hobj.get_hash(), payload); ::encode(osdmap_epoch, payload); ::encode(flags, payload); ::encode(reqid, payload); + if (header.version >= 9) { + ::encode(qos_params, payload); + } encode_trace(payload, features); // -- above decoded up front; below decoded post-dispatch thread -- @@ -400,7 +409,7 @@ struct ceph_osd_request_head { p = payload.begin(); // Always keep here the newest version of decoding order/rule - if (header.version == HEAD_VERSION) { + if (header.version >= 8) { ::decode(pgid, p); // actual pgid uint32_t hash; ::decode(hash, p); // raw hash value @@ -408,6 +417,8 @@ struct ceph_osd_request_head { ::decode(osdmap_epoch, p); ::decode(flags, p); ::decode(reqid, p); + if (header.version >= 9) + ::decode(qos_params, p); decode_trace(p); } else if (header.version == 7) { ::decode(pgid.pgid, p); // raw pgid diff --git a/src/messages/MOSDOpReply.h b/src/messages/MOSDOpReply.h index 69f0856e097..a1f773194f4 100644 --- a/src/messages/MOSDOpReply.h +++ b/src/messages/MOSDOpReply.h @@ -21,6 +21,7 @@ #include "MOSDOp.h" #include "os/ObjectStore.h" #include "common/errno.h" +#include "common/mClockCommon.h" /* * OSD op reply @@ -32,7 +33,7 @@ class MOSDOpReply : public Message { - static const int HEAD_VERSION = 8; + static const int HEAD_VERSION = 9; static const int COMPAT_VERSION = 2; object_t oid; @@ -48,6 +49,7 @@ class MOSDOpReply : public Message { int32_t retry_attempt = -1; bool do_redirect; request_redirect_t redirect; + dmc::PhaseType qos_resp; public: const object_t& get_oid() const { return oid; } @@ -94,6 +96,8 @@ public: void set_redirect(const request_redirect_t& redir) { redirect = redir; } const request_redirect_t& get_redirect() const { return redirect; } bool is_redirect_reply() const { return do_redirect; } + void set_qos_resp(const dmc::PhaseType qresp) { qos_resp = qresp; } + dmc::PhaseType get_qos_resp() const { return qos_resp; } void add_flags(int f) { flags |= f; } @@ -131,11 +135,11 @@ public: bdata_encode(false) { do_redirect = false; } - MOSDOpReply(const MOSDOp *req, int r, epoch_t e, int acktype, - bool ignore_out_data) + MOSDOpReply(const MOSDOp *req, int r, epoch_t e, int acktype, bool ignore_out_data, + dmc::PhaseType qresp = dmc::PhaseType::reservation) : Message(CEPH_MSG_OSD_OPREPLY, HEAD_VERSION, COMPAT_VERSION), oid(req->hobj.oid), pgid(req->pgid.pgid), ops(req->ops), - bdata_encode(false) { + bdata_encode(false), qos_resp(qresp) { set_tid(req->get_tid()); result = r; @@ -209,6 +213,11 @@ public: if (do_redirect) { ::encode(redirect, payload); } + if ((features & CEPH_FEATURE_QOS_DMC) == 0) { + header.version = 8; + } else { + ::encode(qos_resp, payload); + } } encode_trace(payload, features); } @@ -242,6 +251,7 @@ public: ::decode(do_redirect, p); if (do_redirect) ::decode(redirect, p); + ::decode(qos_resp, p); decode_trace(p); } else if (header.version < 2) { ceph_osd_reply_head head; @@ -303,6 +313,9 @@ public: } } if (header.version >= 8) { + if (header.version >= 9) { + ::decode(qos_resp, p); + } decode_trace(p); } } -- 2.47.3