From: Samuel Just Date: Tue, 12 Feb 2013 22:04:55 +0000 (-0800) Subject: librados/: include watch cookie in notify_ack X-Git-Tag: v0.59~160^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=661a28320be22d58fb680d699d40f1d3b6f3e325;p=ceph.git librados/: include watch cookie in notify_ack Signed-off-by: Samuel Just --- diff --git a/src/librados/IoCtxImpl.cc b/src/librados/IoCtxImpl.cc index ea63b2a59b4c..800e27f90b6e 100644 --- a/src/librados/IoCtxImpl.cc +++ b/src/librados/IoCtxImpl.cc @@ -1403,7 +1403,7 @@ int librados::IoCtxImpl::watch(const object_t& oid, uint64_t ver, lock->Lock(); WatchContext *wc = new WatchContext(this, oid, ctx); - client->register_watcher(wc, oid, ctx, cookie); + client->register_watcher(wc, cookie); prepare_assert_ops(&rd); rd.watch(*cookie, ver, 1); bufferlist bl; @@ -1431,12 +1431,14 @@ int librados::IoCtxImpl::watch(const object_t& oid, uint64_t ver, /* this is called with IoCtxImpl::lock held */ -int librados::IoCtxImpl::_notify_ack(const object_t& oid, - uint64_t notify_id, uint64_t ver) +int librados::IoCtxImpl::_notify_ack( + const object_t& oid, + uint64_t notify_id, uint64_t ver, + uint64_t cookie) { ::ObjectOperation rd; prepare_assert_ops(&rd); - rd.notify_ack(notify_id, ver); + rd.notify_ack(notify_id, ver, cookie); objecter->read(oid, oloc, rd, snap_seq, (bufferlist*)NULL, 0, 0, 0); return 0; @@ -1491,7 +1493,7 @@ int librados::IoCtxImpl::notify(const object_t& oid, uint64_t ver, bufferlist& b lock->Lock(); WatchContext *wc = new WatchContext(this, oid, ctx); - client->register_watcher(wc, oid, ctx, &cookie); + client->register_watcher(wc, &cookie); uint32_t prot_ver = 1; uint32_t timeout = notify_timeout; ::encode(prot_ver, inbl); @@ -1687,7 +1689,7 @@ void librados::IoCtxImpl::C_NotifyComplete::notify(uint8_t opcode, librados::WatchContext::WatchContext(IoCtxImpl *io_ctx_impl_, const object_t& _oc, librados::WatchCtx *_ctx) - : io_ctx_impl(io_ctx_impl_), oid(_oc), ctx(_ctx), linger_id(0) + : io_ctx_impl(io_ctx_impl_), oid(_oc), ctx(_ctx), linger_id(0), cookie(0) { io_ctx_impl->get(); } @@ -1706,7 +1708,7 @@ void librados::WatchContext::notify(Mutex *client_lock, ctx->notify(opcode, ver, payload); if (opcode != WATCH_NOTIFY_COMPLETE) { client_lock->Lock(); - io_ctx_impl->_notify_ack(oid, notify_id, ver); + io_ctx_impl->_notify_ack(oid, notify_id, ver, cookie); client_lock->Unlock(); } } diff --git a/src/librados/IoCtxImpl.h b/src/librados/IoCtxImpl.h index 33d1f3ebd14a..c5b14cab8e36 100644 --- a/src/librados/IoCtxImpl.h +++ b/src/librados/IoCtxImpl.h @@ -194,7 +194,9 @@ struct librados::IoCtxImpl { int watch(const object_t& oid, uint64_t ver, uint64_t *cookie, librados::WatchCtx *ctx); int unwatch(const object_t& oid, uint64_t cookie); int notify(const object_t& oid, uint64_t ver, bufferlist& bl); - int _notify_ack(const object_t& oid, uint64_t notify_id, uint64_t ver); + int _notify_ack( + const object_t& oid, uint64_t notify_id, uint64_t ver, + uint64_t cookie); eversion_t last_version(); void set_assert_version(uint64_t ver); @@ -217,6 +219,7 @@ struct WatchContext : public RefCountedWaitObject { const object_t oid; librados::WatchCtx *ctx; uint64_t linger_id; + uint64_t cookie; WatchContext(IoCtxImpl *io_ctx_impl_, const object_t& _oc, diff --git a/src/librados/RadosClient.cc b/src/librados/RadosClient.cc index 7e76b65694de..feb0dfc3602a 100644 --- a/src/librados/RadosClient.cc +++ b/src/librados/RadosClient.cc @@ -478,14 +478,11 @@ int librados::RadosClient::pool_delete_async(const char *name, PoolAsyncCompleti return r; } -void librados::RadosClient::register_watcher(WatchContext *wc, - const object_t& oid, - librados::WatchCtx *ctx, - uint64_t *cookie) +void librados::RadosClient::register_watcher(WatchContext *wc, uint64_t *cookie) { assert(lock.is_locked()); - *cookie = ++max_watch_cookie; - watchers[*cookie] = wc; + wc->cookie = *cookie = ++max_watch_cookie; + watchers[wc->cookie] = wc; } void librados::RadosClient::unregister_watcher(uint64_t cookie) diff --git a/src/librados/RadosClient.h b/src/librados/RadosClient.h index 1f39f22fb3f3..6dd6d109c647 100644 --- a/src/librados/RadosClient.h +++ b/src/librados/RadosClient.h @@ -97,8 +97,7 @@ public: uint64_t max_watch_cookie; map watchers; - void register_watcher(librados::WatchContext *wc, const object_t& oid, - librados::WatchCtx *ctx, uint64_t *cookie); + void register_watcher(librados::WatchContext *wc, uint64_t *cookie); void unregister_watcher(uint64_t cookie); void watch_notify(MWatchNotify *m); void get(); diff --git a/src/osdc/Objecter.h b/src/osdc/Objecter.h index baf600c53be5..9ff02f6ab938 100644 --- a/src/osdc/Objecter.h +++ b/src/osdc/Objecter.h @@ -487,8 +487,10 @@ struct ObjectOperation { add_watch(CEPH_OSD_OP_NOTIFY, cookie, ver, 1, inbl); } - void notify_ack(uint64_t notify_id, uint64_t ver) { + void notify_ack(uint64_t notify_id, uint64_t ver, uint64_t cookie) { bufferlist bl; + ::encode(notify_id, bl); + ::encode(cookie, bl); add_watch(CEPH_OSD_OP_NOTIFY_ACK, notify_id, ver, 0, bl); }