]> git.apps.os.sepia.ceph.com Git - ceph-ci.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)
committerCory Snyder <csnyder@iland.com>
Thu, 21 Apr 2022 17:28:09 +0000 (13:28 -0400)
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>
src/common/options/osd.yaml.in
src/kv/RocksDBStore.cc
src/kv/RocksDBStore.h
src/os/bluestore/BlueStore.cc

index 76262edf6bb062b1059666749d680296bfcbffef..e170364a248dadae37e24b10355f4a84bd529e7e 100644 (file)
@@ -1278,3 +1278,9 @@ options:
   default: 1
   flags:
   - runtime
+- name: osd_rocksdb_iterator_bounds_enabled
+  desc: Whether omap iterator bounds are applied to rocksdb iterator ReadOptions
+  type: bool
+  level: dev
+  default: true
+  with_legacy: true
index 487a2173207df68255fd75e050409dcd7e6877c3..065e1317901e0756ec8de41c7b6ae42d1ae32cfc 100644 (file)
@@ -2242,11 +2242,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);
   }
@@ -2796,11 +2798,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));
@@ -2981,7 +2985,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 932ad249e7287e1aa7963bf0435d3f7b8e545581..f880954dd85b7e03fdd455c63adcc6b030473378 100644 (file)
@@ -368,11 +368,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 e007201cada86d4e82c76be56ffeae57c38793ce..1263f19a4c710dc5892302bd8172fcd77c36c817 100644 (file)
@@ -11876,10 +11876,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) {
@@ -11964,10 +11961,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) {
@@ -16676,10 +16670,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) {