From 5d5902a6b65bbb23892c216daf32b453ffbce674 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Tue, 29 Jul 2014 21:41:56 -0700 Subject: [PATCH] os/KeyValueStore: rename osd_keyvaluedb -> keyvaluestore_backend This option should be keyvaluestore_*, not osd_*. Clean up the backend instantiation. Signed-off-by: xinxin shu Signed-off-by: Sage Weil --- src/common/config_opts.h | 3 +-- src/os/KeyValueStore.cc | 52 ++++++++++++++-------------------------- src/os/KeyValueStore.h | 21 ---------------- 3 files changed, 19 insertions(+), 57 deletions(-) diff --git a/src/common/config_opts.h b/src/common/config_opts.h index 054136b8b1138..6c034a54a4b30 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -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) diff --git a/src/os/KeyValueStore.cc b/src/os/KeyValueStore.cc index b184f53cfc4d6..668105698b568 100644 --- a/src/os/KeyValueStore.cc +++ b/src/os/KeyValueStore.cc @@ -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(); diff --git a/src/os/KeyValueStore.h b/src/os/KeyValueStore.h index fd07055d9a75d..7bb15ca675738 100644 --- a/src/os/KeyValueStore.h +++ b/src/os/KeyValueStore.h @@ -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 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(); -- 2.39.5