From 6f8c34087534ca3a544824b3b6f82afe70e1491d Mon Sep 17 00:00:00 2001 From: Matan Breizman Date: Thu, 24 Apr 2025 07:57:00 +0000 Subject: [PATCH] crimson/osd/pg: Let PGListener use start_peering_event_operation PG::start_peering_event_operation is a template function while PGRecovery::pg is of PGRecoveryListener* type. We can't expose a template function through the PGRecoveryListener interface since it must be also virtual. Instead, introduce start_peering_event_operation_listener which will act as a wrapper to PG::start_peering_event_operation for PGRecovery to use freely. Signed-off-by: Matan Breizman (cherry picked from commit c94e604bbb6550109ad5945ab86f82d6d5aeb1a1) --- src/crimson/osd/pg_recovery.cc | 37 +++++++++----------------- src/crimson/osd/pg_recovery.h | 3 ++- src/crimson/osd/pg_recovery_listener.h | 1 + 3 files changed, 16 insertions(+), 25 deletions(-) diff --git a/src/crimson/osd/pg_recovery.cc b/src/crimson/osd/pg_recovery.cc index 8d14cb77eaa..fd6c1097dff 100644 --- a/src/crimson/osd/pg_recovery.cc +++ b/src/crimson/osd/pg_recovery.cc @@ -623,32 +623,28 @@ void PGRecovery::on_pg_clean() backfill_state.reset(); } +// PGListener wrapper to PG::start_peering_event_operation +template +void PGRecovery::start_peering_event_operation_listener(T &&evt, float delay) { + (void) pg->schedule_event_after(PGPeeringEventRef( + std::make_shared( + pg->get_osdmap_epoch(), + pg->get_osdmap_epoch(), + std::forward(evt))), delay); +} + void PGRecovery::backfilled() { LOG_PREFIX(PGRecovery::backfilled); DEBUGDPP("", pg->get_pgid()); - using LocalPeeringEvent = crimson::osd::LocalPeeringEvent; - std::ignore = pg->get_shard_services().start_operation( - static_cast(pg), - pg->get_pg_whoami(), - pg->get_pgid(), - pg->get_osdmap_epoch(), - pg->get_osdmap_epoch(), - PeeringState::Backfilled{}); + start_peering_event_operation_listener(PeeringState::Backfilled()); } void PGRecovery::request_backfill() { LOG_PREFIX(PGRecovery::request_backfill); DEBUGDPP("", pg->get_pgid()); - using LocalPeeringEvent = crimson::osd::LocalPeeringEvent; - std::ignore = pg->get_shard_services().start_operation( - static_cast(pg), - pg->get_pg_whoami(), - pg->get_pgid(), - pg->get_osdmap_epoch(), - pg->get_osdmap_epoch(), - PeeringState::RequestBackfill{}); + start_peering_event_operation_listener(PeeringState::RequestBackfill()); } @@ -656,14 +652,7 @@ void PGRecovery::all_replicas_recovered() { LOG_PREFIX(PGRecovery::all_replicas_recovered); DEBUGDPP("", pg->get_pgid()); - using LocalPeeringEvent = crimson::osd::LocalPeeringEvent; - std::ignore = pg->get_shard_services().start_operation( - static_cast(pg), - pg->get_pg_whoami(), - pg->get_pgid(), - pg->get_osdmap_epoch(), - pg->get_osdmap_epoch(), - PeeringState::AllReplicasRecovered{}); + start_peering_event_operation_listener(PeeringState::AllReplicasRecovered()); } void PGRecovery::backfill_suspended() diff --git a/src/crimson/osd/pg_recovery.h b/src/crimson/osd/pg_recovery.h index 9bddbcf75ec..f85709c501d 100644 --- a/src/crimson/osd/pg_recovery.h +++ b/src/crimson/osd/pg_recovery.h @@ -138,7 +138,8 @@ private: const hobject_t& new_last_backfill) final; bool budget_available() const final; - // TODO: move to start_peering_event_operation + template + void start_peering_event_operation_listener(T &&evt, float delay = 0); void backfilled() final; void request_backfill(); void all_replicas_recovered(); diff --git a/src/crimson/osd/pg_recovery_listener.h b/src/crimson/osd/pg_recovery_listener.h index 347a3b2194e..ab50b99a639 100644 --- a/src/crimson/osd/pg_recovery_listener.h +++ b/src/crimson/osd/pg_recovery_listener.h @@ -43,4 +43,5 @@ public: virtual void set_pglog_based_recovery_op( crimson::osd::PglogBasedRecovery *op) = 0; virtual void reset_pglog_based_recovery_op() = 0; + virtual void schedule_event_after(PGPeeringEventRef evt, float delay) = 0; }; -- 2.39.5