From ea2babaa16f3aaae9609e97d3baa329a7c497c7d Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Sun, 11 May 2025 10:40:55 +0000 Subject: [PATCH] osd: just shuffle get_write_plan() from ECBackend to ECCommon Signed-off-by: Radoslaw Zarzynski (cherry picked from commit 9d5bf623537b8ee29e000504d752ace1c05964d7) --- src/osd/ECBackend.cc | 65 ------------------------------------------- src/osd/ECBackend.h | 11 -------- src/osd/ECCommon.cc | 66 ++++++++++++++++++++++++++++++++++++++++++++ src/osd/ECCommon.h | 10 +++++++ 4 files changed, 76 insertions(+), 76 deletions(-) diff --git a/src/osd/ECBackend.cc b/src/osd/ECBackend.cc index bb90be14885..3cdf378d1f8 100644 --- a/src/osd/ECBackend.cc +++ b/src/osd/ECBackend.cc @@ -933,18 +933,6 @@ std::tuple< return {0, real_attrs, st.st_size}; } -std::optional ECBackend::get_object_info_from_obc( - ObjectContextRef &obc) { - std::optional 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 &i) { - const auto &[oid, inner_op] = i; - auto &obc = obc_map.at(oid); - object_info_t oi = obc->obs.oi; - std::optional 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 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, diff --git a/src/osd/ECBackend.h b/src/osd/ECBackend.h index 90452f2ba1d..1796d03f14a 100644 --- a/src/osd/ECBackend.h +++ b/src/osd/ECBackend.h @@ -328,17 +328,6 @@ public: size_t > get_attrs_n_size_from_disk(const hobject_t &hoid); - static std::optional 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( diff --git a/src/osd/ECCommon.cc b/src/osd/ECCommon.cc index b8c2bdb95df..557a45aaa14 100644 --- a/src/osd/ECCommon.cc +++ b/src/osd/ECCommon.cc @@ -1561,4 +1561,70 @@ ECCommon::RecoveryBackend::recover_object( return op; } +std::optional ECBackend::get_object_info_from_obc( + ObjectContextRef &obc) { + std::optional 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 &i) { + const auto &[oid, inner_op] = i; + auto &obc = obc_map.at(oid); + object_info_t oi = obc->obs.oi; + std::optional 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 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 diff --git a/src/osd/ECCommon.h b/src/osd/ECCommon.h index cc84944a1d4..2c2684155d3 100644 --- a/src/osd/ECCommon.h +++ b/src/osd/ECCommon.h @@ -795,6 +795,16 @@ struct ECCommon { void _failed_push(const hobject_t &hoid, ECCommon::read_result_t &res); }; + static std::optional 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 { -- 2.39.5