From 19fcec84d8d7d21e796c7624e521b60d28ee21ed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:45:59 +0200 Subject: Adding upstream version 16.2.11+ds. Signed-off-by: Daniel Baumann --- src/tools/kvstore_tool.h | 80 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 src/tools/kvstore_tool.h (limited to 'src/tools/kvstore_tool.h') diff --git a/src/tools/kvstore_tool.h b/src/tools/kvstore_tool.h new file mode 100644 index 000000000..d8c896613 --- /dev/null +++ b/src/tools/kvstore_tool.h @@ -0,0 +1,80 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#pragma once + +#include +#include +#include + +#include "acconfig.h" +#include "include/buffer_fwd.h" +#ifdef WITH_BLUESTORE +#include "os/bluestore/BlueStore.h" +#endif + +class KeyValueDB; + +class StoreTool +{ +#ifdef WITH_BLUESTORE + struct Deleter { + BlueStore *bluestore; + Deleter() + : bluestore(nullptr) {} + Deleter(BlueStore *store) + : bluestore(store) {} + void operator()(KeyValueDB *db) { + if (bluestore) { + bluestore->umount(); + delete bluestore; + } else { + delete db; + } + } + }; + std::unique_ptr db; +#else + std::unique_ptr db; +#endif + + const std::string store_path; + +public: + StoreTool(const std::string& type, + const std::string& path, + bool need_open_db = true, + bool need_stats = false); + int load_bluestore(const std::string& path, bool need_open_db); + uint32_t traverse(const std::string& prefix, + const bool do_crc, + const bool do_value_dump, + ostream *out); + void list(const std::string& prefix, + const bool do_crc, + const bool do_value_dump); + bool exists(const std::string& prefix); + bool exists(const std::string& prefix, const std::string& key); + ceph::bufferlist get(const std::string& prefix, + const std::string& key, + bool& exists); + uint64_t get_size(); + bool set(const std::string& prefix, + const std::string& key, + ceph::bufferlist& val); + bool rm(const std::string& prefix, const std::string& key); + bool rm_prefix(const std::string& prefix); + void print_summary(const uint64_t total_keys, const uint64_t total_size, + const uint64_t total_txs, const std::string& store_path, + const std::string& other_path, const int duration) const; + int copy_store_to(const std::string& type, const std::string& other_path, + const int num_keys_per_tx, const std::string& other_type); + void compact(); + void compact_prefix(const std::string& prefix); + void compact_range(const std::string& prefix, + const std::string& start, + const std::string& end); + int destructive_repair(); + + int print_stats() const; +}; -- cgit v1.2.3