From 5cdb7a3a8a5c8ed2ab84117507c3e09585eaa3e6 Mon Sep 17 00:00:00 2001 From: Alex Ainscow Date: Tue, 11 Mar 2025 11:00:59 +0000 Subject: [PATCH] osd: EC Switcher actually switches between two (identical) EC implementations Signed-off-by: Alex Ainscow --- src/osd/ECSwitch.h | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/osd/ECSwitch.h b/src/osd/ECSwitch.h index 9d56a6c138b..893869793ef 100644 --- a/src/osd/ECSwitch.h +++ b/src/osd/ECSwitch.h @@ -29,7 +29,7 @@ class ECSwitch : public PGBackend friend class ECReadPred; ECLegacy::ECBackendL legacy; - ECLegacy::ECBackendL optimized; + ECBackend optimized; bool is_optimized_actual; public: @@ -44,12 +44,13 @@ public: PGBackend(cct, pg, store, coll, ch), legacy(pg, cct, ec_impl, stripe_width, this), optimized(pg, cct, ec_impl, stripe_width, this), - is_optimized_actual(false) {} + is_optimized_actual(get_parent()->get_pool().allows_ecoptimizations()) {} bool is_optimized() const { - // FIXME: Interface not yet implemented. - //ceph_assert(is_optimized_actual == get_parent()->get_pool().allows_ecoptimizations()); + // FIXME: Once we trust this, we can remove this assert, as it adds + // function call overhead. + ceph_assert(is_optimized_actual == get_parent()->get_pool().allows_ecoptimizations()); return is_optimized_actual; } @@ -84,7 +85,7 @@ public: private: const ECSwitch *switcher; std::unique_ptr legacy; - std::unique_ptr optimized; + std::unique_ptr optimized; }; class ECReadPred : public IsPGReadablePredicate @@ -111,7 +112,7 @@ public: private: const ECSwitch *switcher; std::unique_ptr legacy; - std::unique_ptr optimized; + std::unique_ptr optimized; }; RecoveryHandle *open_recovery_op() override @@ -181,7 +182,11 @@ public: else { legacy.on_change(); } - //FIXME: Switch to new EC here. + + if (!is_optimized_actual) + is_optimized_actual = get_parent()->get_pool().allows_ecoptimizations(); + else + ceph_assert(get_parent()->get_pool().allows_ecoptimizations()); } void clear_recovery_state() override @@ -345,7 +350,7 @@ public: object_size_to_shard_size(const uint64_t size, int shard) const override { if (is_optimized()) { - return optimized.object_size_to_shard_size(size); + return optimized.object_size_to_shard_size(size, shard); } return legacy.object_size_to_shard_size(size); // All shards are the same size. -- 2.39.5