]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/KeyValueStore: rename osd_keyvaluedb -> keyvaluestore_backend 2163/head
authorSage Weil <sage@redhat.com>
Wed, 30 Jul 2014 04:41:56 +0000 (21:41 -0700)
committerSage Weil <sage@redhat.com>
Wed, 30 Jul 2014 04:43:42 +0000 (21:43 -0700)
This option should be keyvaluestore_*, not osd_*.

Clean up the backend instantiation.

Signed-off-by: xinxin shu <xinxin.shu@intel.com>
Signed-off-by: Sage Weil <sage@redhat.com>
src/common/config_opts.h
src/os/KeyValueStore.cc
src/os/KeyValueStore.h

index 054136b8b11381378736dbd627654dddef3c99f5..6c034a54a4b3093119a63fb7433020835ad037e0 100644 (file)
@@ -570,8 +570,6 @@ OPTION(leveldb_paranoid, OPT_BOOL, false) // leveldb paranoid flag
 OPTION(leveldb_log, OPT_STR, "/dev/null")  // enable leveldb log file
 OPTION(leveldb_compact_on_mount, OPT_BOOL, false)
 
-OPTION(osd_keyvaluedb, OPT_STR, "leveldb")
-
 OPTION(kinetic_host, OPT_STR, "") // hostname or ip address of a kinetic drive to use
 OPTION(kinetic_port, OPT_INT, 8123) // port number of the kinetic drive
 OPTION(kinetic_user_id, OPT_INT, 1) // kinetic user to authenticate as
@@ -708,6 +706,7 @@ OPTION(keyvaluestore_op_thread_suicide_timeout, OPT_INT, 180)
 OPTION(keyvaluestore_default_strip_size, OPT_INT, 4096) // Only affect new object
 OPTION(keyvaluestore_max_expected_write_size, OPT_U64, 1ULL << 24) // bytes
 OPTION(keyvaluestore_header_cache_size, OPT_INT, 4096)    // Header cache size
+OPTION(keyvaluestore_backend, OPT_STR, "leveldb")
 
 // max bytes to search ahead in journal searching for corruption
 OPTION(journal_max_corrupt_search, OPT_U64, 10<<20)
index b184f53cfc4d6b2dafed68ec59402e80b28edbbe..668105698b5688f8c9abc283af06fc118d90315c 100644 (file)
@@ -478,7 +478,6 @@ KeyValueStore::KeyValueStore(const std::string &base,
   internal_name(name),
   basedir(base),
   fsid_fd(-1), current_fd(-1),
-  kv_type(KV_TYPE_NONE),
   backend(NULL),
   ondisk_finisher(g_ceph_context),
   lock("KeyValueStore::lock"),
@@ -616,26 +615,18 @@ int KeyValueStore::mkfs()
     goto close_fsid_fd;
   }
 
-  if (_detect_backend()) {
-    derr << "KeyValueStore::mkfs error in _detect_backend" << dendl;
-    ret = -1;
-    goto close_fsid_fd;
-  }
-
   {
-    KeyValueDB *store;
-    if (kv_type == KV_TYPE_LEVELDB) {
-      store = new LevelDBStore(g_ceph_context, current_fn);
-#ifdef HAVE_KINETIC
-    } else if (kv_type == KV_TYPE_KINETIC) {
-      store = new KineticStore(g_ceph_context);
-#endif
-    } else {
-      derr << "KeyValueStore::mkfs error: unknown backend type" << kv_type << dendl;
+    KeyValueDB *store = KeyValueDB::create(g_ceph_context,
+                                          g_conf->keyvaluestore_backend,
+                                          current_fn.c_str());
+    if(! store)
+    {
+      derr << "KeyValueStore::mkfs backend type "
+          << g_conf->keyvaluestore_backend << " error" << dendl;
       ret = -1;
       goto close_fsid_fd;
-    }
 
+    }
     store->init();
     stringstream err;
     if (store->create_and_open(err)) {
@@ -820,25 +811,18 @@ int KeyValueStore::mount()
 
   assert(current_fd >= 0);
 
-  if (_detect_backend()) {
-    derr << "KeyValueStore::mount error in _detect_backend" << dendl;
-    ret = -1;
-    goto close_current_fd;
-  }
-
   {
-    KeyValueDB *store;
-    if (kv_type == KV_TYPE_LEVELDB) {
-      store = new LevelDBStore(g_ceph_context, current_fn);
-#ifdef HAVE_KINETIC
-    } else if (kv_type == KV_TYPE_KINETIC) {
-      store = new KineticStore(g_ceph_context);
-#endif
-    } else {
-      derr << "KeyValueStore::mount error: unknown backend type" << kv_type
-           << dendl;
+
+    KeyValueDB *store = KeyValueDB::create(g_ceph_context,
+                                          g_conf->keyvaluestore_backend,
+                                          current_fn.c_str());
+    if(! store)
+    {
+      derr << "KeyValueStore::mount backend type "
+          << g_conf->keyvaluestore_backend << " error" << dendl;
       ret = -1;
-      goto close_current_fd;
+      goto close_fsid_fd;
+
     }
 
     store->init();
index fd07055d9a75dca9587bbe8be4c4c1f59a8d3dbe..7bb15ca675738029d6143a940457efa2d0d25589 100644 (file)
@@ -41,14 +41,6 @@ using namespace std;
 
 #include "include/uuid.h"
 
-enum kvstore_types {
-    KV_TYPE_NONE = 0,
-    KV_TYPE_LEVELDB,
-    KV_TYPE_KINETIC,
-    KV_TYPE_OTHER
-};
-
-
 static uint64_t default_strip_size = 1024;
 
 class StripObjectMap: public GenericObjectMap {
@@ -186,8 +178,6 @@ class KeyValueStore : public ObjectStore,
 
   int fsid_fd, current_fd;
 
-  enum kvstore_types kv_type;
-
   deque<uint64_t> snaps;
 
   // ObjectMap
@@ -466,17 +456,6 @@ class KeyValueStore : public ObjectStore,
                 bool update_to=false);
   ~KeyValueStore();
 
-  int _detect_backend() {
-    if (g_conf->osd_keyvaluedb == "leveldb")
-      kv_type = KV_TYPE_LEVELDB;
-#ifdef HAVE_KINETIC
-    else if (g_conf->osd_keyvaluedb == "kinetic")
-      kv_type = KV_TYPE_KINETIC;
-#endif
-    else
-      return -EINVAL;
-    return 0;
-  }
   bool test_mount_in_use();
   int version_stamp_is_valid(uint32_t *version);
   int update_version_stamp();