From 6eb4150528a86e038d3e349aa9f543202efa3a92 Mon Sep 17 00:00:00 2001 From: Bill Scales Date: Wed, 26 Mar 2025 10:05:07 +0000 Subject: [PATCH] osd: EC Optimizations: Add shard_id_sets for backfill_target and ... acting_recovery_backfill Optimized EC code uses shard_id_sets as a convinient and fast way of representing sets of shards. Peering calculates a backfill_target set and an active_recovery_backfill set as a map of pg_shard_ids during peering and these are then used while processing I/O requests. Modify peering so that it initializes a shard_id_set version of these two sets and makes these available to ECBackend code. Signed-off-by: Bill Scales --- src/osd/PG.h | 3 +++ src/osd/PeeringState.cc | 14 ++++++++++++++ src/osd/PeeringState.h | 9 +++++++++ 3 files changed, 26 insertions(+) diff --git a/src/osd/PG.h b/src/osd/PG.h index 907c50a6692..7ab0ece26f8 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -356,6 +356,9 @@ public: const std::set &get_acting_recovery_backfill() const { return recovery_state.get_acting_recovery_backfill(); } + const shard_id_set &get_acting_recovery_backfill_shard_id_set() const { + return recovery_state.get_acting_recovery_backfill_shard_id_set(); + } bool is_acting(pg_shard_t osd) const { return recovery_state.is_acting(osd); } diff --git a/src/osd/PeeringState.cc b/src/osd/PeeringState.cc index 5889d6d3ba5..3d0a74dcf6f 100644 --- a/src/osd/PeeringState.cc +++ b/src/osd/PeeringState.cc @@ -778,6 +778,7 @@ void PeeringState::start_peering_interval( peer_purged.clear(); acting_recovery_backfill.clear(); + acting_recovery_backfill_shard_id_set.clear(); // reset primary/replica state? if (was_old_primary || is_primary()) { @@ -969,6 +970,7 @@ void PeeringState::clear_recovery_state() { async_recovery_targets.clear(); backfill_targets.clear(); + backfill_target_shard_id_set.clear(); } void PeeringState::clear_primary_state() @@ -2556,6 +2558,12 @@ bool PeeringState::choose_acting(pg_shard_t &auth_log_shard_id, return true; want_acting.clear(); acting_recovery_backfill = want_acting_backfill; + acting_recovery_backfill_shard_id_set.clear(); + for (auto &ps : acting_recovery_backfill) { + if (ps.shard != shard_id_t::NO_SHARD) { + acting_recovery_backfill_shard_id_set.insert(ps.shard); + } + } psdout(10) << "acting_recovery_backfill is " << acting_recovery_backfill << dendl; ceph_assert( @@ -2564,6 +2572,12 @@ bool PeeringState::choose_acting(pg_shard_t &auth_log_shard_id, if (backfill_targets.empty()) { // Caller is GetInfo backfill_targets = want_backfill; + backfill_target_shard_id_set.clear(); + for (auto &&i : want_backfill) { + if (i.shard != shard_id_t::NO_SHARD) { + backfill_target_shard_id_set.insert(i.shard); + } + } } // Adding !needs_recovery() to let the async_recovery_targets reset after recovery is complete ceph_assert( diff --git a/src/osd/PeeringState.h b/src/osd/PeeringState.h index 6cc40c4d4eb..1a7323b4127 100644 --- a/src/osd/PeeringState.h +++ b/src/osd/PeeringState.h @@ -1443,6 +1443,7 @@ public: /// union of acting, recovery, and backfill targets std::set acting_recovery_backfill; + shard_id_set acting_recovery_backfill_shard_id_set; std::vector hb_stamps; @@ -1559,6 +1560,7 @@ public: std::set peer_activated; std::set backfill_targets; ///< osds to be backfilled + shard_id_set backfill_target_shard_id_set; std::set async_recovery_targets; ///< osds to be async recovered /// osds which might have objects on them which are unfound on the primary @@ -2297,6 +2299,10 @@ public: const std::set &get_backfill_targets() const { return backfill_targets; } + const shard_id_set &get_backfill_target_shard_id_set() const + { + return backfill_target_shard_id_set; + } bool is_async_recovery_target(pg_shard_t peer) const { return async_recovery_targets.count(peer); } @@ -2306,6 +2312,9 @@ public: const std::set &get_acting_recovery_backfill() const { return acting_recovery_backfill; } + const shard_id_set &get_acting_recovery_backfill_shard_id_set() const { + return acting_recovery_backfill_shard_id_set; + } const PGLog &get_pg_log() const { return pg_log; -- 2.39.5