From: Xuehan Xu Date: Fri, 5 May 2023 05:22:11 +0000 (+0000) Subject: crimson/osd/snaptrim_event: preserve interrupt condition when creating X-Git-Tag: v18.1.0~74^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=dfbec2cf6caf1c25a6021757c1a7b309397f6b8e;p=ceph.git crimson/osd/snaptrim_event: preserve interrupt condition when creating subops Signed-off-by: Xuehan Xu (cherry picked from commit 58f527893e0a5c051c91d6df0c8d3217c1811875) --- diff --git a/src/crimson/osd/osd_operations/snaptrim_event.cc b/src/crimson/osd/osd_operations/snaptrim_event.cc index fc08cefa3d754..89c11bf547c59 100644 --- a/src/crimson/osd/osd_operations/snaptrim_event.cc +++ b/src/crimson/osd/osd_operations/snaptrim_event.cc @@ -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( + auto [op, fut] = shard_services.start_operation_may_interrupt< + interruptor, SnapTrimObjSubEvent>( pg, object, snapid); diff --git a/src/crimson/osd/shard_services.h b/src/crimson/osd/shard_services.h index 43cbd2144e5fe..26209fa903a61 100644 --- a/src/crimson/osd/shard_services.h +++ b/src/crimson/osd/shard_services.h @@ -143,6 +143,28 @@ class PerShardState { return std::make_pair(std::move(op), std::move(fut)); } + template + 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(std::forward(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(std::forward(args)...); } + template + auto start_operation_may_interrupt(Args&&... args) { + return local_state.start_operation_may_interrupt< + InterruptorT, T>(std::forward(args)...); + } + auto &get_registry() { return local_state.registry; } // Loggers