summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRadoslaw Zarzynski <rzarzyns@redhat.com>2024-10-15 17:40:47 +0200
committerRadoslaw Zarzynski <rzarzyns@redhat.com>2024-12-17 20:17:49 +0100
commit08508288c5ff9d9999205ab69ba50787c988214f (patch)
tree9ad995a73836d8ed6ae759382739609978007810
parentkv: avoid memcpy around key() in OMAP iterator of KeyValueDB (diff)
downloadceph-08508288c5ff9d9999205ab69ba50787c988214f.tar.xz
ceph-08508288c5ff9d9999205ab69ba50787c988214f.zip
os/bluestore: reduce dependencies of omap_iterate()'s loop on Onode
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
-rw-r--r--src/os/bluestore/BlueStore.cc24
-rw-r--r--src/os/bluestore/BlueStore.h2
2 files changed, 10 insertions, 16 deletions
diff --git a/src/os/bluestore/BlueStore.cc b/src/os/bluestore/BlueStore.cc
index 90b7062e341..9c1a44fd9a5 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 46709f1428f..67f52cf35ca 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);