]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/osd/snaptrim_event: preserve interrupt condition when creating
authorXuehan Xu <xxhdx1985126@gmail.com>
Fri, 5 May 2023 05:22:11 +0000 (05:22 +0000)
committerXuehan Xu <xxhdx1985126@gmail.com>
Fri, 5 May 2023 05:22:11 +0000 (05:22 +0000)
subops

Signed-off-by: Xuehan Xu <xxhdx1985126@gmail.com>
src/crimson/osd/osd_operations/snaptrim_event.cc
src/crimson/osd/shard_services.h

index b35a5de095d3fa1e4c73a14d6eb5c79d89948247..e63e78481ac1b60fa840f5a48ac24a7f658335c3 100644 (file)
@@ -145,7 +145,8 @@ SnapTrimEvent::with_pg(
         }
         for (const auto& object : to_trim) {
           logger().debug("{}: trimming {}", *this, object);
-          auto [op, fut] = shard_services.start_operation<SnapTrimObjSubEvent>(
+          auto [op, fut] = shard_services.start_operation_may_interrupt<
+           interruptor, SnapTrimObjSubEvent>(
             pg,
             object,
             snapid);
index 79ea0db5fa6f106d4c509b97dab13d3ae3c3d9f2..12bb23ac2ab8135392499cea9b058954b48cb947 100644 (file)
@@ -143,6 +143,28 @@ class PerShardState {
     return std::make_pair(std::move(op), std::move(fut));
   }
 
+  template <typename InterruptorT, typename T, typename... Args>
+  auto start_operation_may_interrupt(Args&&... args) {
+    assert_core();
+    if (__builtin_expect(stopping, false)) {
+      throw crimson::common::system_shutdown_exception();
+    }
+    auto op = registry.create_operation<T>(std::forward<Args>(args)...);
+    crimson::get_logger(ceph_subsys_osd).info(
+      "PerShardState::{}, {}", __func__, *op);
+    auto fut = InterruptorT::make_interruptible(
+      seastar::yield()
+    ).then_interruptible([op] {
+      return op->start().finally([op /* by copy */] {
+       // ensure the op's lifetime is appropriate. It is not enough to
+       // guarantee it's alive at the scheduling stages (i.e. `then()`
+       // calling) but also during the actual execution (i.e. when passed
+       // lambdas are actually run).
+      });
+    });
+    return std::make_pair(std::move(op), std::move(fut));
+  }
+
   // tids for ops i issue, prefixed with core id to ensure uniqueness
   ceph_tid_t next_tid;
   ceph_tid_t get_tid() {
@@ -373,6 +395,12 @@ public:
     return local_state.start_operation<T>(std::forward<Args>(args)...);
   }
 
+  template <typename InterruptorT, typename T, typename... Args>
+  auto start_operation_may_interrupt(Args&&... args) {
+    return local_state.start_operation_may_interrupt<
+      InterruptorT, T>(std::forward<Args>(args)...);
+  }
+
   auto &get_registry() { return local_state.registry; }
 
   // Loggers