From 1c56632e88a126d0eac75235d9a9716833cba6b7 Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Tue, 5 Nov 2019 19:34:41 -0800 Subject: [PATCH] mds: define stream operator for mds_info_t This also cleans up the output to be more readable/useful in debug output. Signed-off-by: Patrick Donnelly --- PendingReleaseNotes | 4 +++- src/mds/FSMap.cc | 5 ++--- src/mds/MDSMap.cc | 25 +++++++++---------------- src/mds/MDSMap.h | 7 ++++++- 4 files changed, 20 insertions(+), 21 deletions(-) diff --git a/PendingReleaseNotes b/PendingReleaseNotes index 110f3f19bab..0a1cf7c6553 100644 --- a/PendingReleaseNotes +++ b/PendingReleaseNotes @@ -262,6 +262,8 @@ ceph config set global mon_warn_on_pool_pg_num_not_power_of_two false +* The format of MDSs in `ceph fs dump` has changed. + * The ``pg_autoscale_mode`` is now set to ``on`` by default for newly created pools, which means that Ceph will automatically manage the number of PGs. To change this behavior, or to learn more about PG @@ -287,4 +289,4 @@ ``.`` in their name. Note that this only applies to configuration options in the - monitor's database--config file parsing is not affected. \ No newline at end of file + monitor's database--config file parsing is not affected. diff --git a/src/mds/FSMap.cc b/src/mds/FSMap.cc index eb7e4120a6a..4c8cfd29557 100644 --- a/src/mds/FSMap.cc +++ b/src/mds/FSMap.cc @@ -131,9 +131,8 @@ void FSMap::print(ostream& out) const out << "Standby daemons:" << std::endl << " " << std::endl; } - for (const auto &p : standby_daemons) { - p.second.print_summary(out); - out << std::endl; + for (const auto& p : standby_daemons) { + out << p.second << std::endl; } } diff --git a/src/mds/MDSMap.cc b/src/mds/MDSMap.cc index 4ff6c8e500d..0a82aa128a1 100644 --- a/src/mds/MDSMap.cc +++ b/src/mds/MDSMap.cc @@ -92,24 +92,21 @@ void MDSMap::mds_info_t::dump(Formatter *f) const f->dump_unsigned("flags", flags); } -void MDSMap::mds_info_t::print_summary(ostream &out) const +void MDSMap::mds_info_t::dump(std::ostream& o) const { - out << global_id << ":\t" - << addrs - << " '" << name << "'" - << " mds." << rank - << "." << inc - << " " << ceph_mds_state_name(state) - << " seq " << state_seq; + o << "[mds." << name << "{" << rank << ":" << global_id << "}" + << " state " << ceph_mds_state_name(state) + << " seq " << state_seq; if (laggy()) { - out << " laggy since " << laggy_since; + o << " laggy since " << laggy_since; } if (!export_targets.empty()) { - out << " export_targets=" << export_targets; + o << " export targets " << export_targets; } if (is_frozen()) { - out << " frozen"; + o << " frozen"; } + o << " addr " << addrs << "]"; } void MDSMap::mds_info_t::generate_test_instances(std::list& ls) @@ -239,14 +236,10 @@ void MDSMap::print(ostream& out) const } for (const auto &p : foo) { - const mds_info_t& info = mds_info.at(p.second); - info.print_summary(out); - out << "\n"; + out << mds_info.at(p.second) << "\n"; } } - - void MDSMap::print_summary(Formatter *f, ostream *out) const { map by_rank; diff --git a/src/mds/MDSMap.h b/src/mds/MDSMap.h index a4a562d5cb4..7f714a52921 100644 --- a/src/mds/MDSMap.h +++ b/src/mds/MDSMap.h @@ -139,7 +139,7 @@ public: } void decode(bufferlist::const_iterator& p); void dump(Formatter *f) const; - void print_summary(ostream &out) const; + void dump(std::ostream&) const; // The long form name for use in cluster log messages` std::string human_name() const; @@ -681,4 +681,9 @@ inline ostream& operator<<(ostream &out, const MDSMap &m) { return out; } +inline std::ostream& operator<<(std::ostream& o, const MDSMap::mds_info_t& info) { + info.dump(o); + return o; +} + #endif -- 2.39.5