From: Igor Fedotov Date: Tue, 14 Oct 2025 13:59:48 +0000 (+0300) Subject: tools/kvstore_tool: reduce BlueStore.h exposure. X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a5228bd8a3a4c836b87f34656392b7a60085cfc5;p=ceph.git tools/kvstore_tool: reduce BlueStore.h exposure. Signed-off-by: Igor Fedotov (cherry picked from commit a123ad1cc04ca375358a6240868b03c3a0440f4b) --- diff --git a/src/tools/kvstore_tool.cc b/src/tools/kvstore_tool.cc index 04f7a9506f1..5431ef68f04 100644 --- a/src/tools/kvstore_tool.cc +++ b/src/tools/kvstore_tool.cc @@ -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, diff --git a/src/tools/kvstore_tool.h b/src/tools/kvstore_tool.h index 241b42e9852..8c2fec6cd26 100644 --- a/src/tools/kvstore_tool.h +++ b/src/tools/kvstore_tool.h @@ -10,34 +10,27 @@ #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 db; -#else - std::unique_ptr 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 };