From ea088fae6ac016868743d49461701074d953273d Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 12 Dec 2013 12:33:44 -0800 Subject: [PATCH] osd/osd_types: operator<< for ObjectContext::RWState Signed-off-by: Sage Weil --- src/osd/osd_types.h | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 3c8218e65dbe8..afba5562b2bb0 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -2289,9 +2289,21 @@ public: RWREAD, RWWRITE }; - State state; /// rw state - uint64_t count; /// number of readers or writers - list 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 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 << ")"; } -- 2.39.5