From 852f4da3b1c2c56f6c32dda2454e4a32ad3fc55f Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 21 Apr 2017 11:56:15 -0400 Subject: [PATCH] ceph-kvstore-tool: compact{,-prefix,-range} Signed-off-by: Sage Weil --- src/tools/ceph_kvstore_tool.cc | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/tools/ceph_kvstore_tool.cc b/src/tools/ceph_kvstore_tool.cc index 96c2734f8d8..df9ef469cc4 100644 --- a/src/tools/ceph_kvstore_tool.cc +++ b/src/tools/ceph_kvstore_tool.cc @@ -211,6 +211,16 @@ class StoreTool return 0; } + + void compact() { + db->compact(); + } + void compact_prefix(string prefix) { + db->compact_prefix(prefix); + } + void compact_range(string prefix, string start, string end) { + db->compact_range(prefix, start, end); + } }; void usage(const char *pname) @@ -227,6 +237,9 @@ void usage(const char *pname) << " set [ver |in ]\n" << " store-copy [num-keys-per-tx]\n" << " store-crc \n" + << " compact\n" + << " compact-prefix \n" + << " compact-range \n" << std::endl; } @@ -426,6 +439,24 @@ int main(int argc, const char *argv[]) uint32_t crc = st.traverse(string(), true, NULL); std::cout << "store at '" << path << "' crc " << crc << std::endl; + } else if (cmd == "compact") { + st.compact(); + } else if (cmd == "compact-prefix") { + if (argc < 5) { + usage(argv[0]); + return 1; + } + string prefix(url_unescape(argv[4])); + st.compact_prefix(prefix); + } else if (cmd == "compact-range") { + if (argc < 7) { + usage(argv[0]); + return 1; + } + string prefix(url_unescape(argv[4])); + string start(url_unescape(argv[5])); + string end(url_unescape(argv[6])); + st.compact_range(prefix, start, end); } else { std::cerr << "Unrecognized command: " << cmd << std::endl; return 1;