]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd/snaptrim_event: preserve interrupt condition when creating 51643/head
authorXuehan Xu <xxhdx1985126@gmail.com>
Fri, 5 May 2023 05:22:11 +0000 (05:22 +0000)
committerMatan Breizman <mbreizma@redhat.com>
Sun, 21 May 2023 09:41:49 +0000 (09:41 +0000)
subops

Signed-off-by: Xuehan Xu <xxhdx1985126@gmail.com>
(cherry picked from commit 58f527893e0a5c051c91d6df0c8d3217c1811875)

src/crimson/osd/osd_operations/snaptrim_event.cc
src/crimson/osd/shard_services.h

index fc08cefa3d754f1fcd85a1739797421dcbea0d14..89c11bf547c5958d506ee5ce30d6931ca9563926 100644 (file)
@@ -143,7 +143,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 43cbd2144e5fed1cac22a4072fb3fee160fd52c9..26209fa903a61f04071d713d9a3d22f78004314e 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() {
@@ -371,6 +393,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