]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd: migrate OperationThrottler to new tracking infra.
authorRadosław Zarzyński <rzarzyns@redhat.com>
Wed, 27 Apr 2022 13:51:33 +0000 (15:51 +0200)
committerRadosław Zarzyński <rzarzyns@redhat.com>
Thu, 5 May 2022 10:39:28 +0000 (12:39 +0200)
Signed-off-by: Radosław Zarzyński <rzarzyns@redhat.com>
src/crimson/osd/osd_operation.cc
src/crimson/osd/osd_operation.h
src/crimson/osd/osd_operations/background_recovery.cc
src/crimson/osd/osd_operations/background_recovery.h

index 90370d57b816fe77ffcacb5ba89db11ec5e63b2d..f3a0964700d23a4db54fb1ab2edcda76e5e4f8b7 100644 (file)
@@ -50,13 +50,13 @@ void OperationThrottler::release_throttle()
   wake();
 }
 
-blocking_future<> OperationThrottler::acquire_throttle(
+seastar::future<> OperationThrottler::acquire_throttle(
   crimson::osd::scheduler::params_t params)
 {
   crimson::osd::scheduler::item_t item{params, seastar::promise<>()};
   auto fut = item.wake.get_future();
   scheduler->enqueue(std::move(item));
-  return make_blocking_future(std::move(fut));
+  return fut;
 }
 
 void OperationThrottler::dump_detail(Formatter *f) const
index f3e4f6386d0d3fa69ce8cce24341a4821d9d31d5..054d6e3742403e3e57806e6e42c620d999af8f8a 100644 (file)
@@ -224,12 +224,7 @@ class OperationThrottler : public BlockerT<OperationThrottler>,
     crimson::osd::scheduler::params_t params,
     F &&f) {
     if (!max_in_progress) return f();
-    auto fut = acquire_throttle(params);
-    // At any given moment a particular op can  be blocked by a given
-    // OperationThrottler instance no more than once. This means the
-    // same throtter won't be on the op's blockers list more than one
-    // time.
-    return op->with_blocking_future(std::move(fut))
+    return acquire_throttle(params)
       .then(std::forward<F>(f))
       .then([this](auto x) {
        release_throttle();
@@ -237,6 +232,17 @@ class OperationThrottler : public BlockerT<OperationThrottler>,
       });
   }
 
+  template <typename OperationT, typename F>
+  seastar::future<> with_throttle_while(
+    OperationT* op,
+    crimson::osd::scheduler::params_t params,
+    F &&f) {
+    return with_throttle(op, params, f).then([this, params, op, f](bool cont) {
+      return cont ? with_throttle_while(op, params, f) : seastar::now();
+    });
+  }
+
+
 public:
   OperationThrottler(ConfigProxy &conf);
 
@@ -245,14 +251,12 @@ public:
                          const std::set<std::string> &changed) final;
   void update_from_config(const ConfigProxy &conf);
 
-  template <typename OperationT, typename F>
+  template <class OpT, class... Args>
   seastar::future<> with_throttle_while(
-    OperationT* op,
-    crimson::osd::scheduler::params_t params,
-    F &&f) {
-    return with_throttle(op, params, f).then([this, params, op, f](bool cont) {
-      return cont ? with_throttle_while(op, params, f) : seastar::now();
-    });
+    BlockingEvent::Trigger<OpT>&& trigger,
+    Args&&... args) {
+    return trigger.maybe_record_blocking(
+      with_throttle_while(std::forward<Args>(args)...), *this);
   }
 
 private:
@@ -267,7 +271,7 @@ private:
 
   void wake();
 
-  blocking_future<> acquire_throttle(
+  seastar::future<> acquire_throttle(
     crimson::osd::scheduler::params_t params);
 
   void release_throttle();
index 0c40e2705340ad11a18de57d46e0b74dd5199053..6e8319e92a5b63aa573fb43fb20a715f75532228 100644 (file)
@@ -79,19 +79,23 @@ seastar::future<> BackgroundRecoveryT<T>::start()
       std::chrono::milliseconds(std::lround(delay * 1000)));
   }
   return maybe_delay.then([ref, this] {
-    return ss.throttler.with_throttle_while(
-      this, get_scheduler_params(), [this] {
-        return T::interruptor::with_interruption([this] {
-          return do_recovery();
-        }, [](std::exception_ptr) {
-         return seastar::make_ready_future<bool>(false);
-        }, pg);
-      }).handle_exception_type([ref, this](const std::system_error& err) {
-        if (err.code() == std::make_error_code(std::errc::interrupted)) {
-          logger().debug("{} recovery interruped: {}", *pg, err.what());
-         return seastar::now();
-        }
-        return seastar::make_exception_future<>(err);
+    return this->template with_blocking_event<OperationThrottler::BlockingEvent>(
+      [ref, this] (auto&& trigger) {
+      return ss.throttler.with_throttle_while(
+        std::move(trigger),
+        this, get_scheduler_params(), [this] {
+          return T::interruptor::with_interruption([this] {
+            return do_recovery();
+          }, [](std::exception_ptr) {
+            return seastar::make_ready_future<bool>(false);
+          }, pg);
+        }).handle_exception_type([ref, this](const std::system_error& err) {
+          if (err.code() == std::make_error_code(std::errc::interrupted)) {
+            logger().debug("{} recovery interruped: {}", *pg, err.what());
+            return seastar::now();
+          }
+          return seastar::make_exception_future<>(err);
+        });
       });
   });
 }
index 1f293e12ba74da63907cb5703e72d12a4aa76475..1e5ffb29d0f309506b95c2a5e4d30725a2f67b99 100644 (file)
@@ -65,6 +65,7 @@ public:
   void print(std::ostream&) const final;
 
   std::tuple<
+    OperationThrottler::BlockingEvent,
     RecoveryBackend::RecoveryBlockingEvent
   > tracking_events;
 
@@ -84,6 +85,7 @@ public:
     float delay = 0);
 
   std::tuple<
+    OperationThrottler::BlockingEvent,
     RecoveryBackend::RecoveryBlockingEvent
   > tracking_events;
 
@@ -114,6 +116,7 @@ public:
   static BackfillRecoveryPipeline &bp(PG &pg);
 
   std::tuple<
+    OperationThrottler::BlockingEvent,
     BackfillRecoveryPipeline::Process::BlockingEvent
   > tracking_events;