From: Radosław Zarzyński Date: Thu, 14 Apr 2022 11:19:36 +0000 (+0200) Subject: crimson/osd: migrate BackgroundRecovery to new tracking infra. X-Git-Tag: v18.0.0~947^2~20 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0fa5d9a749e6a70c8d875cc06946027cd7f19742;p=ceph.git crimson/osd: migrate BackgroundRecovery to new tracking infra. Signed-off-by: Radosław Zarzyński --- diff --git a/src/crimson/osd/osd_operation_external_tracking.h b/src/crimson/osd/osd_operation_external_tracking.h index 8fc69d95264d..1076fdf52ea3 100644 --- a/src/crimson/osd/osd_operation_external_tracking.h +++ b/src/crimson/osd/osd_operation_external_tracking.h @@ -162,4 +162,11 @@ struct EventBackendRegistry { } }; +template <> +struct EventBackendRegistry { + static std::tuple<> get_backends() { + return {}; + } +}; + } // namespace crimson diff --git a/src/crimson/osd/osd_operations/background_recovery.cc b/src/crimson/osd/osd_operations/background_recovery.cc index a340a58a7d08..d3f57d7dee68 100644 --- a/src/crimson/osd/osd_operations/background_recovery.cc +++ b/src/crimson/osd/osd_operations/background_recovery.cc @@ -9,6 +9,7 @@ #include "crimson/osd/pg.h" #include "crimson/osd/shard_services.h" #include "common/Formatter.h" +#include "crimson/osd/osd_operation_external_tracking.h" #include "crimson/osd/osd_operations/background_recovery.h" namespace { @@ -19,7 +20,8 @@ namespace { namespace crimson::osd { -BackgroundRecovery::BackgroundRecovery( +template +BackgroundRecoveryT::BackgroundRecoveryT( Ref pg, ShardServices &ss, epoch_t epoch_started, @@ -32,12 +34,14 @@ BackgroundRecovery::BackgroundRecovery( scheduler_class(scheduler_class) {} -void BackgroundRecovery::print(std::ostream &lhs) const +template +void BackgroundRecoveryT::print(std::ostream &lhs) const { lhs << "BackgroundRecovery(" << pg->get_pgid() << ")"; } -void BackgroundRecovery::dump_detail(Formatter *f) const +template +void BackgroundRecoveryT::dump_detail(Formatter *f) const { f->dump_stream("pgid") << pg->get_pgid(); f->open_object_section("recovery_detail"); @@ -47,11 +51,12 @@ void BackgroundRecovery::dump_detail(Formatter *f) const f->close_section(); } -seastar::future<> BackgroundRecovery::start() +template +seastar::future<> BackgroundRecoveryT::start() { logger().debug("{}: start", *this); - IRef ref = this; + typename T::IRef ref = static_cast(this); auto maybe_delay = seastar::now(); if (delay) { maybe_delay = seastar::sleep( @@ -60,7 +65,7 @@ seastar::future<> BackgroundRecovery::start() return maybe_delay.then([ref, this] { return ss.throttler.with_throttle_while( this, get_scheduler_params(), [this] { - return interruptor::with_interruption([this] { + return T::interruptor::with_interruption([this] { return do_recovery(); }, [](std::exception_ptr) { return seastar::make_ready_future(false); @@ -81,8 +86,8 @@ UrgentRecovery::UrgentRecovery( Ref pg, ShardServices& ss, epoch_t epoch_started) - : BackgroundRecovery{pg, ss, epoch_started, - crimson::osd::scheduler::scheduler_class_t::immediate}, + : BackgroundRecoveryT{pg, ss, epoch_started, + crimson::osd::scheduler::scheduler_class_t::immediate}, soid{soid}, need(need) { } @@ -124,7 +129,7 @@ PglogBasedRecovery::PglogBasedRecovery( ShardServices &ss, const epoch_t epoch_started, float delay) - : BackgroundRecovery( + : BackgroundRecoveryT( std::move(pg), ss, epoch_started, @@ -159,16 +164,20 @@ BackfillRecovery::do_recovery() return seastar::make_ready_future(false); } // TODO: limits - return with_blocking_future_interruptible( + return enter_stage( // process_event() of our boost::statechart machine is non-reentrant. // with the backfill_pipeline we protect it from a second entry from // the implementation of BackfillListener. // additionally, this stage serves to synchronize with PeeringEvent. - handle.enter(bp(*pg).process) + bp(*pg).process ).then_interruptible([this] { pg->get_recovery_handler()->dispatch_backfill_event(std::move(evt)); return seastar::make_ready_future(false); }); } +template class BackgroundRecoveryT; +template class BackgroundRecoveryT; +template class BackgroundRecoveryT; + } // namespace crimson::osd diff --git a/src/crimson/osd/osd_operations/background_recovery.h b/src/crimson/osd/osd_operations/background_recovery.h index 05fba18d1845..6f811fa9bb1e 100644 --- a/src/crimson/osd/osd_operations/background_recovery.h +++ b/src/crimson/osd/osd_operations/background_recovery.h @@ -13,11 +13,12 @@ namespace crimson::osd { class PG; class ShardServices; -class BackgroundRecovery : public TrackableOperationT { +template +class BackgroundRecoveryT : public PhasedOperationT { public: static constexpr OperationTypeCode type = OperationTypeCode::background_recovery; - BackgroundRecovery( + BackgroundRecoveryT( Ref pg, ShardServices &ss, epoch_t epoch_started, @@ -40,7 +41,8 @@ private: scheduler_class }; } - virtual interruptible_future do_recovery() = 0; + using do_recovery_ret_t = typename PhasedOperationT::template interruptible_future; + virtual do_recovery_ret_t do_recovery() = 0; ShardServices &ss; const crimson::osd::scheduler::scheduler_class_t scheduler_class; }; @@ -51,7 +53,7 @@ private: /// @c UrgentRecovery is not throttled by the scheduler. and it /// utilizes @c RecoveryBackend directly to recover the unreadable /// object. -class UrgentRecovery final : public BackgroundRecovery { +class UrgentRecovery final : public BackgroundRecoveryT { public: UrgentRecovery( const hobject_t& soid, @@ -68,7 +70,7 @@ private: const eversion_t need; }; -class PglogBasedRecovery final : public BackgroundRecovery { +class PglogBasedRecovery final : public BackgroundRecoveryT { public: PglogBasedRecovery( Ref pg, @@ -80,7 +82,7 @@ private: interruptible_future do_recovery() override; }; -class BackfillRecovery final : public BackgroundRecovery { +class BackfillRecovery final : public BackgroundRecoveryT { public: class BackfillRecoveryPipeline { struct Process : OrderedExclusivePhaseT { @@ -99,6 +101,10 @@ public: static BackfillRecoveryPipeline &bp(PG &pg); + std::tuple< + BackfillRecoveryPipeline::Process::BlockingEvent + > tracking_events; + private: boost::intrusive_ptr evt; PipelineHandle handle; @@ -111,7 +117,7 @@ BackfillRecovery::BackfillRecovery( ShardServices &ss, const epoch_t epoch_started, const EventT& evt) - : BackgroundRecovery( + : BackgroundRecoveryT( std::move(pg), ss, epoch_started,