]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: carry ondisk write lock for cloned objects
authorSage Weil <sage@newdream.net>
Thu, 19 Aug 2010 16:52:33 +0000 (09:52 -0700)
committerSage Weil <sage@newdream.net>
Thu, 19 Aug 2010 16:52:55 +0000 (09:52 -0700)
This fixes a race when reading and deleting objects, as evidenced by

 cp bigfile a
 mkdir .snap/foo
 rmdir a
 diff bigfile .snap/foo/a    <-- reads cloned object before it hits disk

Reproduced by snaptest-snap-rm-cmp.sh.

Signed-off-by: Sage Weil <sage@newdream.net>
src/osd/ReplicatedPG.cc
src/osd/ReplicatedPG.h

index 0bde57af26c3bad0dc3de985146a9537e57c8139..e10e2254f810ac682a3b7d883cee4a1c1f8108dc 100644 (file)
@@ -2083,10 +2083,13 @@ void ReplicatedPG::apply_repop(RepGather *repop)
   repop->tls.push_back(&repop->ctx->local_t);
 
   repop->obc->ondisk_write_lock();
+  if (repop->ctx->clone_obc)
+    repop->ctx->clone_obc->ondisk_write_lock();
 
   Context *oncommit = new C_OSD_OpCommit(this, repop);
   Context *onapplied = new C_OSD_OpApplied(this, repop);
-  Context *onapplied_sync = new C_OSD_OndiskWriteUnlock(repop->obc);
+  Context *onapplied_sync = new C_OSD_OndiskWriteUnlock(repop->obc,
+                                                       repop->ctx->clone_obc);
   int r = osd->store->queue_transactions(&osr, repop->tls, onapplied, oncommit, onapplied_sync);
   if (r) {
     dout(-10) << "apply_repop  queue_transactions returned " << r << " on " << *repop << dendl;
index 9cbf57e61d7120126b8acaea2dca000e563c1f40..d482322e06bb696b2b1f03a4293ba47e72af2389 100644 (file)
@@ -543,10 +543,12 @@ protected:
     }
   };
   struct C_OSD_OndiskWriteUnlock : public Context {
-    ObjectContext *obc;
-    C_OSD_OndiskWriteUnlock(ObjectContext *o) : obc(o) {}
+    ObjectContext *obc, *obc2;
+    C_OSD_OndiskWriteUnlock(ObjectContext *o, ObjectContext *o2=0) : obc(o), obc2(o2) {}
     void finish(int r) {
       obc->ondisk_write_unlock();
+      if (obc2)
+       obc2->ondisk_write_unlock();
     }
   };
   struct C_OSD_WrotePushedObject : public Context {