From: Radoslaw Zarzynski Date: Tue, 5 May 2020 10:43:13 +0000 (+0200) Subject: crimson/osd: settle BackfillState in PGRecovery. X-Git-Tag: wip-pdonnell-testing-20200918.022351~657^2~13 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=732dd2469a052bd06a664c16557d95d207c2abd9;p=ceph-ci.git crimson/osd: settle BackfillState in PGRecovery. Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/crimson/osd/backfill_facades.h b/src/crimson/osd/backfill_facades.h index 41faca5b920..645fc898737 100644 --- a/src/crimson/osd/backfill_facades.h +++ b/src/crimson/osd/backfill_facades.h @@ -41,6 +41,10 @@ struct BackfillState::PeeringFacade { const pg_stat_t &stats) { return peering_state.update_complete_backfill_object_stats(hoid, stats); } + + PeeringFacade(PeeringState& peering_state) + : peering_state(peering_state) { + } }; // PGFacade -- a facade (in the GoF-defined meaning) simplifying the huge @@ -52,6 +56,8 @@ struct BackfillState::PGFacade { decltype(auto) get_projected_last_update() const { return pg.projected_last_update; } + + PGFacade(PG& pg) : pg(pg) {} }; } // namespace crimson::osd diff --git a/src/crimson/osd/backfill_state.h b/src/crimson/osd/backfill_state.h index a608a317bea..50a72342dcb 100644 --- a/src/crimson/osd/backfill_state.h +++ b/src/crimson/osd/backfill_state.h @@ -243,6 +243,11 @@ public: std::unique_ptr pg); ~BackfillState(); + void process_event( + boost::intrusive_ptr evt) { + backfill_machine.process_event(*std::move(evt)); + } + private: hobject_t last_backfill_started; BackfillInterval backfill_info; diff --git a/src/crimson/osd/osd_operations/background_recovery.cc b/src/crimson/osd/osd_operations/background_recovery.cc index d8db74bc9d0..f473e5a6ea5 100644 --- a/src/crimson/osd/osd_operations/background_recovery.cc +++ b/src/crimson/osd/osd_operations/background_recovery.cc @@ -108,4 +108,13 @@ seastar::future PglogBasedRecovery::do_recovery() crimson::common::local_conf()->osd_recovery_max_single_start)); } +seastar::future BackfillRecovery::do_recovery() +{ + if (pg->has_reset_since(epoch_started)) + return seastar::make_ready_future(false); + // FIXME: blocking future, limits + pg->get_recovery_handler()->dispatch_backfill_event(std::move(evt)); + return seastar::make_ready_future(false); } + +} // namespace crimson::osd diff --git a/src/crimson/osd/osd_operations/background_recovery.h b/src/crimson/osd/osd_operations/background_recovery.h index 789d7b1901a..235038544b9 100644 --- a/src/crimson/osd/osd_operations/background_recovery.h +++ b/src/crimson/osd/osd_operations/background_recovery.h @@ -72,4 +72,32 @@ public: epoch_t epoch_started); }; +class BackfillRecovery final : public BackgroundRecovery { + boost::intrusive_ptr evt; + seastar::future do_recovery() override; + +public: + template + BackfillRecovery( + Ref pg, + ShardServices &ss, + epoch_t epoch_started, + const EventT& evt); +}; + +template +BackfillRecovery::BackfillRecovery( + Ref pg, + ShardServices &ss, + const epoch_t epoch_started, + const EventT& evt) + : BackgroundRecovery( + std::move(pg), + ss, + epoch_started, + crimson::osd::scheduler::scheduler_class_t::background_best_effort), + evt(evt.intrusive_from_this()) +{} + + } diff --git a/src/crimson/osd/pg.h b/src/crimson/osd/pg.h index 0c8a7062009..647f989bc2d 100644 --- a/src/crimson/osd/pg.h +++ b/src/crimson/osd/pg.h @@ -344,7 +344,7 @@ public: } void on_backfill_reserved() final { - ceph_assert(0 == "Not implemented"); + recovery_handler->on_backfill_reserved(); } void on_backfill_canceled() final { ceph_assert(0 == "Not implemented"); diff --git a/src/crimson/osd/pg_recovery.cc b/src/crimson/osd/pg_recovery.cc index 1fd67a8de03..ec25b3fe70f 100644 --- a/src/crimson/osd/pg_recovery.cc +++ b/src/crimson/osd/pg_recovery.cc @@ -5,6 +5,7 @@ #include #include "crimson/common/type_helpers.h" +#include "crimson/osd/backfill_facades.h" #include "crimson/osd/osd_operations/background_recovery.h" #include "crimson/osd/osd_operations/peering_event.h" #include "crimson/osd/pg.h" @@ -445,3 +446,29 @@ void PGRecovery::backfilled() { ceph_abort_msg("Not implemented"); } + +void PGRecovery::dispatch_backfill_event( + boost::intrusive_ptr evt) +{ + logger().debug("{}", __func__); + backfill_state->process_event(evt); +} + +void PGRecovery::on_backfill_reserved() +{ + logger().debug("{}", __func__); + // PIMP and depedency injection for the sake unittestability. + // I'm not afraid about the performance here. + using BackfillState = crimson::osd::BackfillState; + backfill_state = std::make_unique( + *this, + std::make_unique(pg->get_peering_state()), + std::make_unique( + *static_cast(pg))); + using BackfillRecovery = crimson::osd::BackfillRecovery; + pg->get_shard_services().start_operation( + static_cast(pg), + pg->get_shard_services(), + pg->get_osdmap_epoch(), + BackfillState::Triggered{}); +} diff --git a/src/crimson/osd/pg_recovery.h b/src/crimson/osd/pg_recovery.h index afa64dc1e3e..67a87f12b1e 100644 --- a/src/crimson/osd/pg_recovery.h +++ b/src/crimson/osd/pg_recovery.h @@ -22,6 +22,10 @@ public: void start_pglogbased_recovery(); crimson::osd::blocking_future start_recovery_ops(size_t max_to_start); + void on_backfill_reserved(); + void dispatch_backfill_event( + boost::intrusive_ptr evt); + seastar::future<> stop() { return seastar::now(); } private: PGRecoveryListener* pg; @@ -77,6 +81,8 @@ private: seastar::future<> handle_scan(MOSDPGScan& m); // backfill begin + std::unique_ptr backfill_state; + void request_replica_scan( const pg_shard_t& target, const hobject_t& begin,