From 87978510e63ee8b1c2400ffdd069cec3f16c3d73 Mon Sep 17 00:00:00 2001 From: Igor Fedotov Date: Fri, 16 Aug 2019 19:33:25 +0300 Subject: [PATCH] os/bluestore: introduce 'bluestore bluefs stats' admin socket command Signed-off-by: Igor Fedotov (cherry picked from commit f5568eb7209e43e6b916ea8450b2bd0c9484919a) Conflicts: src/os/bluestore/BlueFS.cc Future stuff, legacy admin command iface src/os/bluestore/BlueStore.cc Need to use legacy bluefs_shared_bdev --- src/os/bluestore/BlueFS.cc | 22 ++++++++------- src/os/bluestore/BlueFS.h | 7 +++-- src/os/bluestore/BlueStore.cc | 51 +++++++++++++++-------------------- src/os/bluestore/BlueStore.h | 2 +- 4 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/os/bluestore/BlueFS.cc b/src/os/bluestore/BlueFS.cc index 2f643e4f3cfae..11cd606f589f3 100644 --- a/src/os/bluestore/BlueFS.cc +++ b/src/os/bluestore/BlueFS.cc @@ -62,6 +62,12 @@ public: ldout(bluefs->cct, 1) << __func__ << " cannot register SocketHook" << dendl; delete hook; hook = nullptr; + } else { + r = admin_socket->register_command("bluestore bluefs stats", + "bluestore bluefs stats", + hook, + "Dump internal statistics for bluefs."); + ceph_assert(r == 0); } } return hook; @@ -69,8 +75,7 @@ public: ~SocketHook() { AdminSocket* admin_socket = bluefs->cct->get_admin_socket(); - int r = admin_socket->unregister_command("bluestore bluefs available"); - ceph_assert(r == 0); + admin_socket->unregister_commands(this); } private: SocketHook(BlueFS* bluefs) : @@ -106,6 +111,9 @@ private: f->close_section(); f->flush(ss); delete f; + } else if (command == "bluestore bluefs stats") { + bluefs->dump_block_extents(ss); + bluefs->dump_volume_selector(ss); } else { ss << "Invalid command" << std::endl; r = false; @@ -398,7 +406,6 @@ void BlueFS::dump_perf_counters(Formatter *f) void BlueFS::dump_block_extents(ostream& out) { - vselector->dump(cct); for (unsigned i = 0; i < MAX_BDEV; ++i) { if (!bdev[i]) { continue; @@ -613,7 +620,6 @@ int BlueFS::mount() _stop_alloc(); goto out; } - vselector->dump(cct); // init freelist for (auto& p : file_map) { @@ -654,8 +660,6 @@ void BlueFS::umount() super = bluefs_super_t(); log_t.clear(); _shutdown_logger(); - - vselector->dump(cct); } int BlueFS::prepare_new_device(int id) @@ -3240,9 +3244,9 @@ void OriginalVolumeSelector::get_paths(const std::string& base, paths& res) cons #undef dout_prefix #define dout_prefix *_dout << "OriginalVolumeSelector: " -void OriginalVolumeSelector::dump(CephContext* c) { - ldout(c, 1) << "wal_total:" << wal_total +void OriginalVolumeSelector::dump(ostream& sout) { + sout<< "wal_total:" << wal_total << ", db_total:" << db_total << ", slow_total:" << slow_total - << dendl; + << std::endl; } diff --git a/src/os/bluestore/BlueFS.h b/src/os/bluestore/BlueFS.h index 4f616cc739832..f922fd398b337 100644 --- a/src/os/bluestore/BlueFS.h +++ b/src/os/bluestore/BlueFS.h @@ -87,7 +87,7 @@ public: virtual void sub_usage(void* file_hint, uint64_t fsize) = 0; virtual uint8_t select_prefer_bdev(void* hint) = 0; virtual void get_paths(const std::string& base, paths& res) const = 0; - virtual void dump(CephContext* cct) = 0; + virtual void dump(ostream& sout) = 0; }; class BlueFS; @@ -518,6 +518,9 @@ public: void set_volume_selector(BlueFSVolumeSelector* s) { vselector.reset(s); } + void dump_volume_selector(ostream& sout) { + vselector->dump(sout); + } void get_vselector_paths(const std::string& base, BlueFSVolumeSelector::paths& res) const { return vselector->get_paths(base, res); @@ -618,7 +621,7 @@ public: uint8_t select_prefer_bdev(void* hint) override; void get_paths(const std::string& base, paths& res) const override; - void dump(CephContext* cct) override; + void dump(ostream& sout) override; }; #endif diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 62af0e90036b4..39e430a66cefe 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -5149,7 +5149,7 @@ int BlueStore::_open_bluefs(bool create) return r; } RocksDBBlueFSVolumeSelector* vselector = nullptr; - if (bluefs_layout.shared_bdev == BlueFS::BDEV_SLOW) { + if (bluefs_shared_bdev == BlueFS::BDEV_SLOW) { string options = cct->_conf->bluestore_rocksdb_options; @@ -14705,60 +14705,53 @@ void* RocksDBBlueFSVolumeSelector::get_hint_by_dir(const string& dirname) const return reinterpret_cast(res); } -#undef dout_prefix -#define dout_prefix *_dout << "RocksDBBlueFSVolumeSelector: " - -void RocksDBBlueFSVolumeSelector::dump(CephContext* c) { - stringstream matrix_output; +void RocksDBBlueFSVolumeSelector::dump(ostream& sout) { auto max_x = per_level_per_dev_usage.get_max_x(); auto max_y = per_level_per_dev_usage.get_max_y(); - matrix_output << "LEVEL, WAL, DB, SLOW, ****, ****, REAL" << std::endl; + sout << "RocksDBBlueFSVolumeSelector: wal_total:" << l_totals[LEVEL_WAL - LEVEL_FIRST] + << ", db_total:" << l_totals[LEVEL_DB - LEVEL_FIRST] + << ", slow_total:" << l_totals[LEVEL_SLOW - LEVEL_FIRST] + << ", db_avail:" << db_avail4slow << std::endl + << " usage matrix:" << std::endl; + sout << "LEVEL, WAL, DB, SLOW, ****, ****, REAL" << std::endl; for (size_t l = 0; l < max_y; l++) { switch (l + LEVEL_FIRST) { case LEVEL_WAL: - matrix_output << "WAL "; break; + sout << "WAL "; break; case LEVEL_DB: - matrix_output << "DB "; break; + sout << "DB "; break; case LEVEL_SLOW: - matrix_output << "SLOW" << " "; break; + sout << "SLOW" << " "; break; case LEVEL_MAX: - matrix_output << "TOTALS "; break; + sout << "TOTALS "; break; } for (size_t d = 0; d < max_x - 1; d++) { - matrix_output << per_level_per_dev_usage.at(d, l) << ","; + sout << per_level_per_dev_usage.at(d, l) << ","; } - matrix_output << per_level_per_dev_usage.at(max_x - 1, l) << std::endl; + sout << per_level_per_dev_usage.at(max_x - 1, l) << std::endl; } ceph_assert(max_x == per_level_per_dev_max.get_max_x()); ceph_assert(max_y == per_level_per_dev_max.get_max_y()); - matrix_output << "MAXIMUMS:" << std::endl; + sout << "MAXIMUMS:" << std::endl; for (size_t l = 0; l < max_y; l++) { switch (l + LEVEL_FIRST) { case LEVEL_WAL: - matrix_output << "WAL "; break; + sout << "WAL "; break; case LEVEL_DB: - matrix_output << "DB "; break; + sout << "DB "; break; case LEVEL_SLOW: - matrix_output << "SLOW" << " "; break; + sout << "SLOW" << " "; break; case LEVEL_MAX: - matrix_output << "TOTALS "; break; + sout << "TOTALS "; break; } for (size_t d = 0; d < max_x - 1; d++) { - matrix_output << per_level_per_dev_max.at(d, l) << ","; + sout << per_level_per_dev_max.at(d, l) << ","; } - matrix_output << per_level_per_dev_max.at(max_x - 1, l); + sout << per_level_per_dev_max.at(max_x - 1, l); if (l < max_y - 1) { - matrix_output << std::endl; + sout << std::endl; } } - ldout(c, 1) - << "wal_total:" << l_totals[LEVEL_WAL - LEVEL_FIRST] - << ", db_total:" << l_totals[LEVEL_DB - LEVEL_FIRST] - << ", slow_total:" << l_totals[LEVEL_SLOW - LEVEL_FIRST] - << ", db_avail:" << db_avail4slow - << " usage matrix:" << std::endl - << matrix_output.str() - << dendl; } // ======================================================= diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 3a0cf7689d309..83dba638852e7 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -3547,7 +3547,7 @@ public: const std::string& base, BlueFSVolumeSelector::paths& res) const override; - void dump(CephContext* cct) override; + void dump(ostream& sout) override; }; #endif -- 2.39.5