]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: introduce 'bluestore bluefs stats' admin socket command
authorIgor Fedotov <ifedotov@suse.com>
Fri, 16 Aug 2019 16:33:25 +0000 (19:33 +0300)
committerIgor Fedotov <ifedotov@suse.com>
Wed, 8 Apr 2020 16:31:14 +0000 (19:31 +0300)
Signed-off-by: Igor Fedotov <ifedotov@suse.com>
(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
src/os/bluestore/BlueFS.h
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index 2f643e4f3cfae0334d471d989a91d2d182edac92..11cd606f589f37ea48a85ce148964a9c665fee62 100644 (file)
@@ -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;
 }
index 4f616cc739832269a5a2f8c3b82f8d7e7854fa1d..f922fd398b337c00f14e0ba91d4e0f5d00f01e5e 100644 (file)
@@ -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
index 62af0e90036b44b4f714cb3aa5f51b911accd643..39e430a66cefecce33ac6e40460acf1be6d0c705 100644 (file)
@@ -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<void*>(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;
 }
 
 // =======================================================
index 3a0cf7689d3093f3026ea202df7989d7adf10e4e..83dba638852e7ef906daf8386b5d389e35239c7e 100644 (file)
@@ -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