]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: just shuffle get_write_plan() from ECBackend to ECCommon
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Sun, 11 May 2025 10:40:55 +0000 (10:40 +0000)
committerAlex Ainscow <aainscow@uk.ibm.com>
Wed, 17 Sep 2025 08:43:26 +0000 (09:43 +0100)
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
(cherry picked from commit 9d5bf623537b8ee29e000504d752ace1c05964d7)

src/osd/ECBackend.cc
src/osd/ECBackend.h
src/osd/ECCommon.cc
src/osd/ECCommon.h

index bb90be1488569b2a05c2c7ccc21645cc5c069d17..3cdf378d1f83a2c7d0320db69f46cdcb8f06b2a4 100644 (file)
@@ -933,18 +933,6 @@ std::tuple<
   return {0, real_attrs, st.st_size};
 }
 
-std::optional<object_info_t> ECBackend::get_object_info_from_obc(
-    ObjectContextRef &obc) {
-  std::optional<object_info_t> ret;
-
-  auto attr_cache = obc->attr_cache;
-  if (!attr_cache.contains(OI_ATTR))
-    return ret;
-
-  ret.emplace(attr_cache.at(OI_ATTR));
-  return ret;
-}
-
 void ECBackend::submit_transaction(
   const hobject_t &hoid,
   const object_stat_sum_t &delta_stats,
@@ -1000,59 +988,6 @@ void ECBackend::submit_transaction(
   rmw_pipeline.start_rmw(std::move(op));
 }
 
-ECTransaction::WritePlan ECBackend::get_write_plan(
-  const ECUtil::stripe_info_t &sinfo,
-  PGTransaction &t,
-  ECCommon::ReadPipeline &read_pipeline,
-  ECCommon::RMWPipeline &rmw_pipeline,
-  DoutPrefixProvider *dpp) {
-  ECTransaction::WritePlan plans;
-  auto obc_map = t.obc_map;
-  t.safe_create_traverse(
-    [&](std::pair<const hobject_t, PGTransaction::ObjectOperation> &i) {
-      const auto &[oid, inner_op] = i;
-      auto &obc = obc_map.at(oid);
-      object_info_t oi = obc->obs.oi;
-      std::optional<object_info_t> soi;
-
-      hobject_t source;
-      if (inner_op.has_source(&source)) {
-        if (!inner_op.is_rename()) {
-          soi = get_object_info_from_obc(obc_map.at(source));
-        }
-      }
-
-      uint64_t old_object_size = 0;
-      bool object_in_cache = false;
-      if (rmw_pipeline.extent_cache.contains_object(oid)) {
-        /* We have a valid extent cache for this object. If we need to read, we
-         * need to behave as if the object is already the size projected by the
-         * extent cache, or we may not read enough data.
-         */
-        old_object_size = rmw_pipeline.extent_cache.get_projected_size(oid);
-        object_in_cache = true;
-      } else {
-        std::optional<object_info_t> old_oi = get_object_info_from_obc(obc);
-        if (old_oi && !inner_op.delete_first) {
-          old_object_size = old_oi->size;
-        }
-      }
-
-      auto [readable_shards, writable_shards] =
-        read_pipeline.get_readable_writable_shard_id_sets();
-      ECTransaction::WritePlanObj plan(oid, inner_op, sinfo, readable_shards,
-                                       writable_shards,
-                                       object_in_cache, old_object_size,
-                                       oi, soi,
-                                       rmw_pipeline.ec_pdw_write_mode);
-
-      if (plan.to_read) plans.want_read = true;
-      plans.plans.emplace_back(std::move(plan));
-  });
-  ldpp_dout(dpp, 20) << __func__ << " plans=" << plans << dendl;
-  return plans;
-}
-
 int ECBackend::objects_read_sync(
     const hobject_t &hoid,
     uint64_t off,
index 90452f2ba1d847f2d2dfb2ef12a9969713bdbdcc..1796d03f14a9dbc881237fdc0c7033c0439636b9 100644 (file)
@@ -328,17 +328,6 @@ public:
     size_t
   > get_attrs_n_size_from_disk(const hobject_t &hoid);
 
-  static std::optional<object_info_t> get_object_info_from_obc(
-      ObjectContextRef &obc_map
-    );
-
-  static ECTransaction::WritePlan get_write_plan(
-    const ECUtil::stripe_info_t &sinfo,
-    PGTransaction &t,
-    ECCommon::ReadPipeline &read_pipeline,
-    ECCommon::RMWPipeline &rmw_pipeline,
-    DoutPrefixProvider *dpp);
-
  public:
   int object_stat(const hobject_t &hoid, struct stat *st);
   ECBackend(
index b8c2bdb95df7f437dad1c277f2bddf4e237eb205..557a45aaa14a0d05a467d073a61a74201c1b61e1 100644 (file)
@@ -1561,4 +1561,70 @@ ECCommon::RecoveryBackend::recover_object(
   return op;
 }
 
+std::optional<object_info_t> ECBackend::get_object_info_from_obc(
+    ObjectContextRef &obc) {
+  std::optional<object_info_t> ret;
+
+  auto attr_cache = obc->attr_cache;
+  if (!attr_cache.contains(OI_ATTR))
+    return ret;
+
+  ret.emplace(attr_cache.at(OI_ATTR));
+  return ret;
+}
+
+ECTransaction::WritePlan ECBackend::get_write_plan(
+  const ECUtil::stripe_info_t &sinfo,
+  PGTransaction &t,
+  ECCommon::ReadPipeline &read_pipeline,
+  ECCommon::RMWPipeline &rmw_pipeline,
+  DoutPrefixProvider *dpp) {
+  ECTransaction::WritePlan plans;
+  auto obc_map = t.obc_map;
+  t.safe_create_traverse(
+    [&](std::pair<const hobject_t, PGTransaction::ObjectOperation> &i) {
+      const auto &[oid, inner_op] = i;
+      auto &obc = obc_map.at(oid);
+      object_info_t oi = obc->obs.oi;
+      std::optional<object_info_t> soi;
+
+      hobject_t source;
+      if (inner_op.has_source(&source)) {
+        if (!inner_op.is_rename()) {
+          soi = get_object_info_from_obc(obc_map.at(source));
+        }
+      }
+
+      uint64_t old_object_size = 0;
+      bool object_in_cache = false;
+      if (rmw_pipeline.extent_cache.contains_object(oid)) {
+        /* We have a valid extent cache for this object. If we need to read, we
+         * need to behave as if the object is already the size projected by the
+         * extent cache, or we may not read enough data.
+         */
+        old_object_size = rmw_pipeline.extent_cache.get_projected_size(oid);
+        object_in_cache = true;
+      } else {
+        std::optional<object_info_t> old_oi = get_object_info_from_obc(obc);
+        if (old_oi && !inner_op.delete_first) {
+          old_object_size = old_oi->size;
+        }
+      }
+
+      auto [readable_shards, writable_shards] =
+        read_pipeline.get_readable_writable_shard_id_sets();
+      ECTransaction::WritePlanObj plan(oid, inner_op, sinfo, readable_shards,
+                                       writable_shards,
+                                       object_in_cache, old_object_size,
+                                       oi, soi,
+                                       rmw_pipeline.ec_pdw_write_mode);
+
+      if (plan.to_read) plans.want_read = true;
+      plans.plans.emplace_back(std::move(plan));
+  });
+  ldpp_dout(dpp, 20) << __func__ << " plans=" << plans << dendl;
+  return plans;
+}
+
+
 END_IGNORE_DEPRECATED
index cc84944a1d46e93dce66c13c211ae1cee72661a8..2c2684155d3fd11b4224e8873d80120dc1f480df 100644 (file)
@@ -795,6 +795,16 @@ struct ECCommon {
     void _failed_push(const hobject_t &hoid, ECCommon::read_result_t &res);
   };
 
+  static std::optional<object_info_t> get_object_info_from_obc(
+      ObjectContextRef &obc_map
+    );
+
+  static ECTransaction::WritePlan get_write_plan(
+    const ECUtil::stripe_info_t &sinfo,
+    PGTransaction &t,
+    ECCommon::ReadPipeline &read_pipeline,
+    ECCommon::RMWPipeline &rmw_pipeline,
+    DoutPrefixProvider *dpp);
 };
 
 struct RecoveryMessages {