Skip to content

Commit 6f8c340

Browse files
committed
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 <[email protected]> (cherry picked from commit c94e604)
1 parent 31bfc7a commit 6f8c340

File tree

3 files changed

+16
-25
lines changed

3 files changed

+16
-25
lines changed

src/crimson/osd/pg_recovery.cc

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -623,47 +623,36 @@ void PGRecovery::on_pg_clean()
623623
backfill_state.reset();
624624
}
625625

626+
// PGListener wrapper to PG::start_peering_event_operation
627+
template <typename T>
628+
void PGRecovery::start_peering_event_operation_listener(T &&evt, float delay) {
629+
(void) pg->schedule_event_after(PGPeeringEventRef(
630+
std::make_shared<PGPeeringEvent>(
631+
pg->get_osdmap_epoch(),
632+
pg->get_osdmap_epoch(),
633+
std::forward<T>(evt))), delay);
634+
}
635+
626636
void PGRecovery::backfilled()
627637
{
628638
LOG_PREFIX(PGRecovery::backfilled);
629639
DEBUGDPP("", pg->get_pgid());
630-
using LocalPeeringEvent = crimson::osd::LocalPeeringEvent;
631-
std::ignore = pg->get_shard_services().start_operation<LocalPeeringEvent>(
632-
static_cast<crimson::osd::PG*>(pg),
633-
pg->get_pg_whoami(),
634-
pg->get_pgid(),
635-
pg->get_osdmap_epoch(),
636-
pg->get_osdmap_epoch(),
637-
PeeringState::Backfilled{});
640+
start_peering_event_operation_listener(PeeringState::Backfilled());
638641
}
639642

640643
void PGRecovery::request_backfill()
641644
{
642645
LOG_PREFIX(PGRecovery::request_backfill);
643646
DEBUGDPP("", pg->get_pgid());
644-
using LocalPeeringEvent = crimson::osd::LocalPeeringEvent;
645-
std::ignore = pg->get_shard_services().start_operation<LocalPeeringEvent>(
646-
static_cast<crimson::osd::PG*>(pg),
647-
pg->get_pg_whoami(),
648-
pg->get_pgid(),
649-
pg->get_osdmap_epoch(),
650-
pg->get_osdmap_epoch(),
651-
PeeringState::RequestBackfill{});
647+
start_peering_event_operation_listener(PeeringState::RequestBackfill());
652648
}
653649

654650

655651
void PGRecovery::all_replicas_recovered()
656652
{
657653
LOG_PREFIX(PGRecovery::all_replicas_recovered);
658654
DEBUGDPP("", pg->get_pgid());
659-
using LocalPeeringEvent = crimson::osd::LocalPeeringEvent;
660-
std::ignore = pg->get_shard_services().start_operation<LocalPeeringEvent>(
661-
static_cast<crimson::osd::PG*>(pg),
662-
pg->get_pg_whoami(),
663-
pg->get_pgid(),
664-
pg->get_osdmap_epoch(),
665-
pg->get_osdmap_epoch(),
666-
PeeringState::AllReplicasRecovered{});
655+
start_peering_event_operation_listener(PeeringState::AllReplicasRecovered());
667656
}
668657

669658
void PGRecovery::backfill_suspended()

src/crimson/osd/pg_recovery.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ class PGRecovery : public crimson::osd::BackfillState::BackfillListener {
138138
const hobject_t& new_last_backfill) final;
139139
bool budget_available() const final;
140140

141-
// TODO: move to start_peering_event_operation
141+
template <typename T>
142+
void start_peering_event_operation_listener(T &&evt, float delay = 0);
142143
void backfilled() final;
143144
void request_backfill();
144145
void all_replicas_recovered();

src/crimson/osd/pg_recovery_listener.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,5 @@ class PGRecoveryListener {
4343
virtual void set_pglog_based_recovery_op(
4444
crimson::osd::PglogBasedRecovery *op) = 0;
4545
virtual void reset_pglog_based_recovery_op() = 0;
46+
virtual void schedule_event_after(PGPeeringEventRef evt, float delay) = 0;
4647
};

0 commit comments

Comments
 (0)