]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
bluestore: add config option to allow rocksdb iterator bounds to be disabled
authorCory Snyder <csnyder@iland.com>
Thu, 21 Apr 2022 17:13:22 +0000 (13:13 -0400)
committerAdam Kupczyk <akupczyk@redhat.com>
Fri, 29 Apr 2022 22:37:02 +0000 (00:37 +0200)
Add osd_rocksdb_iterator_bounds_enabled config option to allow rocksdb iterator bounds to be disabled.
Also includes minor refactoring to shorten code associated with IteratorBounds initialization in bluestore.

Signed-off-by: Cory Snyder <csnyder@iland.com>
(cherry picked from commit ca3ccd9)

Conflicts:
src/common/options/osd.yaml.in

Cherry-pick notes:
- Conflicts due to option definition in common/options.cc in Pacific vs. common/options/osd.yaml.in in later releases

src/common/legacy_config_opts.h
src/common/options.cc
src/kv/RocksDBStore.cc
src/kv/RocksDBStore.h
src/os/bluestore/BlueStore.cc

index 059113b8cc782e8b6046a8448f62157ccb10e43a..3dbd1fe464a8359ba8f8c0788779cb022fe13d0c 100644 (file)
@@ -768,6 +768,7 @@ OPTION(osd_failsafe_full_ratio, OPT_FLOAT) // what % full makes an OSD "full" (f
 OPTION(osd_fast_shutdown, OPT_BOOL)
 OPTION(osd_fast_shutdown_notify_mon, OPT_BOOL) // tell mon the OSD is shutting down on osd_fast_shutdown
 OPTION(osd_fast_fail_on_connection_refused, OPT_BOOL) // immediately mark OSDs as down once they refuse to accept connections
+OPTION(osd_rocksdb_iterator_bounds_enabled, OPT_BOOL) // whether omap iterator bounds are applied to rocksdb iterator ReadOptions
 
 OPTION(osd_pg_object_context_cache_count, OPT_INT)
 OPTION(osd_tracing, OPT_BOOL) // true if LTTng-UST tracepoints should be enabled
