Merge pull request #14895 from liewegas/wip-19778

kv: move 'bluestore-kv' hackery out of KeyValueDB into ceph-kvstore-tool

Reviewed-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
Kefu Chai 2017-05-02 11:05:54 +08:00 committed by GitHub
commit 46da7ee760
4 changed files with 28 additions and 26 deletions

View 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);

View 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;

View 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();

View File

@ -28,6 +28,10 @@
#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);
}