os/bluestore: dynamically configure CFs and options via bluestore_rocksdb_cfs

Signed-off-by: Sage Weil <sage@redhat.com>
This commit is contained in:
Sage Weil 2017-10-10 15:05:39 -05:00
parent 3e56a4d056
commit 234700a0f3
2 changed files with 18 additions and 7 deletions

View File

@ -3474,6 +3474,10 @@ std::vector<Option> get_global_options() {
.set_default(false)
.set_description("Enable use of rocksdb column families for bluestore metadata"),
Option("bluestore_rocksdb_cfs", Option::TYPE_STR, Option::LEVEL_DEV)
.set_default("M= P= L=")
.set_description("List of whitespace-separate key/value pairs where key is CF name and value is CF options"),
Option("bluestore_fsck_on_mount", Option::TYPE_BOOL, Option::LEVEL_DEV)
.set_default(false)
.set_description("Run fsck at mount"),

View File

@ -24,6 +24,7 @@
#include "include/compat.h"
#include "include/intarith.h"
#include "include/stringify.h"
#include "include/str_map.h"
#include "common/errno.h"
#include "common/safe_io.h"
#include "Allocator.h"
@ -69,12 +70,6 @@ const string PREFIX_ALLOC = "B"; // u64 offset -> u64 length (freelist)
const string PREFIX_ALLOC_BITMAP = "b"; // (see BitmapFreelistManager)
const string PREFIX_SHARED_BLOB = "X"; // u64 offset -> shared_blob_t
const std::vector<KeyValueDB::ColumnFamily> cfs = {
KeyValueDB::ColumnFamily(PREFIX_OMAP, ""),
KeyValueDB::ColumnFamily(PREFIX_PGMETA_OMAP, ""),
KeyValueDB::ColumnFamily(PREFIX_DEFERRED, ""),
};
// write a label in the first block. always use this size. note that
// bluefs makes a matching assumption about the location of its
// superblock (always the second block of the device).
@ -4492,6 +4487,8 @@ int BlueStore::_open_db(bool create)
ceph::shared_ptr<Int64ArrayMergeOperator> merge_op(new Int64ArrayMergeOperator);
string kv_backend;
std::vector<KeyValueDB::ColumnFamily> cfs;
if (create) {
kv_backend = cct->_conf->bluestore_kvbackend;
} else {
@ -4739,8 +4736,18 @@ int BlueStore::_open_db(bool create)
db->set_cache_size(cache_size * cache_kv_ratio);
if (kv_backend == "rocksdb")
if (kv_backend == "rocksdb") {
options = cct->_conf->bluestore_rocksdb_options;
map<string,string> cf_map;
get_str_map(cct->_conf->get_val<string>("bluestore_rocksdb_cfs"), &cf_map,
" \t");
for (auto& i : cf_map) {
dout(10) << "column family " << i.first << ": " << i.second << dendl;
cfs.push_back(KeyValueDB::ColumnFamily(i.first, i.second));
}
}
db->init(options);
if (create) {
if (cct->_conf->get_val<bool>("bluestore_rocksdb_cf")) {