index 9a073faa9ed4619588b3371e445072c5505cbdec..7fda073872332d296ec47c30df715a98c8d48eaf 100644 (file)
@@ -3798,6 +3798,10 @@ std::vector<Option> get_global_options() {
     .set_flag(Option::FLAG_RUNTIME)
     .set_description("Time in seconds to sleep before next removal transaction when data is on HDD and journal is on SSD"),
 
+    Option("osd_rocksdb_iterator_bounds_enabled", Option::TYPE_BOOL, Option::LEVEL_DEV)
+    .set_default(true)
+    .set_description("Whether omap iterator bounds are applied to rocksdb iterator ReadOptions"),
+
     Option("osd_failsafe_full_ratio", Option::TYPE_FLOAT, Option::LEVEL_ADVANCED)
     .set_default(.97)
     .set_description(""),
index dcfa645dc01c545ab541a27c542919ecee76d082..d7a5ee707047dcfad4f0bfc45dd6b4840a6170c9 100644 (file)
@@ -2250,11 +2250,13 @@ public:
       iterate_upper_bound(make_slice(bounds.upper_bound))
       {
       auto options = rocksdb::ReadOptions();
-      if (bounds.lower_bound) {
-        options.iterate_lower_bound = &iterate_lower_bound;
-      }
-      if (bounds.upper_bound) {
-        options.iterate_upper_bound = &iterate_upper_bound;
+      if (db->cct->_conf->osd_rocksdb_iterator_bounds_enabled) {
+        if (bounds.lower_bound) {
+          options.iterate_lower_bound = &iterate_lower_bound;
+        }
+        if (bounds.upper_bound) {
+          options.iterate_upper_bound = &iterate_upper_bound;
+        }
       }
       dbiter = db->db->NewIterator(options, cf);
   }
@@ -2804,11 +2806,13 @@ public:
   {
     iters.reserve(shards.size());
     auto options = rocksdb::ReadOptions();
-    if (bounds.lower_bound) {
-      options.iterate_lower_bound = &iterate_lower_bound;
-    }
-    if (bounds.upper_bound) {
-      options.iterate_upper_bound = &iterate_upper_bound;
+    if (db->cct->_conf->osd_rocksdb_iterator_bounds_enabled) {
+      if (bounds.lower_bound) {
+        options.iterate_lower_bound = &iterate_lower_bound;
+      }
+      if (bounds.upper_bound) {
+        options.iterate_upper_bound = &iterate_upper_bound;
+      }
     }
     for (auto& s : shards) {
       iters.push_back(db->db->NewIterator(options, s));
@@ -2989,7 +2993,7 @@ KeyValueDB::Iterator RocksDBStore::get_iterator(const std::string& prefix, Itera
     rocksdb::ColumnFamilyHandle* cf = nullptr;
     if (cf_it->second.handles.size() == 1) {
       cf = cf_it->second.handles[0];
-    } else {
+    } else if (cct->_conf->osd_rocksdb_iterator_bounds_enabled) {
       cf = get_cf_handle(prefix, bounds);
     }
     if (cf) {
index 37833bf74a4d3da8fa82b04b2e8a85355e7ae2f4..a64e69b1d1d6cb0f6b1afef9e982d83dd8c6c01e 100644 (file)
@@ -369,11 +369,13 @@ public:
         rocksdb::ReadOptions options = rocksdb::ReadOptions();
         if (opts & ITERATOR_NOCACHE)
           options.fill_cache=false;
-        if (bounds.lower_bound) {
-          options.iterate_lower_bound = &iterate_lower_bound;
-        }
-        if (bounds.upper_bound) {
-          options.iterate_upper_bound = &iterate_upper_bound;
+        if (db->cct->_conf->osd_rocksdb_iterator_bounds_enabled) {
+          if (bounds.lower_bound) {
+            options.iterate_lower_bound = &iterate_lower_bound;
+          }
+          if (bounds.upper_bound) {
+            options.iterate_upper_bound = &iterate_upper_bound;
+          }
         }
         dbiter = db->db->NewIterator(options, cf);
     }
index 43a206e552512ba74034b722b67f7d4a295b2939..b9ee17fbfe8305e9738b4232bc15e85a14f9f623 100644 (file)
@@ -11004,10 +11004,7 @@ int BlueStore::_onode_omap_get(
     string head, tail;
     o->get_omap_header(&head);
     o->get_omap_tail(&tail);
-    auto bounds = KeyValueDB::IteratorBounds();
-    bounds.lower_bound = head;
-    bounds.upper_bound = tail;
-    KeyValueDB::Iterator it = db->get_iterator(prefix, 0, std::move(bounds));
+    KeyValueDB::Iterator it = db->get_iterator(prefix, 0, KeyValueDB::IteratorBounds{head, tail});
     it->lower_bound(head);
     while (it->valid()) {
       if (it->key() == head) {
@@ -11092,10 +11089,7 @@ int BlueStore::omap_get_keys(
     string head, tail;
     o->get_omap_key(string(), &head);
     o->get_omap_tail(&tail);
-    auto bounds = KeyValueDB::IteratorBounds();
-    bounds.lower_bound = head;
-    bounds.upper_bound = tail;
-    KeyValueDB::Iterator it = db->get_iterator(prefix, 0, std::move(bounds));
+    KeyValueDB::Iterator it = db->get_iterator(prefix, 0, KeyValueDB::IteratorBounds{head, tail});
     it->lower_bound(head);
     while (it->valid()) {
       if (it->key() >= tail) {
@@ -15557,10 +15551,7 @@ int BlueStore::_clone(TransContext *txc,
     string head, tail;
     oldo->get_omap_header(&head);
     oldo->get_omap_tail(&tail);
-    auto bounds = KeyValueDB::IteratorBounds();
-    bounds.lower_bound = head;
-    bounds.upper_bound = tail;
-    KeyValueDB::Iterator it = db->get_iterator(prefix, 0, std::move(bounds));
+    KeyValueDB::Iterator it = db->get_iterator(prefix, 0, KeyValueDB::IteratorBounds{head, tail});
     it->lower_bound(head);
     while (it->valid()) {
       if (it->key() >= tail) {