]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: send watch DISCONNECT to client when a watch is removed
authorSage Weil <sage@redhat.com>
Thu, 13 Nov 2014 21:01:44 +0000 (13:01 -0800)
committerSage Weil <sage@redhat.com>
Thu, 4 Dec 2014 18:32:39 +0000 (10:32 -0800)
This is an explicit notification to the client that a watch is no longer
valid and needs to be re-registered.

Signed-off-by: Sage Weil <sage@redhat.com>
src/common/ceph_strings.cc
src/include/ceph_fs.h
src/osd/ReplicatedPG.cc
src/osd/Watch.cc
src/osd/Watch.h

index 0aed7673c76aab854f40e7b23525e3cbd4cf9ae1..02359b7b0905f7ad9f6fd0d231ca07b46ef39f78 100644 (file)
@@ -186,6 +186,7 @@ const char *ceph_watch_event_name(int e)
        case CEPH_WATCH_EVENT_NOTIFY: return "notify";
        case CEPH_WATCH_EVENT_NOTIFY_COMPLETE: return "notify_complete";
        case CEPH_WATCH_EVENT_FAILED_NOTIFY: return "failed_notify";
+       case CEPH_WATCH_EVENT_DISCONNECT: return "disconnect";
        }
        return "???";
 }
index 92bbb7236040310276b067afb36bdcef44560e48..6bca7b2d1e191d8a2167b3677afec5d60d8a1463 100644 (file)
@@ -133,6 +133,7 @@ enum {
        CEPH_WATCH_EVENT_NOTIFY           = 1, /* notifying watcher */
        CEPH_WATCH_EVENT_NOTIFY_COMPLETE  = 2, /* notifier notified when done */
        CEPH_WATCH_EVENT_FAILED_NOTIFY    = 3, /* we made a notify time out */
+       CEPH_WATCH_EVENT_DISCONNECT       = 4, /* we were disconnected */
 };
 
 const char *ceph_watch_event_name(int o);
index 2b8c8825ceaef7214d55659c27cfaae997bd9f1b..1ddd738bef1b330acf22ffa169b6ef54d1f922a1 100644 (file)
@@ -7433,6 +7433,8 @@ void ReplicatedPG::handle_watch_timeout(WatchRef watch)
     return;
   }
 
+  watch->send_disconnect();
+
   obc->watchers.erase(make_pair(watch->get_cookie(), watch->get_entity()));
   obc->obs.oi.watchers.erase(make_pair(watch->get_cookie(), watch->get_entity()));
   watch->remove();
index 36a8d09e443b64935e4b09395068e935e5ccd016..33e39a85129493a74b7d123ec0cbbdeb9937d968 100644 (file)
@@ -471,6 +471,16 @@ void Watch::send_failed_notify(Notify *notif)
   conn->send_message(reply);
 }
 
+void Watch::send_disconnect()
+{
+  if (!conn)
+    return;
+  bufferlist empty;
+  MWatchNotify *reply(new MWatchNotify(cookie, 0, 0,
+                                      CEPH_WATCH_EVENT_DISCONNECT, empty));
+  conn->send_message(reply);
+}
+
 void Watch::notify_ack(uint64_t notify_id, bufferlist& reply_bl)
 {
   dout(10) << "notify_ack" << dendl;
index 7176af628a2c67445056189c21b107970aebbcb3..793229a703a10aa96de5e5879bf25c58e5e5b474 100644 (file)
@@ -202,6 +202,9 @@ public:
   /// send a failed notify message
   void send_failed_notify(Notify *notif);
 
+  /// send a disconnect notice to the client
+  void send_disconnect();
+
   /// NOTE: must be called with pg lock held
   ~Watch();