]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
context: conditional context debugging
authorSage Weil <sage.weil@dreamhost.com>
Wed, 23 Mar 2011 16:43:51 +0000 (09:43 -0700)
committerSage Weil <sage.weil@dreamhost.com>
Wed, 23 Mar 2011 16:43:51 +0000 (09:43 -0700)
Mainly C_Gather, which is a reasonably frequent source of pain.

Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
src/common/config.cc
src/common/config.h
src/common/debug.h
src/include/Context.h

index 171bb8f1a842b5596f3491eeca7507e8f4ac739d..7356893771ba17e0f496e4393fb2c98d3ed18aea 100644 (file)
@@ -123,6 +123,7 @@ struct config_option config_optionsp[] = {
   OPTION(max_open_files, 0, OPT_LONGLONG, 0),
   OPTION(debug, 0, OPT_INT, 0),
   OPTION(debug_lockdep, 0, OPT_INT, 0),
+  OPTION(debug_context, 0, OPT_INT, 0),
   OPTION(debug_mds, 0, OPT_INT, 1),
   OPTION(debug_mds_balancer, 0, OPT_INT, 1),
   OPTION(debug_mds_log, 0, OPT_INT, 1),
index 75468c3f2fb905cfd595b58cfac40bca26f3db15..39ff6cdd7f2feeb859c44044b057fb94851b7607 100644 (file)
@@ -101,6 +101,7 @@ struct md_config_t
 
   int debug;
   int debug_lockdep;
+  int debug_context;
   int debug_mds;
   int debug_mds_balancer;
   int debug_mds_log;
index 057f130d483dfa83a2e20e9db70465ed4192365a..d89f95b4248ddc57754e8fdd448bad3b2817e9f1 100644 (file)
@@ -94,6 +94,11 @@ inline std::ostream& operator<<(std::ostream& out, _bad_endl_use_dendl_t) {
     dout_impl(v) \
     dout_prefix
 
+#define cdout(sys, v)        \
+  do { if (v <= XDOUT_CONDVAR(sys)) { \
+    dout_impl(v) \
+    dout_prefix
+
 #define pdout(v, p) \
   do { if ((v) <= (p)) {\
     dout_impl(v) \
index e7bc67f6fe3095865ac116591613dfb4929c3b62..091867997703f7fd3c4f6aa1b4ae1d631647b9e8 100644 (file)
@@ -47,12 +47,12 @@ inline void finish_contexts(std::list<Context*>& finished,
   list<Context*> ls;
   ls.swap(finished); // swap out of place to avoid weird loops
 
-  generic_dout(10) << ls.size() << " contexts to finish with " << result << dendl;
+  cdout(context, 10) << ls.size() << " contexts to finish with " << result << dendl;
   for (std::list<Context*>::iterator it = ls.begin(); 
        it != ls.end(); 
        it++) {
     Context *c = *it;
-    generic_dout(10) << "---- " << c << dendl;
+    cdout(context, 10) << "---- " << c << dendl;
     c->finish(result);
     delete c;
   }
@@ -67,12 +67,12 @@ inline void finish_contexts(std::vector<Context*>& finished,
   vector<Context*> ls;
   ls.swap(finished); // swap out of place to avoid weird loops
 
-  generic_dout(10) << ls.size() << " contexts to finish with " << result << dendl;
+  cdout(context, 10) << ls.size() << " contexts to finish with " << result << dendl;
   for (std::vector<Context*>::iterator it = ls.begin(); 
        it != ls.end(); 
        it++) {
     Context *c = *it;
-    generic_dout(10) << "---- " << c << dendl;
+    cdout(context, 10) << "---- " << c << dendl;
     c->finish(result);
     delete c;
   }
@@ -131,7 +131,11 @@ private:
 #endif
     --sub_existing_count;
 
-    //generic_dout(0) << "C_Gather " << this << ".sub_finish(r=" << r << ") " << sub << " " << dendl;
+    cdout(context, 10) << "C_Gather " << this << ".sub_finish(r=" << r << ") " << sub
+#ifdef DEBUG_GATHER
+                   << " (remaining " << waitfor << ")"
+#endif
+                   << dendl;
 
     if (r < 0 && result == 0)
       result = r;
@@ -182,10 +186,10 @@ public:
                                           lock("C_Gather::lock", true, false), //disable lockdep
                                           any(an),
                                          activated(onfinish ? true : false) {
-    //generic_dout(0) << "C_Gather " << this << ".new" << dendl;
+    cdout(context, 10) << "C_Gather " << this << ".new" << dendl;
   }
   ~C_Gather() {
-    //generic_dout(0) << "C_Gather " << this << ".delete" << dendl;
+    cdout(context, 10) << "C_Gather " << this << ".delete" << dendl;
     assert(sub_existing_count == 0);
 #ifdef DEBUG_GATHER
     assert(waitfor.empty());
@@ -207,7 +211,7 @@ public:
 #ifdef DEBUG_GATHER
     waitfor.insert(s);
 #endif
-    //generic_dout(0) << "C_Gather " << this << ".new_sub is " << sub_created_count << " " << s << dendl;
+    cdout(context, 10) << "C_Gather " << this << ".new_sub is " << sub_created_count << " " << s << dendl;
     return s;
   }
   void rm_sub(Context *s) {