]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
src/tools/kvstore_tool.cc: Move bluestore start-up code 26828/head
authorBrad Hubbard <bhubbard@redhat.com>
Fri, 8 Mar 2019 01:31:32 +0000 (11:31 +1000)
committerBrad Hubbard <bhubbard@redhat.com>
Sat, 9 Mar 2019 05:24:17 +0000 (15:24 +1000)
Move this code into a separate function to avoid ICE.

Fixes: http://tracker.ceph.com/issues/38633
Signed-off-by: Brad Hubbard <bhubbard@redhat.com>
src/tools/kvstore_tool.cc
src/tools/kvstore_tool.h

index 2d94e610c731772bb1aed2b64e1e7480f163b4f6..7ed6c9e2d09ea5bcf8b2667461b52fe413f7043e 100644 (file)
@@ -15,12 +15,8 @@ StoreTool::StoreTool(const string& type, const string& path, bool need_open_db)
 {
   if (type == "bluestore-kv") {
 #ifdef WITH_BLUESTORE
-    auto bluestore = new BlueStore(g_ceph_context, path);
-    KeyValueDB *db_ptr;
-    if (int r = bluestore->start_kv_only(&db_ptr, need_open_db); r < 0) {
+    if (load_bluestore(path, need_open_db) != 0)
       exit(1);
-    }
-    db = decltype(db){db_ptr, Deleter(bluestore)};
 #else
     cerr << "bluestore not compiled in" << std::endl;
     exit(1);
@@ -38,6 +34,18 @@ StoreTool::StoreTool(const string& type, const string& path, bool need_open_db)
   }
 }
 
+int StoreTool::load_bluestore(const string& path, bool need_open_db)
+{
+    auto bluestore = new BlueStore(g_ceph_context, path);
+    KeyValueDB *db_ptr;
+    int r = bluestore->start_kv_only(&db_ptr, need_open_db);
+    if (r < 0) {
+     return -EINVAL;
+    }
+    db = decltype(db){db_ptr, Deleter(bluestore)};
+    return 0;
+}
+
 uint32_t StoreTool::traverse(const string& prefix,
                              const bool do_crc,
                              const bool do_value_dump,
index 296ee5d9a79e58903dcc4d101b6130aebaf11f73..3203024728e9836ae57fa06e9df5703080a392c9 100644 (file)
@@ -44,6 +44,7 @@ public:
   StoreTool(const std::string& type,
            const std::string& path,
            bool need_open_db=true);
+  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,