]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/osd/osd_operations/snaptrim_event: introduce process_and_submit
authorMatan Breizman <mbreizma@redhat.com>
Mon, 26 Aug 2024 10:07:36 +0000 (10:07 +0000)
committerMatan Breizman <mbreizma@redhat.com>
Mon, 9 Sep 2024 09:38:08 +0000 (09:38 +0000)
We should be carful with using capturing lambdas with coroutines.
Avoid capturing [this] by passing process_and_submit instead.

See: https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rcoro-capture

Signed-off-by: Matan Breizman <mbreizma@redhat.com>
src/crimson/osd/osd_operations/snaptrim_event.cc
src/crimson/osd/osd_operations/snaptrim_event.h

index 21d9c116aab22d1bb200860db3cc4c4192e96276..bb497cc1d3aeebe5d0b3bdff3e1397dcf1ace378 100644 (file)
@@ -436,6 +436,33 @@ SnapTrimObjSubEvent::start()
   co_await interruptor::make_interruptible(handle.complete());
 }
 
+ObjectContextLoader::load_obc_iertr::future<>
+SnapTrimObjSubEvent::process_and_submit(ObjectContextRef head_obc,
+                                        ObjectContextRef clone_obc) {
+  logger().debug("{}: got clone_obc={}", *this, clone_obc->get_oid());
+
+  co_await enter_stage<interruptor>(client_pp().process);
+
+  logger().debug("{}: processing clone_obc={}", *this, clone_obc->get_oid());
+
+  auto txn = co_await remove_or_update(clone_obc, head_obc);
+
+  auto [submitted, all_completed] = co_await pg->submit_transaction(
+         std::move(clone_obc),
+         std::move(txn),
+         std::move(osd_op_p),
+         std::move(log_entries)
+  );
+
+  co_await std::move(submitted);
+
+  co_await enter_stage<interruptor>(client_pp().wait_repop);
+
+  co_await std::move(all_completed);
+
+  co_return;
+}
+
 void SnapTrimObjSubEvent::print(std::ostream &lhs) const
 {
   lhs << "SnapTrimObjSubEvent("
index 9a656a451bd3f87ec94424326eb42486cef7fc5b..88a2a0392ea1e3142d5673005a2cc8ce139a779f 100644 (file)
@@ -113,6 +113,10 @@ public:
 private:
   object_stat_sum_t delta_stats;
 
+  ObjectContextLoader::load_obc_iertr::future<> process_and_submit(
+    ObjectContextRef head_obc,
+    ObjectContextRef clone_obc);
+
   snap_trim_obj_subevent_ret_t remove_clone(
     ObjectContextRef obc,
     ObjectContextRef head_obc,