]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: track obc for clone from log replay
authorSage Weil <sage@newdream.net>
Wed, 25 Jan 2012 06:03:51 +0000 (22:03 -0800)
committerSage Weil <sage@newdream.net>
Wed, 25 Jan 2012 06:03:51 +0000 (22:03 -0800)
We need to keep an in-memory obc to track the state of the in-flight io
to disk.  This is analogous to when an object is pushed + written, and we
can share the same completion function.

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

index 1d7fd422ff4aeb654db4879ad87c12818d609652..8c5fd528b98c29534639466d64359aebedf75e3d 100644 (file)
@@ -4380,10 +4380,10 @@ void ReplicatedPG::_committed_pushed_object(MOSDSubOp *op, epoch_t same_since, e
   put();
 }
 
-void ReplicatedPG::_applied_pushed_object(ObjectStore::Transaction *t, ObjectContext *obc)
+void ReplicatedPG::_applied_recovered_object(ObjectStore::Transaction *t, ObjectContext *obc)
 {
   lock();
-  dout(10) << "_applied_pushed_object " << *obc << dendl;
+  dout(10) << "_applied_recovered_object " << *obc << dendl;
   if (is_primary())
     populate_obc_watchers(obc);
   put_object_context(obc);
@@ -4681,7 +4681,7 @@ void ReplicatedPG::sub_op_push(MOSDSubOp *op)
        ssc->snapset.decode(sp);
       }
 
-      onreadable = new C_OSD_AppliedPushedObject(this, t, obc);
+      onreadable = new C_OSD_AppliedRecoveredObject(this, t, obc);
       onreadable_sync = new C_OSD_OndiskWriteUnlock(obc);
     } else {
       onreadable = new ObjectStore::C_DeleteTransaction(t);
@@ -5254,13 +5254,22 @@ int ReplicatedPG::recover_primary(int max)
            ::decode(oi.snaps, i);
            assert(oi.snaps.size() > 0);
            oi.copy_user_bits(headobc->obs.oi);
-           _make_clone(*t, head, soid, &oi);
 
-           put_object_context(headobc);
+           ObjectContext *clone_obc = new ObjectContext(oi, true, NULL);
+           clone_obc->get();
+           clone_obc->ondisk_write_lock();
+           clone_obc->ssc = get_snapset_context(soid.oid, soid.get_key(), soid.hash, true);
+           register_object_context(clone_obc);
+
+           _make_clone(*t, head, soid, &clone_obc->obs.oi);
 
-           // XXX: track objectcontext!
-           int tr = osd->store->queue_transaction(&osr, t);
+           Context *onreadable = new C_OSD_AppliedRecoveredObject(this, t, clone_obc);
+           Context *onreadable_sync = new C_OSD_OndiskWriteUnlock(clone_obc);
+           int tr = osd->store->queue_transaction(&osr, t, onreadable, NULL, onreadable_sync);
            assert(tr == 0);
+
+           put_object_context(headobc);
+
            missing.got(latest->soid, latest->version);
            missing_loc.erase(latest->soid);
            continue;
@@ -5293,7 +5302,7 @@ int ReplicatedPG::recover_primary(int max)
              recover_got(soid, latest->version);
 
              osd->store->queue_transaction(&osr, t,
-                                           new C_OSD_AppliedPushedObject(this, t, obc),
+                                           new C_OSD_AppliedRecoveredObject(this, t, obc),
                                            new C_OSD_CommittedPushedObject(this, NULL,
                                                                            info.history.same_interval_since,
                                                                            info.last_complete),
index 6b43aa23d676a1f2a537759087e9179bde42a68c..830fae1706838d8dca58fb03a5531bf96a3d92f7 100644 (file)
@@ -710,14 +710,14 @@ protected:
        (*p)->ondisk_write_unlock();
     }
   };
-  struct C_OSD_AppliedPushedObject : public Context {
+  struct C_OSD_AppliedRecoveredObject : public Context {
     ReplicatedPG *pg;
     ObjectStore::Transaction *t;
     ObjectContext *obc;
-    C_OSD_AppliedPushedObject(ReplicatedPG *p, ObjectStore::Transaction *tt, ObjectContext *o) :
+    C_OSD_AppliedRecoveredObject(ReplicatedPG *p, ObjectStore::Transaction *tt, ObjectContext *o) :
       pg(p), t(tt), obc(o) {}
     void finish(int r) {
-      pg->_applied_pushed_object(t, obc);
+      pg->_applied_recovered_object(t, obc);
     }
   };
   struct C_OSD_CommittedPushedObject : public Context {
@@ -744,7 +744,7 @@ protected:
   void sub_op_modify_commit(RepModify *rm);
 
   void sub_op_modify_reply(MOSDSubOpReply *reply);
-  void _applied_pushed_object(ObjectStore::Transaction *t, ObjectContext *obc);
+  void _applied_recovered_object(ObjectStore::Transaction *t, ObjectContext *obc);
   void _committed_pushed_object(MOSDSubOp *op, epoch_t same_since, eversion_t lc);
   void recover_got(hobject_t oid, eversion_t v);
   void sub_op_push(MOSDSubOp *op);