]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
tools/kvstore_tool: reduce BlueStore.h exposure.
authorIgor Fedotov <igor.fedotov@croit.io>
Tue, 14 Oct 2025 13:59:48 +0000 (16:59 +0300)
committerIgor Fedotov <igor.fedotov@croit.io>
Wed, 15 Apr 2026 22:14:24 +0000 (01:14 +0300)
Signed-off-by: Igor Fedotov <igor.fedotov@croit.io>
(cherry picked from commit a123ad1cc04ca375358a6240868b03c3a0440f4b)

src/tools/kvstore_tool.cc
src/tools/kvstore_tool.h

index 04f7a9506f1da32cbe67ca00617b82ef6eccadba..5431ef68f046b5f4833119c295ddb6e00a600e78 100644 (file)
@@ -34,13 +34,8 @@ StoreTool::StoreTool(const string& type,
   }
 
   if (type == "bluestore-kv") {
-#ifdef WITH_BLUESTORE
     if (load_bluestore(path, read_only, to_repair) != 0)
       exit(1);
-#else
-    cerr << "bluestore not compiled in" << std::endl;
-    exit(1);
-#endif
   } else {
     auto db_ptr = KeyValueDB::create(g_ceph_context, type, path);
     if (!to_repair) {
@@ -55,21 +50,24 @@ StoreTool::StoreTool(const string& type,
   }
 }
 
-#ifdef WITH_BLUESTORE
 
 int StoreTool::load_bluestore(const string& path, bool read_only, bool to_repair)
 {
+#ifdef WITH_BLUESTORE
     auto bluestore = new BlueStore(g_ceph_context, path);
     KeyValueDB *db_ptr;
     int r = bluestore->open_db_environment(&db_ptr, read_only, to_repair);
     if (r < 0) {
      return -EINVAL;
     }
-    db = decltype(db){db_ptr, Deleter(bluestore)};
+    db = decltype(db){db_ptr, Deleter((ObjectStore*)bluestore)};
     return 0;
+#else
+    cerr << "bluestore not compiled in" << std::endl;
+    return -1;
+#endif // WITH_BLUESTORE
 }
 
-#endif // WITH_BLUESTORE
 
 uint32_t StoreTool::traverse(const string& prefix,
                              const bool do_crc,
index 241b42e9852c043bb78fd32f9a2b0cbd7e00be3d..8c2fec6cd266a19674cfc1528b71cc40d60a27c7 100644 (file)
 #include "acconfig.h"
 #include "include/buffer_fwd.h"
 #include "kv/KeyValueDB.h"
-#ifdef WITH_BLUESTORE
-#include "os/bluestore/BlueStore.h"
-#endif
+#include "os/ObjectStore.h"
 
 class KeyValueDB;
 
 class StoreTool
 {
-#ifdef WITH_BLUESTORE
   struct Deleter {
-    BlueStore *bluestore;
-    Deleter()
-      : bluestore(nullptr) {}
-    Deleter(BlueStore *store)
-      : bluestore(store) {}
+    ObjectStore *store = nullptr;
+    Deleter() {}
+    Deleter(ObjectStore *_store)
+      : store(_store) {}
     void operator()(KeyValueDB *db) {
-      if (bluestore) {
-       bluestore->umount();
-       delete bluestore;
+      if (store) {
+       store->umount();
+       delete store;
       } else {
        delete db;
       }
     }
   };
   std::unique_ptr<KeyValueDB, Deleter> db;
-#else
-  std::unique_ptr<KeyValueDB> db;
-#endif
 
   const std::string store_path;
 
@@ -80,8 +73,6 @@ public:
   int print_stats() const;
   int build_size_histogram(const std::string& prefix) const;
 
-#ifdef WITH_BLUESTORE
 private:
   int load_bluestore(const std::string& path, bool read_only, bool need_open_db);
-#endif // WITH_BLUESTORE
 };