]> 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>
Tue, 26 Nov 2019 18:38:15 +0000 (21:38 +0300)
Signed-off-by: Igor Fedotov <ifedotov@suse.com>
src/os/bluestore/BlueFS.cc
src/os/bluestore/BlueFS.h
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index a39abd86eff72f8862beb5a7de50e7a6e6a2de10..5b45596ce2bd7b8162e51d88a30fc18c3e3c89e9 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",
+                                           hook,
+                                           "Dump internal statistics for bluefs."
+                                           "");
+        ceph_assert(r == 0);
       }
     }
     return hook;
@@ -103,6 +109,9 @@ private:
       }
       f->dump_int("available_from_bluestore", extra_space);
       f->close_section();
+    } else if (command == "bluestore bluefs stats") {
+      bluefs->dump_block_extents(ss);
+      bluefs->dump_volume_selector(ss);
     } else {
       ss << "Invalid command" << std::endl;
       return -ENOSYS;
@@ -394,7 +403,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;
@@ -610,7 +618,6 @@ int BlueFS::mount()
     _stop_alloc();
     goto out;
   }
-  vselector->dump(cct);
 
   // init freelist
   for (auto& p : file_map) {
@@ -668,8 +675,6 @@ void BlueFS::umount()
   super = bluefs_super_t();
   log_t.clear();
   _shutdown_logger();
-
-  vselector->dump(cct);
 }
 
 int BlueFS::prepare_new_device(int id, const bluefs_layout_t& layout)
@@ -1258,7 +1263,6 @@ int BlueFS::_replay(bool noop, bool to_stdout)
 
           if (!noop) {
            FileRef f = _get_file(fnode.ino);
-<<<<<<< HEAD
             if (cct->_conf->bluefs_log_replay_check_allocations) {
               // check initial log layout
               if (first_log_check) {
@@ -1282,8 +1286,6 @@ int BlueFS::_replay(bool noop, bool to_stdout)
               }
             }
 
-           f->fnode = fnode;
-=======
             if (fnode.ino != 1) {
               vselector->sub_usage(f->vselector_hint, f->fnode);
             }
@@ -1292,7 +1294,6 @@ int BlueFS::_replay(bool noop, bool to_stdout)
               vselector->add_usage(f->vselector_hint, f->fnode);
             }
 
->>>>>>> os/bluestore: introduce volume selector abstraction to BlueFS
            if (fnode.ino > ino_last) {
              ino_last = fnode.ino;
            }
@@ -3498,9 +3499,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 9d8b8e48f2bc7b1b5182af25e179796fd51ec33c..9bca340fed69c51c6e74c0130337834d31ecd8e5 100644 (file)
@@ -90,7 +90,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;
 
@@ -516,6 +516,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 e146cf600f8e531478f65f4514db8bfefd83a9cc..81db8c095a046711bffff6eb78e9e89f9ca8d7a0 100644 (file)
@@ -15597,60 +15597,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 3652f5e5a8a4dfd8357f407f6b62528356b82aa9..63bacc0a27541d3652e95a59d09b727fd4a5d36d 100644 (file)
@@ -3686,7 +3686,7 @@ public:
     const std::string& base,
     BlueFSVolumeSelector::paths& res) const override;
 
-  void dump(CephContext* cct) override;
+  void dump(ostream& sout) override;
 };
 
 #endif