From ca3ccd9559f57d674869e110fe1ee888d28fe260 Mon Sep 17 00:00:00 2001 From: Cory Snyder Date: Thu, 21 Apr 2022 13:13:22 -0400 Subject: [PATCH] bluestore: add config option to allow rocksdb iterator bounds to be disabled 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 --- src/common/options/osd.yaml.in | 6 ++++++ src/kv/RocksDBStore.cc | 26 +++++++++++++++----------- src/kv/RocksDBStore.h | 12 +++++++----- src/os/bluestore/BlueStore.cc | 15 +++------------ 4 files changed, 31 insertions(+), 28 deletions(-) diff --git a/src/common/options/osd.yaml.in b/src/common/options/osd.yaml.in index 76262edf6bb..e170364a248 100644 --- a/src/common/options/osd.yaml.in +++ b/src/common/options/osd.yaml.in @@ -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 diff --git a/src/kv/RocksDBStore.cc b/src/kv/RocksDBStore.cc index 487a2173207..065e1317901 100644 --- a/src/kv/RocksDBStore.cc +++ b/src/kv/RocksDBStore.cc @@ -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) { diff --git a/src/kv/RocksDBStore.h b/src/kv/RocksDBStore.h index 932ad249e72..f880954dd85 100644 --- a/src/kv/RocksDBStore.h +++ b/src/kv/RocksDBStore.h @@ -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); } diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index e007201cada..1263f19a4c7 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -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) { -- 2.39.5