]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
tools/ceph-bluestore-tool: introduce bluefs-super-dump command.
authorIgor Fedotov <igor.fedotov@croit.io>
Thu, 6 Mar 2025 20:44:11 +0000 (23:44 +0300)
committerIgor Fedotov <igor.fedotov@croit.io>
Tue, 29 Apr 2025 09:27:40 +0000 (12:27 +0300)
This is a rework of Adam's commit:
https://github.com/ceph/ceph/pull/62069/commits/c8e57c4e06691bef7718277267e7590ae695bd02

Signed-off-by: Igor Fedotov <igor.fedotov@croit.io>
(cherry picked from commit e9d3ea827568afb6063db2ed4fe222b455e5ddec)

src/os/bluestore/BlueFS.cc
src/os/bluestore/BlueFS.h
src/os/bluestore/bluestore_tool.cc

index ebc49cff7352605b60b21008edcf604f310afc8e..041ff732f7030e407e0667095b775dcaa61d2917 100644 (file)
@@ -1847,6 +1847,26 @@ int BlueFS::_replay(bool noop, bool to_stdout)
   return 0;
 }
 
+int BlueFS::super_dump()
+{
+  // only dump superblock's content
+  _init_logger();
+  int r = _open_super();
+  if (r < 0) {
+    derr << __func__ << " failed to open super: " << cpp_strerror(r) << dendl;
+    return r;
+  }
+  ceph::JSONFormatter f(true);
+  f.open_object_section("superblock");
+  super.dump(&f);
+  f.close_section();
+  f.flush(std::cout);
+
+  _shutdown_logger();
+  super = bluefs_super_t();
+  return r;
+}
+
 int BlueFS::log_dump()
 {
   // only dump log file's content
index 67a262aeaa11f531ccf992f3885809aaa49c17b0..ee8f50149c545a67d0daa2737235bd6f2652934e 100644 (file)
@@ -691,6 +691,7 @@ public:
   int prepare_new_device(int id, const bluefs_layout_t& layout);
   
   int log_dump();
+  int super_dump();
 
   void collect_metadata(std::map<std::string,std::string> *pm, unsigned skip_bdev_id);
   void get_devices(std::set<std::string> *ls);
index b8cd83a5801cb208a2a4c9fe18cad1d29fbc431f..3244a0044744f8431946e6a7595b5f98e4cdd334 100644 (file)
@@ -214,6 +214,25 @@ void log_dump(
   delete fs;
 }
 
+void super_dump(
+  CephContext *cct,
+  const string& path,
+  const vector<string>& devs)
+{
+  validate_path(cct, path, true);
+  BlueFS *fs = new BlueFS(cct);
+
+  add_devices(fs, cct, devs);
+  int r = fs->super_dump();
+  if (r < 0) {
+    cerr << "super_dump failed" << ": "
+         << cpp_strerror(r) << std::endl;
+    exit(EXIT_FAILURE);
+  }
+
+  delete fs;
+}
+
 void inferring_bluefs_devices(vector<string>& devs, std::string& path)
 {
   cout << "inferring bluefs devices from bluestore path" << std::endl;
@@ -338,6 +357,7 @@ int main(int argc, char **argv)
         "set-label-key, "
         "rm-label-key, "
         "prime-osd-dir, "
+        "bluefs-super-dump, "
         "bluefs-log-dump, "
         "free-dump, "
         "free-score, "
@@ -510,6 +530,7 @@ int main(int argc, char **argv)
   }
   if (action == "bluefs-export" || 
       action == "bluefs-import" || 
+      action == "bluefs-super-dump" ||
       action == "bluefs-log-dump") {
     if (path.empty()) {
       cerr << "must specify bluestore path" << std::endl;
@@ -975,6 +996,8 @@ int main(int argc, char **argv)
     delete fs;
   } else if (action == "bluefs-log-dump") {
     log_dump(cct.get(), path, devs);
+  } else if (action == "bluefs-super-dump") {
+    super_dump(cct.get(), path, devs);
   } else if (action == "bluefs-bdev-new-db" || action == "bluefs-bdev-new-wal") {
     map<string, int> cur_devs_map;
     bool need_db = action == "bluefs-bdev-new-db";