]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
messages/MWatchNotify: include an error code in the message 3944/head
authorSage Weil <sage@redhat.com>
Mon, 11 Aug 2014 00:51:08 +0000 (17:51 -0700)
committerLoic Dachary <ldachary@redhat.com>
Wed, 11 Mar 2015 00:49:24 +0000 (01:49 +0100)
Document the fields, while we are here.

Signed-off-by: Sage Weil <sage@redhat.com>
(cherry picked from commit 7c7bf5fee7be397ef141b947f532a2a0b3567b42)

src/messages/MWatchNotify.h

index 66632f72002b0c5da3eaa7217ccc2ba0a4c5bbcb..bc6bacb711ebc4eb35ccaddc2f6625a91479d55d 100644 (file)
 
 
 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 << ")";
   }
 };