From: Sage Weil Date: Thu, 13 Nov 2014 21:01:44 +0000 (-0800) Subject: osd: send watch DISCONNECT to client when a watch is removed X-Git-Tag: v0.91~114 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=300131eaab7ebdc9e2400b66ea641230417a3044;p=ceph.git osd: send watch DISCONNECT to client when a watch is removed 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 --- diff --git a/src/common/ceph_strings.cc b/src/common/ceph_strings.cc index 0aed7673c76..02359b7b090 100644 --- a/src/common/ceph_strings.cc +++ b/src/common/ceph_strings.cc @@ -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 "???"; } diff --git a/src/include/ceph_fs.h b/src/include/ceph_fs.h index 92bbb723604..6bca7b2d1e1 100644 --- a/src/include/ceph_fs.h +++ b/src/include/ceph_fs.h @@ -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); diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 2b8c8825cea..1ddd738bef1 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -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(); diff --git a/src/osd/Watch.cc b/src/osd/Watch.cc index 36a8d09e443..33e39a85129 100644 --- a/src/osd/Watch.cc +++ b/src/osd/Watch.cc @@ -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; diff --git a/src/osd/Watch.h b/src/osd/Watch.h index 7176af628a2..793229a703a 100644 --- a/src/osd/Watch.h +++ b/src/osd/Watch.h @@ -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();