From 89e033c75b09edc63bc6da24a6b18b2bc5aea1cc Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 7 Nov 2014 15:35:24 -0800 Subject: [PATCH] clean up CEPH_WATCH_EVENT_* namespace, and make COMPLETE distinct Use a proper prefix and make a separate event for the notify completion message. Signed-off-by: Sage Weil --- src/common/ceph_strings.cc | 9 +++++++++ src/include/ceph_fs.h | 5 +++-- src/librados/RadosClient.cc | 2 +- src/messages/MWatchNotify.h | 2 +- src/osd/Watch.cc | 4 ++-- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/common/ceph_strings.cc b/src/common/ceph_strings.cc index a0651fad32230..247a3f079a6a2 100644 --- a/src/common/ceph_strings.cc +++ b/src/common/ceph_strings.cc @@ -180,6 +180,15 @@ const char *ceph_snap_op_name(int o) return "???"; } +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"; + } + return "???"; +} + const char *ceph_pool_op_name(int op) { switch (op) { diff --git a/src/include/ceph_fs.h b/src/include/ceph_fs.h index 70a3958c7e558..5eebdd8fddb83 100644 --- a/src/include/ceph_fs.h +++ b/src/include/ceph_fs.h @@ -130,10 +130,11 @@ struct ceph_dir_layout { /* watch-notify operations */ enum { - WATCH_NOTIFY = 1, /* notifying watcher */ - WATCH_NOTIFY_COMPLETE = 2, /* notifier notified when done */ + CEPH_WATCH_EVENT_NOTIFY = 1, /* notifying watcher */ + CEPH_WATCH_EVENT_NOTIFY_COMPLETE = 2, /* notifier notified when done */ }; +const char *ceph_watch_event_name(int o); /* pool operations */ enum { diff --git a/src/librados/RadosClient.cc b/src/librados/RadosClient.cc index ba4f5a89b1fd3..f5a4e161d9350 100644 --- a/src/librados/RadosClient.cc +++ b/src/librados/RadosClient.cc @@ -775,7 +775,7 @@ void librados::RadosClient::do_watch_notify(MWatchNotify *m) assert(!!wc->watch_ctx ^ !!wc->watch_ctx2); // only one is defined lock.Unlock(); if (wc->watch_ctx) { - wc->watch_ctx->notify(WATCH_NOTIFY, m->ver, m->bl); + wc->watch_ctx->notify(CEPH_WATCH_EVENT_NOTIFY, m->ver, m->bl); // send ACK back to the OSD bufferlist empty; wc->io_ctx_impl->notify_ack(wc->oid, m->notify_id, m->cookie, empty); diff --git a/src/messages/MWatchNotify.h b/src/messages/MWatchNotify.h index aa82140739f8e..af426805fbb50 100644 --- a/src/messages/MWatchNotify.h +++ b/src/messages/MWatchNotify.h @@ -27,7 +27,7 @@ class MWatchNotify : public Message { 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 + uint8_t opcode; ///< CEPH_WATCH_EVENT_* bufferlist bl; ///< notify payload (osd->client) int32_t return_code; ///< notify result (osd->client) uint64_t notifier_gid; ///< who sent the notify diff --git a/src/osd/Watch.cc b/src/osd/Watch.cc index 4e07d6e66a9cf..91ed6d84f0123 100644 --- a/src/osd/Watch.cc +++ b/src/osd/Watch.cc @@ -189,7 +189,7 @@ void Notify::maybe_complete_notify() ::encode(notify_replies, bl); bufferlist empty; MWatchNotify *reply(new MWatchNotify(cookie, version, notify_id, - WATCH_NOTIFY, empty)); + CEPH_WATCH_EVENT_NOTIFY_COMPLETE, empty)); reply->notifier_gid = client_gid; reply->set_data(bl); if (timed_out) @@ -430,7 +430,7 @@ void Watch::send_notify(NotifyRef notif) dout(10) << "send_notify" << dendl; MWatchNotify *notify_msg = new MWatchNotify( cookie, notif->version, notif->notify_id, - WATCH_NOTIFY, notif->payload); + CEPH_WATCH_EVENT_NOTIFY, notif->payload); notify_msg->notifier_gid = notif->client_gid; osd->send_message_osd_client(notify_msg, conn.get()); } -- 2.39.5