]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Journaler: make reprobe() an asynchronous function.
authorGreg Farnum <gregf@hq.newdream.net>
Tue, 23 Nov 2010 00:19:06 +0000 (16:19 -0800)
committerGreg Farnum <gregf@hq.newdream.net>
Thu, 6 Jan 2011 18:35:24 +0000 (10:35 -0800)
This better fits the spirit of the other functions, and the MDS itself.

Signed-off-by: Greg Farnum <gregf@hq.newdream.net>
src/osdc/Journaler.cc
src/osdc/Journaler.h

index 27e9c485853ac516e4c10a7f8d71d4116988d709..eed64150ea4606efe14b0596b7db37d5dac0d34f 100644 (file)
@@ -97,6 +97,18 @@ public:
   }
 };
 
+class Journaler::C_ReProbe : public Context {
+  Journaler *ls;
+  Context *onfinish;
+public:
+  uint64_t end;
+  C_ReProbe(Journaler *l, Context *onfinish_) :
+    ls(l), onfinish(onfinish_), end(0) {}
+  void finish(int r) {
+    ls->_finish_reprobe(r, end, onfinish);
+  }
+};
+
 void Journaler::recover(Context *onread) 
 {
   dout(1) << "recover start" << dendl;
@@ -208,23 +220,23 @@ void Journaler::probe(Context *finish, uint64_t *end)
              write_pos, end, 0, true, 0, finish);
 }
 
-void Journaler::reprobe()
+void Journaler::reprobe(Context *finish)
 {
   dout(10) << "reprobe" << dendl;
   assert(state == STATE_ACTIVE);
 
-  Mutex lock("Journaler::reprobe");
-  Cond cond;
-  bool done = false;
-  bufferlist bl;
   state = STATE_REPROBING;
-  uint64_t new_end = 0;
-  probe(new C_SafeCond(&lock, &cond, &done), &new_end);
-  while (!done) cond.Wait(lock);
+  C_ReProbe *fin = new C_ReProbe(this, finish);
+  probe(fin, &fin->end);
+}
+
 
+void Journaler::_finish_reprobe(int r, uint64_t new_end, Context *onfinish) {
   assert(new_end >= write_pos);
-  write_pos = new_end;
+  assert(r >= 0);
+  write_pos = flush_pos = ack_pos = safe_pos = new_end;
   state = STATE_ACTIVE;
+  onfinish->finish(r);
 }
 
 void Journaler::_finish_probe_end(int r, uint64_t end)
index 22648ab4b6bd7fd838668e088b8834bdb7a2ac3b..b3f225bdf3a0b7a9ea98bd11a517608cd549a35b 100644 (file)
@@ -148,12 +148,15 @@ private:
   void _finish_reread_head(int r, bufferlist& bl, Context *finish);
   void probe(Context *finish, uint64_t *end);
   void _finish_probe_end(int r, uint64_t end);
+  void _finish_reprobe(int r, uint64_t end, Context *onfinish);
   class C_ReadHead;
   friend class C_ReadHead;
   class C_ProbeEnd;
   friend class C_ProbeEnd;
   class C_RereadHead;
   friend class C_RereadHead;
+  class C_ReProbe;
+  friend class C_ReProbe;
 
 
 
@@ -265,7 +268,7 @@ public:
   void create(ceph_file_layout *layout);
   void recover(Context *onfinish);
   void reread_head(Context *onfinish);
-  void reprobe();
+  void reprobe(Context *onfinish);
   void write_head(Context *onsave=0);
 
   void set_layout(ceph_file_layout *l);