From: Radoslaw Zarzynski Date: Tue, 15 Oct 2024 15:40:47 +0000 (+0000) Subject: os/bluestore: reduce dependencies of omap_iterate()'s loop on Onode X-Git-Tag: v20.0.0~411^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=08508288c5ff9d9999205ab69ba50787c988214f;p=ceph.git os/bluestore: reduce dependencies of omap_iterate()'s loop on Onode Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc index 90b7062e341b..9c1a44fd9a57 100644 --- a/src/os/bluestore/BlueStore.cc +++ b/src/os/bluestore/BlueStore.cc @@ -4830,7 +4830,7 @@ void BlueStore::Onode::rewrite_omap_key(const string& old, string *out) out->append(old.c_str() + out->length(), old.size() - out->length()); } -void BlueStore::Onode::decode_omap_key(const string& key, string *user_key) +size_t BlueStore::Onode::calc_userkey_offset_in_omap_key() const { size_t pos = sizeof(uint64_t) + 1; if (!onode.is_pgmeta_omap()) { @@ -4840,22 +4840,15 @@ void BlueStore::Onode::decode_omap_key(const string& key, string *user_key) pos += sizeof(uint64_t); } } - *user_key = key.substr(pos); + return pos; } -void BlueStore::Onode::decode_omap_key(const std::string_view& key, std::string_view *user_key) +void BlueStore::Onode::decode_omap_key(const string& key, string *user_key) { - size_t pos = sizeof(uint64_t) + 1; - if (!onode.is_pgmeta_omap()) { - if (onode.is_perpg_omap()) { - pos += sizeof(uint64_t) + sizeof(uint32_t); - } else if (onode.is_perpool_omap()) { - pos += sizeof(uint64_t); - } - } - *user_key = key.substr(pos); + *user_key = key.substr(calc_userkey_offset_in_omap_key()); } + void BlueStore::Onode::finish_write(TransContext* txc, uint32_t offset, uint32_t length) { while (true) { @@ -13807,15 +13800,16 @@ int BlueStore::omap_iterate( // iterate! std::string tail; - ceph::timespan next_lat_acc{0}; o->get_omap_tail(&tail); + const std::string_view::size_type userkey_offset_in_dbkey = + o->calc_userkey_offset_in_omap_key(); + ceph::timespan next_lat_acc{0}; while (it->valid()) { const auto& db_key = it->raw_key_as_sv().second; if (db_key >= tail) { break; } - std::string_view user_key; - o->decode_omap_key(db_key, &user_key); + std::string_view user_key = db_key.substr(userkey_offset_in_dbkey); omap_iter_ret_t ret = f(user_key, it->value_as_sv()); if (ret == omap_iter_ret_t::STOP) { break; diff --git a/src/os/bluestore/BlueStore.h b/src/os/bluestore/BlueStore.h index 46709f1428f5..67f52cf35cac 100644 --- a/src/os/bluestore/BlueStore.h +++ b/src/os/bluestore/BlueStore.h @@ -1457,8 +1457,8 @@ public: } void rewrite_omap_key(const std::string& old, std::string *out); + size_t calc_userkey_offset_in_omap_key() const; void decode_omap_key(const std::string& key, std::string *user_key); - void decode_omap_key(const std::string_view& key, std::string_view *user_key); void finish_write(TransContext* txc, uint32_t offset, uint32_t length);