]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librados: use Objecter's linger_id as the cookie
authorSage Weil <sage@redhat.com>
Fri, 14 Nov 2014 21:35:05 +0000 (13:35 -0800)
committerSage Weil <sage@redhat.com>
Thu, 4 Dec 2014 18:34:05 +0000 (10:34 -0800)
Signed-off-by: Sage Weil <sage@redhat.com>
src/librados/IoCtxImpl.cc
src/librados/RadosClient.cc
src/librados/RadosClient.h
src/osdc/Objecter.cc
src/osdc/Objecter.h

index c68ab7e594bd0b867ef426510ad34fe73720daec..08d71d049cd7c0b04e80425e39bc322193b7256e 100644 (file)
@@ -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)
index 81fa7701d4b29762d24ce402a315ffd5e3259726..c2e572e436c219a5356848d877e97b68020b0f80 100644 (file)
@@ -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;
 }
index 3e57ae4f9fb632283dbe6bc90f3be9e9da3159b2..299ffa288ed80b0503724a7c5a9bfb8723bba58a 100644 (file)
@@ -109,11 +109,10 @@ public:
   int pool_delete_async(const char *name, PoolAsyncCompletionImpl *c);
 
   // watch/notify
-  uint64_t max_watch_notify_cookie;
   map<uint64_t, librados::WatchNotifyInfo *> 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);
index a4a33b327ea7c47dc0791d10d23e09863bb424f1..8341264708d6971c7ff8facb907eb133085c8b6c 100644 (file)
@@ -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;
index 5ae14ffb73617431dfdbebaea368acc0a86beed4..21d18d64b6a9bd31e49b0831fc74f1d11e910587 100644 (file)
@@ -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,