]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
os/bluestore: pass rocksdb options via map, not global config
authorSage Weil <sage@redhat.com>
Mon, 20 Nov 2017 20:52:51 +0000 (14:52 -0600)
committerSage Weil <sage@redhat.com>
Tue, 6 Mar 2018 20:44:10 +0000 (14:44 -0600)
Signed-off-by: Sage Weil <sage@redhat.com>
src/common/legacy_config_opts.h
src/common/options.cc
src/kv/RocksDBStore.cc
src/os/bluestore/BlueStore.cc

index 7912e4b5fbe5dbd4578a39a2178bb025c1c0b7d1..0cc9e7546f63d8f459f78523e60691c66cc4669d 100644 (file)
@@ -839,8 +839,6 @@ OPTION(kinetic_hmac_key, OPT_STR) // kinetic key to authenticate with
 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)
index f9ead98f7c9ed0f125189b9a129fb1c76a23cc21..d5fc33aea3712947809aa348a8cbc33eea4e2733 100644 (file)
@@ -3181,15 +3181,6 @@ std::vector<Option> get_global_options() {
     .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(""),
index 148652a5106d557b28dadd67aeee0329c8a52d34..b81a103bd90b3f14e3d2fb3bbcd83eaa55886261 100644 (file)
@@ -339,39 +339,35 @@ int RocksDBStore::load_rocksdb_options(bool create_if_missing, rocksdb::Options&
   }
 
   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();
   }
index e551f922b5aa991fbed52ca0cd111e37c23ff602..e58d465847f4ee842fdfa63024dd5b01b8afe8d3 100644 (file)
@@ -4707,6 +4707,7 @@ int BlueStore::_open_db(bool create, bool to_repair_db)
   }
   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;
@@ -4820,10 +4821,10 @@ int BlueStore::_open_db(bool create, bool to_repair_db)
          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;
@@ -4867,20 +4868,16 @@ int BlueStore::_open_db(bool create, bool to_repair_db)
                << (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);
@@ -4893,7 +4890,7 @@ int BlueStore::_open_db(bool create, bool to_repair_db)
     }
 
     // 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)
@@ -4910,6 +4907,7 @@ int BlueStore::_open_db(bool create, bool to_repair_db)
   db = KeyValueDB::create(cct,
                          kv_backend,
                          fn,
+                         kv_options,
                          static_cast<void*>(env));
   if (!db) {
     derr << __func__ << " error creating db" << dendl;