]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd: migrate BackgroundRecovery to new tracking infra.
authorRadosław Zarzyński <rzarzyns@redhat.com>
Thu, 14 Apr 2022 11:19:36 +0000 (13:19 +0200)
committerRadosław Zarzyński <rzarzyns@redhat.com>
Thu, 5 May 2022 02:06:31 +0000 (04:06 +0200)
Signed-off-by: Radosław Zarzyński <rzarzyns@redhat.com>
src/crimson/osd/osd_operation_external_tracking.h
src/crimson/osd/osd_operations/background_recovery.cc
src/crimson/osd/osd_operations/background_recovery.h

index 8fc69d95264dcd786254f063ff8d3cfa0f7f9db2..1076fdf52ea30a5559b36c75ffde7f6e3b2a6421 100644 (file)
@@ -162,4 +162,11 @@ struct EventBackendRegistry<osd::CompoundPeeringRequest> {
   }
 };
 
+template <>
+struct EventBackendRegistry<osd::BackfillRecovery> {
+  static std::tuple<> get_backends() {
+    return {};
+  }
+};
+
 } // namespace crimson
index a340a58a7d0858a3bb33a9484c9522b431191f2a..d3f57d7dee68539bbacd3100b543f2e7020ec6e0 100644 (file)
@@ -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 <class T>
+BackgroundRecoveryT<T>::BackgroundRecoveryT(
   Ref<PG> 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 <class T>
+void BackgroundRecoveryT<T>::print(std::ostream &lhs) const
 {
   lhs << "BackgroundRecovery(" << pg->get_pgid() << ")";
 }
 
-void BackgroundRecovery::dump_detail(Formatter *f) const
+template <class T>
+void BackgroundRecoveryT<T>::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 <class T>
+seastar::future<> BackgroundRecoveryT<T>::start()
 {
   logger().debug("{}: start", *this);
 
-  IRef ref = this;
+  typename T::IRef ref = static_cast<T*>(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<bool>(false);
@@ -81,8 +86,8 @@ UrgentRecovery::UrgentRecovery(
     Ref<PG> 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<bool>(false);
   }
   // TODO: limits
-  return with_blocking_future_interruptible<interruptor::condition>(
+  return enter_stage<interruptor>(
     // 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<bool>(false);
   });
 }
 
+template class BackgroundRecoveryT<UrgentRecovery>;
+template class BackgroundRecoveryT<PglogBasedRecovery>;
+template class BackgroundRecoveryT<BackfillRecovery>;
+
 } // namespace crimson::osd
index 05fba18d1845dbd213683bd2b7c56b75bfc234b3..6f811fa9bb1e123cfedfff6a832e8aa5120acf20 100644 (file)
@@ -13,11 +13,12 @@ namespace crimson::osd {
 class PG;
 class ShardServices;
 
-class BackgroundRecovery : public TrackableOperationT<BackgroundRecovery> {
+template <class T>
+class BackgroundRecoveryT : public PhasedOperationT<T> {
 public:
   static constexpr OperationTypeCode type = OperationTypeCode::background_recovery;
 
-  BackgroundRecovery(
+  BackgroundRecoveryT(
     Ref<PG> pg,
     ShardServices &ss,
     epoch_t epoch_started,
@@ -40,7 +41,8 @@ private:
       scheduler_class
     };
   }
-  virtual interruptible_future<bool> do_recovery() = 0;
+  using do_recovery_ret_t = typename PhasedOperationT<T>::template interruptible_future<bool>;
+  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<UrgentRecovery> {
 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<PglogBasedRecovery> {
 public:
   PglogBasedRecovery(
     Ref<PG> pg,
@@ -80,7 +82,7 @@ private:
   interruptible_future<bool> do_recovery() override;
 };
 
-class BackfillRecovery final : public BackgroundRecovery {
+class BackfillRecovery final : public BackgroundRecoveryT<BackfillRecovery> {
 public:
   class BackfillRecoveryPipeline {
     struct Process : OrderedExclusivePhaseT<Process> {
@@ -99,6 +101,10 @@ public:
 
   static BackfillRecoveryPipeline &bp(PG &pg);
 
+  std::tuple<
+    BackfillRecoveryPipeline::Process::BlockingEvent
+  > tracking_events;
+
 private:
   boost::intrusive_ptr<const boost::statechart::event_base> 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,