summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Just <sam.just@inktank.com>2013-02-12 14:04:55 -0800
committerSamuel Just <sam.just@inktank.com>2013-02-20 13:29:20 -0800
commit661a28320be22d58fb680d699d40f1d3b6f3e325 (patch)
tree3d3ac5da47632412fdaa9ce415de2558020810aa
parent8ece91ff2132c50c58d924aa1b912544ff423704 (diff)
downloadceph-661a28320be22d58fb680d699d40f1d3b6f3e325.tar.gz
librados/: include watch cookie in notify_ack
Signed-off-by: Samuel Just <sam.just@inktank.com>
-rw-r--r--src/librados/IoCtxImpl.cc16
-rw-r--r--src/librados/IoCtxImpl.h5
-rw-r--r--src/librados/RadosClient.cc9
-rw-r--r--src/librados/RadosClient.h3
-rw-r--r--src/osdc/Objecter.h4
5 files changed, 20 insertions, 17 deletions
diff --git a/src/librados/IoCtxImpl.cc b/src/librados/IoCtxImpl.cc
index ea63b2a59b4..800e27f90b6 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 33d1f3ebd14..c5b14cab8e3 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 7e76b65694d..feb0dfc3602 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 1f39f22fb3f..6dd6d109c64 100644
--- a/src/librados/RadosClient.h
+++ b/src/librados/RadosClient.h
@@ -97,8 +97,7 @@ public:
uint64_t max_watch_cookie;
map<uint64_t, librados::WatchContext *> 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 baf600c53be..9ff02f6ab93 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);
}