]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
bluestore/tools: Add option 'dump' to ceph-kvstore-tool to print both key and values.
authorAdam Kupczyk <akupczyk@redhat.com>
Mon, 26 Nov 2018 15:27:28 +0000 (16:27 +0100)
committerAdam Kupczyk <akupczyk@redhat.com>
Tue, 4 Dec 2018 08:19:26 +0000 (09:19 +0100)
Signed-off-by: Adam Kupczyk <akupczyk@redhat.com>
doc/man/8/ceph-kvstore-tool.rst
src/test/cli/ceph-kvstore-tool/help.t
src/tools/ceph_kvstore_tool.cc

index 7ef0ab3e2b9f17b96c8e8c091bd4cdf94dc97ed0..d7b88f08aac7ceb3ee580d8f6812dfe363387d4c 100644 (file)
@@ -30,6 +30,9 @@ which are as follows:
 :command:`list-crc [prefix]`
     Print CRC of all KV pairs stored with the URL encoded prefix.
 
+:command:`dump [prefix]`
+    Print key and value of all KV pairs stored with the URL encoded prefix.
+
 :command:`exists <prefix> [key]`
     Check if there is any KV pair stored with the URL encoded prefix. If key
     is also specified, check for the key with the prefix instead.
index 0d6041a44bfd207acdaf05a0033aa63a46566f82..d27fddc08446b65ba90d09561a0194efbf93762a 100644 (file)
@@ -4,6 +4,7 @@
   Commands:
     list [prefix]
     list-crc [prefix]
+    dump [prefix]
     exists <prefix> [key]
     get <prefix> <key> [out <file>]
     crc <prefix> <key>
index 4f73b1ea8e855680538b781c8e4fa483459b3dc3..bf446cd233aa30d78e8089bdaab8121f83a287ef 100644 (file)
@@ -89,6 +89,7 @@ class StoreTool
 
   uint32_t traverse(const string &prefix,
                     const bool do_crc,
+                    const bool do_value_dump,
                     ostream *out) {
     KeyValueDB::WholeSpaceIterator iter = db->get_wholespace_iterator();
 
@@ -119,14 +120,22 @@ class StoreTool
       }
       if (out)
         *out << std::endl;
+      if (out && do_value_dump) {
+       bufferptr bp = iter->value_as_ptr();
+       bufferlist value;
+       value.append(bp);
+       ostringstream os;
+       value.hexdump(os);
+       std::cout << os.str() << std::endl;
+      }
       iter->next();
     }
 
     return crc;
   }
 
-  void list(const string &prefix, const bool do_crc) {
-    traverse(prefix, do_crc, &std::cout);
+  void list(const string &prefix, const bool do_crc, const bool do_value_dump) {
+    traverse(prefix, do_crc, do_value_dump, &std::cout);
   }
 
   bool exists(const string &prefix) {
@@ -297,6 +306,7 @@ void usage(const char *pname)
     << "Commands:\n"
     << "  list [prefix]\n"
     << "  list-crc [prefix]\n"
+    << "  dump [prefix]\n"
     << "  exists <prefix> [key]\n"
     << "  get <prefix> <key> [out <file>]\n"
     << "  crc <prefix> <key>\n"
@@ -378,8 +388,13 @@ int main(int argc, const char *argv[])
       prefix = url_unescape(argv[4]);
 
     bool do_crc = (cmd == "list-crc");
+    st.list(prefix, do_crc, false);
 
-    st.list(prefix, do_crc);
+  } else if (cmd == "dump") {
+    string prefix;
+    if (argc > 4)
+      prefix = url_unescape(argv[4]);
+    st.list(prefix, false, true);
 
   } else if (cmd == "exists") {
     string key;
@@ -580,7 +595,7 @@ int main(int argc, const char *argv[])
       return 1;
     }
     std::ofstream fs(argv[4]);
-    uint32_t crc = st.traverse(string(), true, &fs);
+    uint32_t crc = st.traverse(string(), true, false, &fs);
     std::cout << "store at '" << argv[4] << "' crc " << crc << std::endl;
 
   } else if (cmd == "compact") {