]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: reduce dependencies of omap_iterate()'s loop on Onode
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Tue, 15 Oct 2024 15:40:47 +0000 (15:40 +0000)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Tue, 14 Jan 2025 13:00:39 +0000 (13:00 +0000)
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
(cherry picked from commit 08508288c5ff9d9999205ab69ba50787c988214f)

Conflicts:
    src/os/bluestore/BlueStore.cc
      trivial conflict with Onode::finish_write() that doesn't
      exist in squid.

src/os/bluestore/BlueStore.cc
src/os/bluestore/BlueStore.h

index 1c482c505f1b8a3aa1f3e50538fd2fa2fdee0db6..ac74657940236872d95cadbc779dbcce3da0cd37 100644 (file)
@@ -4805,7 +4805,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()) {
@@ -4815,22 +4815,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());
 }
 
+
 // =======================================================
 // WriteContext
  
@@ -13531,15 +13524,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;
index c92ce9448c0ddefa46dfc77656b9f92a4e20984e..f9e8261d8e95b52f27af5260bf26416e78c2444e 100644 (file)
@@ -1428,8 +1428,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);
 
 private:
     void _decode(const ceph::buffer::list& v);