From: Sage Weil Date: Fri, 14 Nov 2014 21:35:05 +0000 (-0800) Subject: librados: use Objecter's linger_id as the cookie X-Git-Tag: v0.91~98 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8ec0af473e1f0839b757ae9dfc7d198937729ae9;p=ceph.git librados: use Objecter's linger_id as the cookie Signed-off-by: Sage Weil --- diff --git a/src/librados/IoCtxImpl.cc b/src/librados/IoCtxImpl.cc index c68ab7e594b..08d71d049cd 100644 --- a/src/librados/IoCtxImpl.cc +++ b/src/librados/IoCtxImpl.cc @@ -1050,8 +1050,8 @@ int librados::IoCtxImpl::watch(const object_t& oid, WatchNotifyInfo *wc = new WatchNotifyInfo(this, oid); wc->watch_ctx = ctx; wc->watch_ctx2 = ctx2; - wc->linger_op = objecter->linger_register(oid, oloc, 0); - client->register_watch_notify_callback(wc, cookie); + wc->linger_op = objecter->linger_register(oid, oloc, 0, cookie); + client->register_watch_notify_callback(wc, *cookie); prepare_assert_ops(&wr); wr.watch(*cookie, CEPH_OSD_WATCH_OP_WATCH); bufferlist bl; @@ -1159,8 +1159,8 @@ int librados::IoCtxImpl::notify(const object_t& oid, bufferlist& bl, // Acquire cookie uint64_t cookie; - wc->linger_op = objecter->linger_register(oid, oloc, 0); - client->register_watch_notify_callback(wc, &cookie); + wc->linger_op = objecter->linger_register(oid, oloc, 0, &cookie); + client->register_watch_notify_callback(wc, cookie); uint32_t prot_ver = 1; uint32_t timeout = notify_timeout; if (timeout_ms) diff --git a/src/librados/RadosClient.cc b/src/librados/RadosClient.cc index 81fa7701d4b..c2e572e436c 100644 --- a/src/librados/RadosClient.cc +++ b/src/librados/RadosClient.cc @@ -78,8 +78,7 @@ librados::RadosClient::RadosClient(CephContext *cct_) timer(cct, lock), refcnt(1), log_last_version(0), log_cb(NULL), log_cb_arg(NULL), - finisher(cct), - max_watch_notify_cookie(0) + finisher(cct) { } @@ -645,10 +644,10 @@ void librados::RadosClient::blacklist_self(bool set) { void librados::RadosClient::register_watch_notify_callback( WatchNotifyInfo *wc, - uint64_t *cookie) + uint64_t cookie) { assert(lock.is_locked_by_me()); - wc->cookie = *cookie = ++max_watch_notify_cookie; + wc->cookie = cookie; ldout(cct,10) << __func__ << " cookie " << wc->cookie << dendl; watch_notify_info[wc->cookie] = wc; } diff --git a/src/librados/RadosClient.h b/src/librados/RadosClient.h index 3e57ae4f9fb..299ffa288ed 100644 --- a/src/librados/RadosClient.h +++ b/src/librados/RadosClient.h @@ -109,11 +109,10 @@ public: int pool_delete_async(const char *name, PoolAsyncCompletionImpl *c); // watch/notify - uint64_t max_watch_notify_cookie; map watch_notify_info; void register_watch_notify_callback(librados::WatchNotifyInfo *wc, - uint64_t *cookie); + uint64_t cookie); int unregister_watch_notify_callback(uint64_t cookie, object_t *poid); int watch_check(uint64_t cookie); void handle_watch_notify(MWatchNotify *m); diff --git a/src/osdc/Objecter.cc b/src/osdc/Objecter.cc index a4a33b327ea..8341264708d 100644 --- a/src/osdc/Objecter.cc +++ b/src/osdc/Objecter.cc @@ -595,7 +595,8 @@ void Objecter::_linger_cancel(LingerOp *info) Objecter::LingerOp *Objecter::linger_register(const object_t& oid, const object_locator_t& oloc, - int flags) + int flags, + uint64_t *cookie) { LingerOp *info = new LingerOp; info->target.base_oid = oid; @@ -609,6 +610,7 @@ Objecter::LingerOp *Objecter::linger_register(const object_t& oid, // Acquire linger ID info->linger_id = ++max_linger_id; + *cookie = info->linger_id; ldout(cct, 10) << __func__ << " info " << info << " linger_id " << info->linger_id << dendl; linger_ops[info->linger_id] = info; diff --git a/src/osdc/Objecter.h b/src/osdc/Objecter.h index 5ae14ffb736..21d18d64b6a 100644 --- a/src/osdc/Objecter.h +++ b/src/osdc/Objecter.h @@ -1965,7 +1965,7 @@ public: // caller owns a ref LingerOp *linger_register(const object_t& oid, const object_locator_t& oloc, - int flags); + int flags, uint64_t *pcookie); ceph_tid_t linger_watch(LingerOp *info, ObjectOperation& op, const SnapContext& snapc, utime_t mtime,