]> git-server-git.apps.pok.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)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Wed, 13 Aug 2025 19:20:23 +0000 (19:20 +0000)
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/osd/ECBackend.cc
src/osd/ECBackend.h
src/osd/ECCommon.cc
src/osd/ECCommon.h

index 85dffa81e4530f201e550d808d07dbaba34ff3b9..13af474b9dc7bf3d5b37ed9432906e85bd450cd1 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 7768b7a4efb365e68cc319f848effc84697fa9d3..2eccee123b53ebad179f01bd7d8099ae943dcfc2 100644 (file)
@@ -338,17 +338,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 3ef800dae914aa905281feba8405ce5a3d0b1466..9484ea3a82e8f8dab08d877b8371f4f05b73c5d7 100644 (file)
@@ -1614,4 +1614,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 fda29744787238b900e55341e5b9b377f60b7495..97b5b6e1068c94c219deffb3fc180d9302db4da0 100644 (file)
@@ -808,6 +808,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 {