]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/osd_types: operator<< for ObjectContext::RWState
authorSage Weil <sage@inktank.com>
Thu, 12 Dec 2013 20:33:44 +0000 (12:33 -0800)
committerSage Weil <sage@inktank.com>
Sat, 14 Dec 2013 00:35:56 +0000 (16:35 -0800)
Signed-off-by: Sage Weil <sage@inktank.com>
src/osd/osd_types.h

index 3c8218e65dbe88e3103e4a2c47da9a5f1c142c53..afba5562b2bb055cf3c2394167825cfc2272e51f 100644 (file)
@@ -2289,9 +2289,21 @@ public:
       RWREAD,
       RWWRITE
     };
-    State state;                 /// rw state
-    uint64_t count;              /// number of readers or writers
-    list<OpRequestRef> waiters;  /// ops waiting on state change
+    static const char *get_state_name(State s) {
+      switch (s) {
+      case RWNONE: return "none";
+      case RWREAD: return "read";
+      case RWWRITE: return "write";
+      default: return "???";
+      }
+    }
+    const char *get_state_name() const {
+      return get_state_name(state);
+    }
+
+    State state;                 ///< rw state
+    uint64_t count;              ///< number of readers or writers
+    list<OpRequestRef> waiters;  ///< ops waiting on state change
 
     /// if set, restart backfill when we can get a read lock
     bool backfill_read_marker;
@@ -2459,7 +2471,7 @@ public:
   }
 };
 
-inline ostream& operator<<(ostream& out, ObjectState& obs)
+inline ostream& operator<<(ostream& out, const ObjectState& obs)
 {
   out << obs.oi.soid;
   if (!obs.exists)
@@ -2467,9 +2479,17 @@ inline ostream& operator<<(ostream& out, ObjectState& obs)
   return out;
 }
 
-inline ostream& operator<<(ostream& out, ObjectContext& obc)
+inline ostream& operator<<(ostream& out, const ObjectContext::RWState& rw)
+{
+  return out << "rwstate(" << rw.get_state_name()
+            << " n=" << rw.count
+            << " w=" << rw.waiters.size()
+            << ")";
+}
+
+inline ostream& operator<<(ostream& out, const ObjectContext& obc)
 {
-  return out << "obc(" << obc.obs << ")";
+  return out << "obc(" << obc.obs << " " << obc.rwstate << ")";
 }