]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ReplicatedPG: don't finish_recovery_op until the transaction completes
authorSamuel Just <sam.just@inktank.com>
Wed, 23 Jan 2013 19:50:13 +0000 (11:50 -0800)
committerSamuel Just <sam.just@inktank.com>
Wed, 23 Jan 2013 19:50:24 +0000 (11:50 -0800)
Signed-off-by: Samuel Just <sam.just@inktank.com>
src/osd/ReplicatedPG.cc
src/osd/ReplicatedPG.h

index 573161e530500ef570de56590134ca74b4f8a206..6b354f9584a085b8311d95e55627b4deb158cc1f 100644 (file)
@@ -5383,6 +5383,7 @@ void ReplicatedPG::handle_pull_response(OpRequestRef op)
   ObjectStore::Transaction *t = new ObjectStore::Transaction;
   Context *onreadable = 0;
   Context *onreadable_sync = 0;
+  Context *oncomplete = 0;
   submit_push_data(pi.recovery_info, first,
                   data_included, data,
                   m->omap_header,
@@ -5411,21 +5412,25 @@ void ReplicatedPG::handle_pull_response(OpRequestRef op)
 
     onreadable = new C_OSD_AppliedRecoveredObject(this, t, obc);
     onreadable_sync = new C_OSD_OndiskWriteUnlock(obc);
+    oncomplete = new C_OSD_CompletedPull(this, hoid, get_osdmap()->get_epoch());
   } else {
     onreadable = new ObjectStore::C_DeleteTransaction(t);
   }
 
   int r = osd->store->
-    queue_transaction(osr.get(), t,
-                     onreadable,
-                     new C_OSD_CommittedPushedObject(this, op,
-                                                     info.history.same_interval_since,
-                                                     info.last_complete),
-                     onreadable_sync);
+    queue_transaction(
+      osr.get(), t,
+      onreadable,
+      new C_OSD_CommittedPushedObject(this, op,
+                                     info.history.same_interval_since,
+                                     info.last_complete),
+      onreadable_sync,
+      oncomplete,
+      TrackedOpRef()
+      );
   assert(r == 0);
 
   if (complete) {
-    finish_recovery_op(hoid);
     pulling.erase(hoid);
     pull_from_peer[m->get_source().num()].erase(hoid);
     update_stats();
index 03f04458f2a83111176a70b58c340f86cef2a57c..2b5019f33744dec6169dd5e7a579c87c1b43b086 100644 (file)
@@ -907,6 +907,23 @@ protected:
       osd->send_message_osd_cluster(reply, conn.get());
     }
   };
+  struct C_OSD_CompletedPull : public Context {
+    boost::intrusive_ptr<ReplicatedPG> pg;
+    hobject_t hoid;
+    epoch_t epoch;
+    C_OSD_CompletedPull(
+      ReplicatedPG *pg,
+      const hobject_t &hoid,
+      epoch_t epoch) : pg(pg), hoid(hoid), epoch(epoch) {}
+    void finish(int) {
+      pg->lock();
+      if (epoch >= pg->last_peering_reset) {
+       pg->finish_recovery_op(hoid);
+      }
+      pg->unlock();
+    }
+  };
+  friend class C_OSD_CompletedPull;
   struct C_OSD_AppliedRecoveredObjectReplica : public Context {
     boost::intrusive_ptr<ReplicatedPG> pg;
     ObjectStore::Transaction *t;