From 7c59c3749021e9113dfb777c197f70709f416ce6 Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Wed, 10 Jan 2024 14:08:11 -0500 Subject: [PATCH] mds: pretty print mutation when dumping lock Now looks like: ... (iquiesce xlock x=1 by request(mds.0:2785 nref=6)) ... instead of: ... (iquiesce xlock x=1 by 0xdeadbeef)) ... Signed-off-by: Patrick Donnelly --- src/mds/SimpleLock.cc | 26 ++++++++++++++++++++++++++ src/mds/SimpleLock.h | 23 +---------------------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/src/mds/SimpleLock.cc b/src/mds/SimpleLock.cc index 43f710ec68a..70d277bd10c 100644 --- a/src/mds/SimpleLock.cc +++ b/src/mds/SimpleLock.cc @@ -108,3 +108,29 @@ std::vector SimpleLock::get_active_caches() { } return result; } + +void SimpleLock::_print(std::ostream& out) const +{ + out << get_lock_type_name(get_type()) << " "; + out << get_state_name(get_state()); + if (!get_gather_set().empty()) + out << " g=" << get_gather_set(); + if (is_leased()) + out << " l"; + if (is_rdlocked()) + out << " r=" << get_num_rdlocks(); + if (is_wrlocked()) + out << " w=" << get_num_wrlocks(); + if (is_xlocked()) { + out << " x=" << get_num_xlocks(); + if (auto mut = get_xlock_by(); mut) { + out << " by " << *mut; + } + } +#if 0 + if (is_stable()) + out << " stable"; + else + out << " unstable"; +#endif +} diff --git a/src/mds/SimpleLock.h b/src/mds/SimpleLock.h index d0b6578302d..f0fef93e1c6 100644 --- a/src/mds/SimpleLock.h +++ b/src/mds/SimpleLock.h @@ -581,28 +581,7 @@ public: return false; } - void _print(std::ostream& out) const { - out << get_lock_type_name(get_type()) << " "; - out << get_state_name(get_state()); - if (!get_gather_set().empty()) - out << " g=" << get_gather_set(); - if (is_leased()) - out << " l"; - if (is_rdlocked()) - out << " r=" << get_num_rdlocks(); - if (is_wrlocked()) - out << " w=" << get_num_wrlocks(); - if (is_xlocked()) { - out << " x=" << get_num_xlocks(); - if (get_xlock_by()) - out << " by " << get_xlock_by(); - } - /*if (is_stable()) - out << " stable"; - else - out << " unstable"; - */ - } + void _print(std::ostream& out) const; /** * Write bare values (caller must be in an object section) -- 2.39.5