From 0f31388eb2bb68c09ab270f871b421a9c368af97 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Sun, 10 Aug 2014 17:51:08 -0700 Subject: [PATCH] messages/MWatchNotify: include an error code in the message Document the fields, while we are here. Signed-off-by: Sage Weil (cherry picked from commit 7c7bf5fee7be397ef141b947f532a2a0b3567b42) --- src/messages/MWatchNotify.h | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/src/messages/MWatchNotify.h b/src/messages/MWatchNotify.h index 66632f72002b0..bc6bacb711ebc 100644 --- a/src/messages/MWatchNotify.h +++ b/src/messages/MWatchNotify.h @@ -20,16 +20,27 @@ class MWatchNotify : public Message { + static const int HEAD_VERSION = 2; + static const int COMPAT_VERSION = 1; + public: - uint64_t cookie; - uint64_t ver; - uint64_t notify_id; - uint8_t opcode; - bufferlist bl; + uint64_t cookie; ///< client unique id for this watch or notify + uint64_t ver; ///< unused + uint64_t notify_id; ///< osd unique id for a notify notification + uint8_t opcode; ///< always WATCH_NOTIFY + bufferlist bl; ///< notify payload (osd->client) + int32_t return_code; ///< notify result (osd->client) - MWatchNotify() : Message(CEPH_MSG_WATCH_NOTIFY) { } - MWatchNotify(uint64_t c, uint64_t v, uint64_t i, uint8_t o, bufferlist b) : Message(CEPH_MSG_WATCH_NOTIFY), - cookie(c), ver(v), notify_id(i), opcode(o), bl(b) { } + MWatchNotify() + : Message(CEPH_MSG_WATCH_NOTIFY, HEAD_VERSION, COMPAT_VERSION) { } + MWatchNotify(uint64_t c, uint64_t v, uint64_t i, uint8_t o, bufferlist b) + : Message(CEPH_MSG_WATCH_NOTIFY, HEAD_VERSION, COMPAT_VERSION), + cookie(c), + ver(v), + notify_id(i), + opcode(o), + bl(b), + return_code(0) { } private: ~MWatchNotify() {} @@ -44,6 +55,10 @@ public: ::decode(notify_id, p); if (msg_ver >= 1) ::decode(bl, p); + if (header.version >= 2) + ::decode(return_code, p); + else + return_code = 0; } void encode_payload(uint64_t features) { uint8_t msg_ver = 1; @@ -53,11 +68,12 @@ public: ::encode(ver, payload); ::encode(notify_id, payload); ::encode(bl, payload); + ::encode(return_code, payload); } const char *get_type_name() const { return "watch-notify"; } void print(ostream& out) const { - out << "watch-notify(c=" << cookie << " v=" << ver << " i=" << notify_id << " opcode=" << (int)opcode << ")"; + out << "watch-notify(c=" << cookie << " v=" << ver << " i=" << notify_id << " opcode=" << (int)opcode << " r = " << return_code << ")"; } }; -- 2.39.5