]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/Watch: inform watchers when they cause a notify timeout
authorSage Weil <sage@redhat.com>
Sat, 8 Nov 2014 00:36:43 +0000 (16:36 -0800)
committerSage Weil <sage@redhat.com>
Thu, 4 Dec 2014 18:32:38 +0000 (10:32 -0800)
If a watcher doesn't ack in time, let them know that they triggered a
notify failure.

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

index 247a3f079a6a209367812e06d91aa18311bbd550..0aed7673c76aab854f40e7b23525e3cbd4cf9ae1 100644 (file)
@@ -185,6 +185,7 @@ const char *ceph_watch_event_name(int e)
        switch (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";
        }
        return "???";
 }
index 5eebdd8fddb83fc8f23bb0eb113cc22ff00f5635..92bbb7236040310276b067afb36bdcef44560e48 100644 (file)
@@ -132,6 +132,7 @@ struct ceph_dir_layout {
 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 */
 };
 
 const char *ceph_watch_event_name(int o);
index 9ca852a2621deba37693fec75007a1a3090ae3ce..51afac16cee0e6ab6cc0cf7ad1fd892e3a57e6fb 100644 (file)
@@ -188,8 +188,12 @@ void Notify::maybe_complete_notify()
     reply->set_data(bl);
     if (timed_out)
       reply->return_code = -ETIMEDOUT;
-    osd->send_message_osd_client(reply, client.get());
+    client->send_message(reply);
     unregister_cb();
+
+    for (set<WatchRef>::iterator p = watchers.begin(); p != watchers.end(); ++p) {
+      (*p)->send_failed_notify(this);
+    }
     complete = true;
   }
 }
@@ -425,7 +429,16 @@ void Watch::send_notify(NotifyRef notif)
     cookie, notif->version, notif->notify_id,
     CEPH_WATCH_EVENT_NOTIFY, notif->payload);
   notify_msg->notifier_gid = notif->client_gid;
-  osd->send_message_osd_client(notify_msg, conn.get());
+  conn->send_message(notify_msg);
+}
+
+void Watch::send_failed_notify(Notify *notif)
+{
+  bufferlist empty;
+  MWatchNotify *reply(new MWatchNotify(cookie, notif->version, notif->notify_id,
+                                      CEPH_WATCH_EVENT_FAILED_NOTIFY, empty));
+  reply->notifier_gid = notif->client_gid;
+  conn->send_message(reply);
 }
 
 void Watch::notify_ack(uint64_t notify_id, bufferlist& reply_bl)
index 7eb42e13c6de38804039748093815fd57ced62ad..2e199c5535ba06477ae42468aa6c20ce9b0bf8de 100644 (file)
@@ -190,6 +190,9 @@ public:
   /// Unregisters the timeout callback
   void unregister_cb();
 
+  /// send a failed notify message
+  void send_failed_notify(Notify *notif);
+
   /// NOTE: must be called with pg lock held
   ~Watch();