]> 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>
Fri, 21 Mar 2025 17:26:18 +0000 (20:26 +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>
src/os/bluestore/BlueFS.cc
src/os/bluestore/BlueFS.h
src/os/bluestore/bluestore_tool.cc

index 7279549405b154aebb0d9c3190fff203a4148752..f301badfbe0c45d9bda6163197546352246e36e8 100644 (file)
@@ -1861,6 +1861,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 f0c565003b8a5b9f6aeb91e06d37a971de6d881b..e0676d7967f31f6e462664e852208f00a4f5b704 100644 (file)
@@ -687,6 +687,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 31c7e33c31d2a8cf565ee5dafc387e420c4ac191..0983af7bca4e09fda8a290b86b75126fc9bd2dd4 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;
@@ -340,6 +359,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, "
@@ -513,6 +533,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;
@@ -1001,6 +1022,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";