]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
osd: shuffle UnstableHashInfoRegistry to ECCommon
authorRadosław Zarzyński <rzarzyns@redhat.com>
Tue, 28 Nov 2023 13:55:58 +0000 (14:55 +0100)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Wed, 10 Jan 2024 17:30:28 +0000 (17:30 +0000)
Signed-off-by: Radosław Zarzyński <rzarzyns@redhat.com>
src/osd/ECBackend.cc
src/osd/ECBackend.h
src/osd/ECCommon.cc
src/osd/ECCommon.h

index 4a537766d0b546170b47ca1962855af0c2e55b72..472acdf8848762621c82938e833888479de2745f 100644 (file)
@@ -1408,54 +1408,6 @@ void ECBackend::submit_transaction(
   rmw_pipeline.start_rmw(std::move(op));
 }
 
-ECUtil::HashInfoRef ECBackend::UnstableHashInfoRegistry::maybe_put_hash_info(
-  const hobject_t &hoid,
-  ECUtil::HashInfo &&hinfo)
-{
-  return registry.lookup_or_create(hoid, hinfo);
-}
-
-ECUtil::HashInfoRef ECBackend::UnstableHashInfoRegistry::get_hash_info(
-  const hobject_t &hoid,
-  bool create,
-  const map<string, bufferlist, less<>>& attrs,
-  uint64_t size)
-{
-  dout(10) << __func__ << ": Getting attr on " << hoid << dendl;
-  ECUtil::HashInfoRef ref = registry.lookup(hoid);
-  if (!ref) {
-    dout(10) << __func__ << ": not in cache " << hoid << dendl;
-    ECUtil::HashInfo hinfo(ec_impl->get_chunk_count());
-    bufferlist bl;
-    map<string, bufferlist>::const_iterator k = attrs.find(ECUtil::get_hinfo_key());
-    if (k == attrs.end()) {
-      dout(5) << __func__ << " " << hoid << " missing hinfo attr" << dendl;
-    } else {
-      bl = k->second;
-    }
-    if (bl.length() > 0) {
-      auto bp = bl.cbegin();
-      try {
-        decode(hinfo, bp);
-      } catch(...) {
-        dout(0) << __func__ << ": Can't decode hinfo for " << hoid << dendl;
-        return ECUtil::HashInfoRef();
-      }
-      if (hinfo.get_total_chunk_size() != size) {
-        dout(0) << __func__ << ": Mismatch of total_chunk_size "
-                      << hinfo.get_total_chunk_size() << dendl;
-        return ECUtil::HashInfoRef();
-      }
-    } else if (size == 0) { // If empty object and no hinfo, create it
-      create = true;
-    }
-    if (create) {
-      ref = registry.lookup_or_create(hoid, hinfo);
-    }
-  }
-  return ref;
-}
-
 int ECBackend::objects_read_sync(
   const hobject_t &hoid,
   uint64_t off,
index 745ad4546b68a6e557985db845ef294f1d4f71ba..1f10269947a4bdcaa1864cdf4f59787b975434bd 100644 (file)
@@ -324,29 +324,7 @@ public:
 
   const ECUtil::stripe_info_t sinfo;
 
-  class UnstableHashInfoRegistry {
-    CephContext *cct;
-    ceph::ErasureCodeInterfaceRef ec_impl;
-    /// If modified, ensure that the ref is held until the update is applied
-    SharedPtrRegistry<hobject_t, ECUtil::HashInfo> registry;
-
-  public:
-    UnstableHashInfoRegistry(
-      CephContext *cct,
-      ceph::ErasureCodeInterfaceRef ec_impl)
-      : cct(cct),
-       ec_impl(std::move(ec_impl)) {}
-
-    ECUtil::HashInfoRef maybe_put_hash_info(
-      const hobject_t &hoid,
-      ECUtil::HashInfo &&hinfo);
-
-    ECUtil::HashInfoRef get_hash_info(
-      const hobject_t &hoid,
-      bool create,
-      const std::map<std::string, ceph::buffer::list, std::less<>>& attr,
-      uint64_t size);
-  } unstable_hashinfo_registry;
+  ECCommon::UnstableHashInfoRegistry unstable_hashinfo_registry;
 
   int object_stat(const hobject_t &hoid, struct stat* st);
 
index e1bbfce7796ce82952038236b0d9c2c05cb3f481..2c6534d081f157803f4036c3e6c8d5d154b00c54 100644 (file)
@@ -58,6 +58,11 @@ static ostream& _prefix(std::ostream *_dout, ECCommon::RMWPipeline *rmw_pipeline
 static ostream& _prefix(std::ostream *_dout, ECCommon::ReadPipeline *read_pipeline) {
   return read_pipeline->get_parent()->gen_dbg_prefix(*_dout);
 }
+static ostream& _prefix(std::ostream *_dout,
+                       ECCommon::UnstableHashInfoRegistry *unstable_hash_info_registry) {
+  // TODO: backref to ECListener?
+  return *_dout;
+}
 
 ostream &operator<<(ostream &lhs, const ECCommon::RMWPipeline::pipeline_state_t &rhs) {
   switch (rhs.pipeline_state) {
@@ -1074,3 +1079,51 @@ void ECCommon::RMWPipeline::call_write_ordered(std::function<void(void)> &&cb) {
     cb();
   }
 }
+
+ECUtil::HashInfoRef ECCommon::UnstableHashInfoRegistry::maybe_put_hash_info(
+  const hobject_t &hoid,
+  ECUtil::HashInfo &&hinfo)
+{
+  return registry.lookup_or_create(hoid, hinfo);
+}
+
+ECUtil::HashInfoRef ECCommon::UnstableHashInfoRegistry::get_hash_info(
+  const hobject_t &hoid,
+  bool create,
+  const map<string, bufferlist, less<>>& attrs,
+  uint64_t size)
+{
+  dout(10) << __func__ << ": Getting attr on " << hoid << dendl;
+  ECUtil::HashInfoRef ref = registry.lookup(hoid);
+  if (!ref) {
+    dout(10) << __func__ << ": not in cache " << hoid << dendl;
+    ECUtil::HashInfo hinfo(ec_impl->get_chunk_count());
+    bufferlist bl;
+    map<string, bufferlist>::const_iterator k = attrs.find(ECUtil::get_hinfo_key());
+    if (k == attrs.end()) {
+      dout(5) << __func__ << " " << hoid << " missing hinfo attr" << dendl;
+    } else {
+      bl = k->second;
+    }
+    if (bl.length() > 0) {
+      auto bp = bl.cbegin();
+      try {
+        decode(hinfo, bp);
+      } catch(...) {
+        dout(0) << __func__ << ": Can't decode hinfo for " << hoid << dendl;
+        return ECUtil::HashInfoRef();
+      }
+      if (hinfo.get_total_chunk_size() != size) {
+        dout(0) << __func__ << ": Mismatch of total_chunk_size "
+                      << hinfo.get_total_chunk_size() << dendl;
+        return ECUtil::HashInfoRef();
+      }
+    } else if (size == 0) { // If empty object and no hinfo, create it
+      create = true;
+    }
+    if (create) {
+      ref = registry.lookup_or_create(hoid, hinfo);
+    }
+  }
+  return ref;
+}
index 46f8bb14772b54917b7c16a7b5ed68040998b4b3..83e1712b0438eeb9655907ee195d7bbac8c7e333 100644 (file)
@@ -17,6 +17,7 @@
 #include <boost/intrusive/set.hpp>
 #include <boost/intrusive/list.hpp>
 
+#include "common/sharedptr_registry.hpp"
 #include "erasure-code/ErasureCodeInterface.h"
 #include "ECUtil.h"
 #if WITH_SEASTAR
@@ -581,6 +582,30 @@ struct ECCommon {
         ec_backend(ec_backend) {
     }
   };
+
+  class UnstableHashInfoRegistry {
+    CephContext *cct;
+    ceph::ErasureCodeInterfaceRef ec_impl;
+    /// If modified, ensure that the ref is held until the update is applied
+    SharedPtrRegistry<hobject_t, ECUtil::HashInfo> registry;
+
+  public:
+    UnstableHashInfoRegistry(
+      CephContext *cct,
+      ceph::ErasureCodeInterfaceRef ec_impl)
+      : cct(cct),
+       ec_impl(std::move(ec_impl)) {}
+
+    ECUtil::HashInfoRef maybe_put_hash_info(
+      const hobject_t &hoid,
+      ECUtil::HashInfo &&hinfo);
+
+    ECUtil::HashInfoRef get_hash_info(
+      const hobject_t &hoid,
+      bool create,
+      const std::map<std::string, ceph::buffer::list, std::less<>>& attr,
+      uint64_t size);
+  };
 };
 
 std::ostream &operator<<(std::ostream &lhs,