From 7f00b722efce71189d622ee14ec8931cb5bdaa16 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 7 Nov 2014 16:36:43 -0800 Subject: [PATCH] osd/Watch: inform watchers when they cause a notify timeout If a watcher doesn't ack in time, let them know that they triggered a notify failure. Signed-off-by: Sage Weil --- src/common/ceph_strings.cc | 1 + src/include/ceph_fs.h | 1 + src/osd/Watch.cc | 17 +++++++++++++++-- src/osd/Watch.h | 3 +++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/common/ceph_strings.cc b/src/common/ceph_strings.cc index 247a3f079a6a2..0aed7673c76aa 100644 --- a/src/common/ceph_strings.cc +++ b/src/common/ceph_strings.cc @@ -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 "???"; } diff --git a/src/include/ceph_fs.h b/src/include/ceph_fs.h index 5eebdd8fddb83..92bbb72360403 100644 --- a/src/include/ceph_fs.h +++ b/src/include/ceph_fs.h @@ -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); diff --git a/src/osd/Watch.cc b/src/osd/Watch.cc index 9ca852a2621de..51afac16cee0e 100644 --- a/src/osd/Watch.cc +++ b/src/osd/Watch.cc @@ -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::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) diff --git a/src/osd/Watch.h b/src/osd/Watch.h index 7eb42e13c6de3..2e199c5535ba0 100644 --- a/src/osd/Watch.h +++ b/src/osd/Watch.h @@ -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(); -- 2.39.5