]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osdc/Objecter: unwatch is a mutation, not a read
authorSage Weil <sage@inktank.com>
Thu, 21 Feb 2013 21:28:47 +0000 (13:28 -0800)
committerJosh Durgin <josh.durgin@inktank.com>
Tue, 23 Apr 2013 18:33:17 +0000 (11:33 -0700)
This was causing librados to unblock after the ACK on unwatch, which meant
that librbd users raced and tried to delete the image before the unwatch
change was committed..and got EBUSY.  See #3958.

The watch operation has a similar problem.

Signed-off-by: Sage Weil <sage@inktank.com>
(cherry picked from commit fea77682a6cf9c7571573bc9791c03373d1d976d)

Conflicts:

src/librados/IoCtxImpl.cc

src/librados/IoCtxImpl.cc

index 934a10190d1a0b6ed96aeeda7576bada098dbb62..a5b04843641be1feb76df798432c61fa50c506a3 100644 (file)
@@ -1377,7 +1377,7 @@ void librados::IoCtxImpl::set_sync_op_version(eversion_t& ver)
 int librados::IoCtxImpl::watch(const object_t& oid, uint64_t ver,
                               uint64_t *cookie, librados::WatchCtx *ctx)
 {
-  ::ObjectOperation rd;
+  ::ObjectOperation wr;
   Mutex mylock("IoCtxImpl::watch::mylock");
   Cond cond;
   bool done;
@@ -1389,11 +1389,11 @@ int librados::IoCtxImpl::watch(const object_t& oid, uint64_t ver,
 
   WatchContext *wc = new WatchContext(this, oid, ctx);
   client->register_watcher(wc, oid, ctx, cookie);
-  prepare_assert_ops(&rd);
-  rd.watch(*cookie, ver, 1);
+  prepare_assert_ops(&wr);
+  wr.watch(*cookie, ver, 1);
   bufferlist bl;
   wc->linger_id = objecter->linger(
-    oid, oloc, rd, snap_seq, bl, NULL,
+    oid, oloc, wr, snap_seq, bl, NULL,
     CEPH_OSD_FLAG_WRITE,
     NULL, onfinish, &objver);
   lock->Unlock();
@@ -1435,16 +1435,16 @@ int librados::IoCtxImpl::unwatch(const object_t& oid, uint64_t cookie)
   Cond cond;
   bool done;
   int r;
-  Context *onack = new C_SafeCond(&mylock, &cond, &done, &r);
+  Context *oncommit = new C_SafeCond(&mylock, &cond, &done, &r);
   eversion_t ver;
   lock->Lock();
 
   client->unregister_watcher(cookie);
 
-  ::ObjectOperation rd;
-  prepare_assert_ops(&rd);
-  rd.watch(cookie, 0, 0);
-  objecter->read(oid, oloc, rd, snap_seq, &outbl, 0, onack, &ver);
+  ::ObjectOperation wr;
+  prepare_assert_ops(&wr);
+  wr.watch(cookie, 0, 0);
+  objecter->mutate(oid, oloc, wr, snapc, ceph_clock_now(client->cct), 0, NULL, oncommit, &ver);
   lock->Unlock();
 
   mylock.Lock();