From: Sage Weil Date: Thu, 26 Aug 2010 04:31:34 +0000 (-0700) Subject: mds: omit lock state in debug output when it's uninteresting (sync, no locks) X-Git-Tag: v0.22~215 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4e3003249cd86898e447e56c1f4fca787f7eb905;p=ceph.git mds: omit lock state in debug output when it's uninteresting (sync, no locks) --- diff --git a/src/mds/CDentry.cc b/src/mds/CDentry.cc index 6abba341d3ae..2a9e1fbcb732 100644 --- a/src/mds/CDentry.cc +++ b/src/mds/CDentry.cc @@ -85,8 +85,10 @@ ostream& operator<<(ostream& out, CDentry& dn) out << ")"; } - out << " " << dn.lock; - out << " " << dn.versionlock; + if (!dn.lock.is_sync_and_unlocked()) + out << " " << dn.lock; + if (!dn.versionlock.is_sync_and_unlocked()) + out << " " << dn.versionlock; if (dn.get_projected_version() != dn.get_version()) out << " pv=" << dn.get_projected_version(); diff --git a/src/mds/CInode.cc b/src/mds/CInode.cc index 0ee4648d20fe..aaa0e7503408 100644 --- a/src/mds/CInode.cc +++ b/src/mds/CInode.cc @@ -149,18 +149,27 @@ ostream& operator<<(ostream& out, CInode& in) // locks - out << " " << in.authlock; - out << " " << in.linklock; + if (!in.authlock.is_sync_and_unlocked()) + out << " " << in.authlock; + if (!in.linklock.is_sync_and_unlocked()) + out << " " << in.linklock; if (in.inode.is_dir()) { - out << " " << in.dirfragtreelock; - out << " " << in.snaplock; - out << " " << in.nestlock; + if (!in.dirfragtreelock.is_sync_and_unlocked()) + out << " " << in.dirfragtreelock; + if (!in.snaplock.is_sync_and_unlocked()) + out << " " << in.snaplock; + if (!in.nestlock.is_sync_and_unlocked()) + out << " " << in.nestlock; } else { - out << " " << in.flocklock; + if (!in.flocklock.is_sync_and_unlocked()) + out << " " << in.flocklock; } - out << " " << in.filelock; - out << " " << in.xattrlock; - out << " " << in.versionlock; + if (!in.filelock.is_sync_and_unlocked()) + out << " " << in.filelock; + if (!in.xattrlock.is_sync_and_unlocked()) + out << " " << in.xattrlock; + if (!in.versionlock.is_sync_and_unlocked()) + out << " " << in.versionlock; // hack: spit out crap on which clients have caps if (in.inode.client_ranges.size()) diff --git a/src/mds/ScatterLock.h b/src/mds/ScatterLock.h index ffcdbee4a2da..ea593e41eb99 100644 --- a/src/mds/ScatterLock.h +++ b/src/mds/ScatterLock.h @@ -40,7 +40,7 @@ class ScatterLock : public SimpleLock { }; more_bits_t *_more; - bool have_more() { return _more ? true : false; } + bool have_more() const { return _more ? true : false; } void try_clear_more() { if (_more && _more->empty()) { delete _more; @@ -64,6 +64,14 @@ public: } } + bool is_sync_and_unlocked() const { + return + SimpleLock::is_sync_and_unlocked() && + !is_dirty() && + !is_flushing(); + } + + xlist::item *get_updated_item() { return &more()->item_updated; } utime_t get_update_stamp() { return more()->update_stamp; } void set_update_stamp(utime_t t) { more()->update_stamp = t; } @@ -79,10 +87,10 @@ public: return have_more() ? _more->scatter_wanted : false; } - bool is_dirty() { + bool is_dirty() const { return have_more() ? _more->dirty : false; } - bool is_flushing() { + bool is_flushing() const { return have_more() ? _more->flushing : false; } diff --git a/src/mds/SimpleLock.h b/src/mds/SimpleLock.h index a686aa19ab41..1151c3305148 100644 --- a/src/mds/SimpleLock.h +++ b/src/mds/SimpleLock.h @@ -298,7 +298,7 @@ public: // state - int get_state() { return state; } + int get_state() const { return state; } int set_state(int s) { state = s; //assert(!is_stable() || gather_set.size() == 0); // gather should be empty in stable states. @@ -314,13 +314,24 @@ public: take_waiting(SimpleLock::WAIT_ALL, waiters); } - bool is_stable() { + bool is_stable() const { return get_sm()->states[state].next == 0; } int get_next_state() { return get_sm()->states[state].next; } + + bool is_sync_and_unlocked() const { + return + get_state() == LOCK_SYNC && + !is_rdlocked() && + !is_leased() && + !is_wrlocked() && + !is_xlocked(); + } + + /* bool fw_rdlock_to_auth() { return get_sm()->states[state].can_rdlock == FW; @@ -397,7 +408,7 @@ public: } // rdlock - bool is_rdlocked() { return num_rdlock > 0; } + bool is_rdlocked() const { return num_rdlock > 0; } int get_rdlock() { if (!num_rdlock) parent->get(MDSCacheObject::PIN_LOCK); @@ -426,7 +437,7 @@ public: try_clear_more(); } } - bool is_wrlocked() { return have_more() && more()->num_wrlock > 0; } + bool is_wrlocked() const { return have_more() && more()->num_wrlock > 0; } int get_num_wrlocks() { return have_more() ? more()->num_wrlock : 0; } // xlock @@ -454,7 +465,7 @@ public: try_clear_more(); } } - bool is_xlocked() { return have_more() && more()->num_xlock > 0; } + bool is_xlocked() const { return have_more() && more()->num_xlock > 0; } int get_num_xlocks() { return have_more() ? more()->num_xlock : 0; } client_t get_xlock_by_client() { return have_more() ? more()->xlock_by_client : -1; @@ -475,7 +486,7 @@ public: try_clear_more(); } } - bool is_leased() { return num_client_lease > 0; } + bool is_leased() const { return num_client_lease > 0; } int get_num_client_lease() { return num_client_lease; }