]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
kv: move 'bluestore-kv' hackery out of KeyValueDB into ceph-kvstore-tool
authorSage Weil <sage@redhat.com>
Mon, 1 May 2017 14:24:03 +0000 (10:24 -0400)
committerSage Weil <sage@redhat.com>
Mon, 1 May 2017 14:24:03 +0000 (10:24 -0400)
This avoids contaminating libkv with ObjectStore/BlueStore.  It also makes
the blustore kv startup slightly less weird (no need to skip the open
step).

Fixes: http://tracker.ceph.com/issues/19778
Signed-off-by: Sage Weil <sage@redhat.com>
src/kv/KeyValueDB.cc
src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h
src/tools/ceph_kvstore_tool.cc

index 42036e3c593859642b3591cb0555d2cbb0e2100a..7a917b7a1836f1c9304b3d827359671268feaace 100644 (file)
@@ -12,9 +12,6 @@
 #ifdef HAVE_KINETIC
 #include "KineticStore.h"
 #endif
-#ifdef HAVE_LIBAIO
-#include "os/bluestore/BlueStore.h"
-#endif
 
 KeyValueDB *KeyValueDB::create(CephContext *cct, const string& type,
                               const string& dir,
@@ -37,18 +34,6 @@ KeyValueDB *KeyValueDB::create(CephContext *cct, const string& type,
   }
 #endif
 
-#ifdef HAVE_LIBAIO
-  if (type == "bluestore-kv") {
-    // note: we'll leak this!  the only user is ceph-kvstore-tool and
-    // we don't care.
-    BlueStore *bluestore = new BlueStore(cct, dir);
-    KeyValueDB *db = nullptr;
-    int r = bluestore->start_kv_only(&db);
-    if (r < 0)
-      return nullptr;  // yes, we leak.
-    return db;
-  }
-#endif
   if ((type == "memdb") && 
     cct->check_experimental_feature_enabled("memdb")) {
     return new MemDB(cct, dir, p);
index 7b6c563edd2f818f78bc749314937435b61165c0..1d69e922677e3b3ea487140c6b14ba2ffefe4445 100644 (file)
@@ -4130,7 +4130,7 @@ bool BlueStore::test_mount_in_use()
   return ret;
 }
 
-int BlueStore::_open_db(bool create, bool kv_no_open)
+int BlueStore::_open_db(bool create)
 {
   int r;
   assert(!db);
@@ -4369,9 +4369,6 @@ int BlueStore::_open_db(bool create, bool kv_no_open)
   if (kv_backend == "rocksdb")
     options = cct->_conf->bluestore_rocksdb_options;
   db->init(options);
-  if (kv_no_open) {
-    return 0;
-  }
   if (create)
     r = db->create_and_open(err);
   else
@@ -4968,7 +4965,7 @@ int BlueStore::_mount(bool kv_only)
   if (r < 0)
     goto out_fsid;
 
-  r = _open_db(false, kv_only);
+  r = _open_db(false);
   if (r < 0)
     goto out_bdev;
 
index f910cca11809b444fb52e99dd4db8434d32ed73c..67b34dbaadac183e522e400c7d0286cfc66f19e2 100644 (file)
@@ -1906,7 +1906,7 @@ private:
 
   int _open_bdev(bool create);
   void _close_bdev();
-  int _open_db(bool create, bool kv_no_open=false);
+  int _open_db(bool create);
   void _close_db();
   int _open_fm(bool create);
   void _close_fm();
index df9ef469cc40987cf260c51e9077a5bedcb01870..adca8a71be2afda511a22ea30e9d08501cd1a887 100644 (file)
 #include "kv/KeyValueDB.h"
 #include "common/url_escape.h"
 
+#ifdef HAVE_LIBAIO
+#include "os/bluestore/BlueStore.h"
+#endif
+
 using namespace std;
 
 class StoreTool
@@ -37,12 +41,28 @@ class StoreTool
 
   public:
   StoreTool(string type, const string &path) : store_path(path) {
-    KeyValueDB *db_ptr = KeyValueDB::create(g_ceph_context, type, path);
-    int r = db_ptr->open(std::cerr);
-    if (r < 0) {
-      cerr << "failed to open type " << type << " path " << path << ": "
-          << cpp_strerror(r) << std::endl;
+    KeyValueDB *db_ptr;
+    if (type == "bluestore-kv") {
+#ifdef HAVE_LIBAIO
+      // note: we'll leak this!  the only user is ceph-kvstore-tool and
+      // we don't care.
+      BlueStore *bluestore = new BlueStore(g_ceph_context, path);
+      int r = bluestore->start_kv_only(&db_ptr);
+      if (r < 0) {
+       exit(1);
+      }
+#else
+      cerr << "bluestore not compiled in" << std::endl;
       exit(1);
+#endif
+    } else {
+      db_ptr = KeyValueDB::create(g_ceph_context, type, path);
+      int r = db_ptr->open(std::cerr);
+      if (r < 0) {
+       cerr << "failed to open type " << type << " path " << path << ": "
+            << cpp_strerror(r) << std::endl;
+       exit(1);
+      }
     }
     db.reset(db_ptr);
   }