]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd: move with_blocking_future from Operation to OperationT.
authorRadosław Zarzyński <rzarzyns@redhat.com>
Fri, 1 Apr 2022 18:55:42 +0000 (20:55 +0200)
committerRadosław Zarzyński <rzarzyns@redhat.com>
Thu, 5 May 2022 02:06:31 +0000 (04:06 +0200)
Buildability of this commit proves all users of `with_blocking_future()`
have the concrete operation type which is necessary on the the way
to the compile-time defined op's blocker registry.

Signed-off-by: Radosław Zarzyński <rzarzyns@redhat.com>
src/crimson/common/operation.cc
src/crimson/common/operation.h
src/crimson/osd/osd_operation.h

index 3f00b5c49a050238026a64790d630018a086353e..fc49046963fa695f4cd1bb2d1cb056bbec7a9ebb 100644 (file)
@@ -16,10 +16,15 @@ void Operation::dump(ceph::Formatter* f) const
     dump_detail(f);
     f->close_section();
   }
+#if 0
+  // TODO: implement when necessary at the leaf class layer
+  // as that's the place that will be aware about the exact
+  // type of an event container.
   f->open_array_section("blockers");
   for (auto &blocker : blockers) {
     blocker->dump(f);
   }
+#endif
   f->close_section();
   f->close_section();
 }
index 296c9e8590224c7cb3f53a071586565e4a6b077a..59016db1a2daf8a7b0b4abbc1f63a7fcbf283fa2 100644 (file)
@@ -39,7 +39,8 @@ class Blocker;
  */
 template <typename Fut>
 class blocking_future_detail {
-  friend class Operation;
+// just as a scaffolding for the transition from blocking_future
+public:
   friend class Blocker;
   Blocker *blocker;
   Fut fut;
@@ -361,51 +362,6 @@ class Operation : public boost::intrusive_ref_counter<
   virtual const char *get_type_name() const = 0;
   virtual void print(std::ostream &) const = 0;
 
-  template <typename T>
-  seastar::future<T> with_blocking_future(blocking_future<T> &&f) {
-    if (f.fut.available()) {
-      return std::move(f.fut);
-    }
-    assert(f.blocker);
-    add_blocker(f.blocker);
-    return std::move(f.fut).then_wrapped([this, blocker=f.blocker](auto &&arg) {
-      clear_blocker(blocker);
-      return std::move(arg);
-    });
-  }
-
-  template <typename InterruptCond, typename T>
-  ::crimson::interruptible::interruptible_future<InterruptCond, T>
-  with_blocking_future_interruptible(blocking_future<T> &&f) {
-    if (f.fut.available()) {
-      return std::move(f.fut);
-    }
-    assert(f.blocker);
-    add_blocker(f.blocker);
-    auto fut = std::move(f.fut).then_wrapped([this, blocker=f.blocker](auto &&arg) {
-      clear_blocker(blocker);
-      return std::move(arg);
-    });
-    return ::crimson::interruptible::interruptible_future<
-      InterruptCond, T>(std::move(fut));
-  }
-
-  template <typename InterruptCond, typename T>
-  ::crimson::interruptible::interruptible_future<InterruptCond, T>
-  with_blocking_future_interruptible(
-    blocking_interruptible_future<InterruptCond, T> &&f) {
-    if (f.fut.available()) {
-      return std::move(f.fut);
-    }
-    assert(f.blocker);
-    add_blocker(f.blocker);
-    return std::move(f.fut).template then_wrapped_interruptible(
-      [this, blocker=f.blocker](auto &&arg) {
-      clear_blocker(blocker);
-      return std::move(arg);
-    });
-  }
-
   void dump(ceph::Formatter *f) const;
   void dump_brief(ceph::Formatter *f) const;
   virtual ~Operation() = default;
@@ -415,23 +371,11 @@ class Operation : public boost::intrusive_ref_counter<
 
   registry_hook_t registry_hook;
 
-  std::vector<Blocker*> blockers;
   uint64_t id = 0;
   void set_id(uint64_t in_id) {
     id = in_id;
   }
 
-  void add_blocker(Blocker *b) {
-    blockers.push_back(b);
-  }
-
-  void clear_blocker(Blocker *b) {
-    auto iter = std::find(blockers.begin(), blockers.end(), b);
-    if (iter != blockers.end()) {
-      blockers.erase(iter);
-    }
-  }
-
   friend class OperationRegistryI;
   template <size_t>
   friend class OperationRegistryT;
index 45694acf4896f5d03e0993cd5b4fd81895defc77..c9cba7e7eb607397362e39fdc0ead4bd9373357a 100644 (file)
@@ -52,7 +52,65 @@ struct InterruptibleOperation : Operation {
 
 template <typename T>
 class OperationT : public InterruptibleOperation {
+  std::vector<Blocker*> blockers;
+
+  void add_blocker(Blocker *b) {
+    blockers.push_back(b);
+  }
+
+  void clear_blocker(Blocker *b) {
+    auto iter = std::find(blockers.begin(), blockers.end(), b);
+    if (iter != blockers.end()) {
+      blockers.erase(iter);
+    }
+  }
+
 public:
+  template <typename U>
+  seastar::future<U> with_blocking_future(blocking_future<U> &&f) {
+    if (f.fut.available()) {
+      return std::move(f.fut);
+    }
+    assert(f.blocker);
+    add_blocker(f.blocker);
+    return std::move(f.fut).then_wrapped([this, blocker=f.blocker](auto &&arg) {
+      clear_blocker(blocker);
+      return std::move(arg);
+    });
+  }
+
+  template <typename InterruptCond, typename U>
+  ::crimson::interruptible::interruptible_future<InterruptCond, U>
+  with_blocking_future_interruptible(blocking_future<U> &&f) {
+    if (f.fut.available()) {
+      return std::move(f.fut);
+    }
+    assert(f.blocker);
+    add_blocker(f.blocker);
+    auto fut = std::move(f.fut).then_wrapped([this, blocker=f.blocker](auto &&arg) {
+      clear_blocker(blocker);
+      return std::move(arg);
+    });
+    return ::crimson::interruptible::interruptible_future<
+      InterruptCond, U>(std::move(fut));
+  }
+
+  template <typename InterruptCond, typename U>
+  ::crimson::interruptible::interruptible_future<InterruptCond, U>
+  with_blocking_future_interruptible(
+    blocking_interruptible_future<InterruptCond, U> &&f) {
+    if (f.fut.available()) {
+      return std::move(f.fut);
+    }
+    assert(f.blocker);
+    add_blocker(f.blocker);
+    return std::move(f.fut).template then_wrapped_interruptible(
+      [this, blocker=f.blocker](auto &&arg) {
+      clear_blocker(blocker);
+      return std::move(arg);
+    });
+  }
+
   static constexpr const char *type_name = OP_NAMES[static_cast<int>(T::type)];
   using IRef = boost::intrusive_ptr<T>;