OPTION(kinetic_use_ssl, OPT_BOOL) // whether to secure kinetic traffic with TLS
-OPTION(rocksdb_separate_wal_dir, OPT_BOOL) // use $path.wal for wal
-SAFE_OPTION(rocksdb_db_paths, OPT_STR) // path,size( path,size)*
OPTION(rocksdb_log_to_ceph_log, OPT_BOOL) // log to ceph log
OPTION(rocksdb_cache_size, OPT_U64) // rocksdb cache size (unless set by bluestore/etc)
OPTION(rocksdb_cache_row_ratio, OPT_FLOAT) // ratio of cache for row (vs block)
.set_default(false)
.set_description(""),
- Option("rocksdb_separate_wal_dir", Option::TYPE_BOOL, Option::LEVEL_ADVANCED)
- .set_default(false)
- .set_description(""),
-
- Option("rocksdb_db_paths", Option::TYPE_STR, Option::LEVEL_ADVANCED)
- .set_default("")
- .set_description("")
- .set_safe(),
-
Option("rocksdb_log_to_ceph_log", Option::TYPE_BOOL, Option::LEVEL_ADVANCED)
.set_default(true)
.set_description(""),
}
opt.create_if_missing = create_if_missing;
- if (g_conf->rocksdb_separate_wal_dir) {
+ if (kv_options.count("separate_wal_dir")) {
opt.wal_dir = path + ".wal";
}
// Since ceph::for_each_substr doesn't return a value and
// std::stoull does throw, we may as well just catch everything here.
try {
- g_conf->with_val<std::string>(
- "rocksdb_db_paths", [&opt, this](const std::string& paths) {
- ceph::for_each_substr(
- paths, "; \t",
- [&paths, &opt, this](auto s) {
- size_t pos = s.find(',');
- if (pos == std::string::npos) {
- derr << __func__ << " invalid db path item " << s << " in "
- << paths << dendl;
- throw std::system_error(std::make_error_code(
- std::errc::invalid_argument));
- }
- // And we have to use string because RocksDB doesn't know any better.
- auto path = string(s.substr(0, pos));
- auto size = std::stoull(string(s.substr(pos + 1)));
- if (!size) {
- derr << __func__ << " invalid db path item " << s << " in "
- << g_conf->get_val<std::string>("rocksdb_db_paths") << dendl;
- throw std::system_error(std::make_error_code(
- std::errc::invalid_argument));
- }
- opt.db_paths.push_back(rocksdb::DbPath(path, size));
- dout(10) << __func__ << " db_path " << path << " size " << size
- << dendl;
- });
- });
+ if (kv_options.count("db_paths")) {
+ list<string> paths;
+ get_str_list(kv_options["db_paths"], "; \t", paths);
+ for (auto& p : paths) {
+ size_t pos = p.find(',');
+ if (pos == std::string::npos) {
+ derr << __func__ << " invalid db path item " << p << " in "
+ << kv_options["db_paths"] << dendl;
+ return -EINVAL;
+ }
+ string path = p.substr(0, pos);
+ string size_str = p.substr(pos + 1);
+ uint64_t size = atoll(size_str.c_str());
+ if (!size) {
+ derr << __func__ << " invalid db path item " << p << " in "
+ << kv_options["db_paths"] << dendl;
+ return -EINVAL;
+ }
+ opt.db_paths.push_back(rocksdb::DbPath(path, size));
+ dout(10) << __func__ << " db_path " << path << " size " << size << dendl;
+ }
+ }
} catch (const std::system_error& e) {
return -e.code().value();
}
}
dout(10) << __func__ << " do_bluefs = " << do_bluefs << dendl;
+ map<string,string> kv_options;
rocksdb::Env *env = NULL;
if (do_bluefs) {
dout(10) << __func__ << " initializing bluefs" << dendl;
bluefs->get_block_device_size(BlueFS::BDEV_WAL) -
BDEV_LABEL_BLOCK_SIZE);
}
- cct->_conf->set_val("rocksdb_separate_wal_dir", "true");
+ kv_options["separate_wal_dir"] = "1";
bluefs_single_shared_device = false;
} else if (::lstat(bfn.c_str(), &st) == -1) {
- cct->_conf->set_val("rocksdb_separate_wal_dir", "false");
+ kv_options.erase("separate_wal_dir");
} else {
//symlink exist is bug
derr << __func__ << " " << bfn << " link target doesn't exist" << dendl;
<< (uint64_t)(db_size * 95 / 100) << " "
<< fn + ".slow" << ","
<< (uint64_t)(slow_size * 95 / 100);
- cct->_conf->set_val("rocksdb_db_paths", db_paths.str(), false);
- dout(10) << __func__ << " set rocksdb_db_paths to "
- << cct->_conf->get_val<std::string>("rocksdb_db_paths") << dendl;
+ kv_options["db_paths"] = db_paths.str();
+ dout(10) << __func__ << " set db_paths to " << db_paths.str() << dendl;
}
if (create) {
env->CreateDir(fn);
- if (cct->_conf->rocksdb_separate_wal_dir)
+ if (kv_options.count("separate_wal_dir"))
env->CreateDir(fn + ".wal");
-
- if (cct->_conf->with_val<std::string>(
- "rocksdb_db_paths", [](const std::string& s) {
- return s.length(); }))
- env->CreateDir(fn + ".slow");
+ if (kv_options.count("rocksdb_db_paths"))
+ env->CreateDir(fn + ".slow");
}
} else if (create) {
int r = ::mkdir(fn.c_str(), 0755);
}
// wal_dir, too!
- if (cct->_conf->rocksdb_separate_wal_dir) {
+ if (kv_options.count("separate_wal_dir")) {
string walfn = path + "/db.wal";
r = ::mkdir(walfn.c_str(), 0755);
if (r < 0)
db = KeyValueDB::create(cct,
kv_backend,
fn,
+ kv_options,
static_cast<void*>(env));
if (!db) {
derr << __func__ << " error creating db" << dendl;