mirror of
https://github.com/ceph/ceph
synced 2026-08-02 07:03:18 +00:00
Merge pull request #65937 from ifed01/wip-ifed-kvstore-tool-cleanup
tools/kvstore_tool: reduce BlueStore.h exposure. Reviewed-by: Kefu Chai <tchaikov@gmail.com>
This commit is contained in:
commit
ec0e508444
@ -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,
|
||||
|
||||
@ -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<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
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user