]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
finisher: fix flushing, debug output
authorSage Weil <sage@newdream.net>
Thu, 28 Jan 2010 18:33:04 +0000 (10:33 -0800)
committerSage Weil <sage@newdream.net>
Thu, 28 Jan 2010 18:33:04 +0000 (10:33 -0800)
src/common/Finisher.cc
src/common/Finisher.h
src/config.cc
src/config.h

index fb0f8e0fa1273f954f683e8d44df28b8482ab1e0..b184035a94561a93df1fe57ea2b325706a31e22a 100644 (file)
@@ -2,6 +2,11 @@
 #include "config.h"
 #include "Finisher.h"
 
+#include "common/debug.h"
+#define DOUT_SUBSYS finisher
+#undef dout_prefix
+#define dout_prefix *_dout << dbeginl << std::hex << pthread_self() << std::dec << " finisher(" << this << ") "
+
 void Finisher::start()
 {
   finisher_thread.create();
@@ -19,15 +24,18 @@ void Finisher::stop()
 void Finisher::wait_for_empty()
 {
   finisher_lock.Lock();
-  while (!finisher_queue.empty())
-    finisher_cond.Wait(finisher_lock);
+  while (!finisher_queue.empty() || finisher_running) {
+    dout(10) << "wait_for_empty waiting" << dendl;
+    finisher_empty_cond.Wait(finisher_lock);
+  }
+  dout(10) << "wait_for_empty empty" << dendl;
   finisher_lock.Unlock();
 }
 
 void *Finisher::finisher_thread_entry()
 {
   finisher_lock.Lock();
-  //dout_generic(10) << "finisher_thread start" << dendl;
+  dout(10) << "finisher_thread start" << dendl;
 
   while (!finisher_stop) {
     while (!finisher_queue.empty()) {
@@ -35,7 +43,9 @@ void *Finisher::finisher_thread_entry()
       list<pair<Context*,int> > ls_rval;
       ls.swap(finisher_queue);
       ls_rval.swap(finisher_queue_rval);
+      finisher_running = true;
       finisher_lock.Unlock();
+      dout(10) << "finisher_thread doing " << ls << dendl;
 
       for (vector<Context*>::iterator p = ls.begin();
           p != ls.end();
@@ -51,18 +61,23 @@ void *Finisher::finisher_thread_entry()
          ls_rval.pop_front();
        }
       }
+      dout(10) << "finisher_thread done with " << ls << dendl;
       ls.clear();
 
       finisher_lock.Lock();
-      finisher_empty_cond.Signal();
+      finisher_running = false;
     }
-    if (finisher_stop) break;
+    dout(10) << "finisher_thread empty" << dendl;
+    finisher_empty_cond.Signal();
+    if (finisher_stop)
+      break;
     
-    //dout_generic(30) << "finisher_thread sleeping" << dendl;
+    dout(10) << "finisher_thread sleeping" << dendl;
     finisher_cond.Wait(finisher_lock);
   }
+  finisher_empty_cond.Signal();
 
-  //dout_generic(10) << "finisher_thread start" << dendl;
+  dout(10) << "finisher_thread stop" << dendl;
   finisher_lock.Unlock();
   return 0;
 }
index 94291b494dd9aaa0875a2dfb29ef7c7a42e3d45b..50d9f6123039f55c3e342cbf922e56ad447bf34c 100644 (file)
@@ -22,7 +22,7 @@
 class Finisher {
   Mutex          finisher_lock;
   Cond           finisher_cond, finisher_empty_cond;
-  bool           finisher_stop;
+  bool           finisher_stop, finisher_running;
   vector<Context*> finisher_queue;
   list<pair<Context*,int> > finisher_queue_rval;
   
@@ -65,7 +65,8 @@ class Finisher {
 
   void wait_for_empty();
 
-  Finisher() : finisher_lock("Finisher::finisher_lock"), finisher_stop(false), finisher_thread(this) {}
+  Finisher() : finisher_lock("Finisher::finisher_lock"),
+              finisher_stop(false), finisher_running(false), finisher_thread(this) {}
 };
 
 #endif
index ac0cb2e72d4e7613344a43abf432bb512481bb80..43a09bcc636919b2e1ba4b473a0cdd19c1901bcb 100644 (file)
@@ -353,6 +353,7 @@ static struct config_option config_optionsp[] = {
        OPTION(debug_paxos, 0, OPT_INT, 0),
        OPTION(debug_tp, 0, OPT_INT, 0),
        OPTION(debug_auth, 0, OPT_INT, 1),
+       OPTION(debug_finisher, 0, OPT_INT, 1),
        OPTION(keys_file, 'k', OPT_STR, "~/.ceph/keyring.bin, /etc/ceph/keyring.bin, .ceph_keyring"),
        OPTION(supported_auth, 0, OPT_STR, "none"),
        OPTION(clock_lock, 0, OPT_BOOL, false),
index e43ee18648dd19b59efc41d1a5c2236446ffb317..7b1af1c84ea036bd71494307f96033933c6f2331 100644 (file)
@@ -106,6 +106,7 @@ struct md_config_t {
   int debug_paxos;
   int debug_tp;
   int debug_auth;
+  int debug_finisher;
 
   // clock
   bool clock_lock;