]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/osd/osd_operations/snaptrim_event: fix lifetime management
authorMatan Breizman <mbreizma@redhat.com>
Thu, 9 Nov 2023 09:39:23 +0000 (09:39 +0000)
committerMatan Breizman <mbreizma@redhat.com>
Sun, 12 Nov 2023 14:12:39 +0000 (14:12 +0000)
The operation's id and future returned when starting SnapTrimObjSubEvent
is emplaced into subop_blocker.
Later on, we await the completion of all the started operations futures.
Before this patch, we only stored the op id in the subop_blocker vector
which allowed `op` to go out of scope and lose all its references
(and get deleted) before exiting.

Storing the operation as a reference instead of the id
will maintain the SnapTrimObjSubEvent operation lifetime.

Fixes: https://tracker.ceph.com/issues/63299
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 ffd43d736ad393e038af37d03ecaa65440c3e9b7..21fd6e94da94f2e2fc31e045ed6142863b558c15 100644 (file)
@@ -44,7 +44,7 @@ void SnapTrimEvent::SubOpBlocker::dump_detail(Formatter *f) const
   f->open_array_section("dependent_operations");
   {
     for (const auto &kv : subops) {
-      f->dump_unsigned("op_id", kv.first);
+      f->dump_unsigned("op_id", kv.first->get_id());
     }
   }
   f->close_section();
@@ -152,7 +152,7 @@ SnapTrimEvent::start()
              object,
              snapid);
            subop_blocker.emplace_back(
-             op->get_id(),
+             std::move(op),
              std::move(fut)
            );
          }
index afb24952a045cf8c3c97ed538b47bbf876a5a631..f7c512881de320f7fdfe516affe40807a8f2f6d3 100644 (file)
@@ -61,7 +61,7 @@ private:
   struct SubOpBlocker : crimson::BlockerT<SubOpBlocker> {
     static constexpr const char* type_name = "CompoundOpBlocker";
 
-    using id_done_t = std::pair<crimson::Operation::id_t,
+    using id_done_t = std::pair<crimson::OperationRef,
                                 remove_or_update_iertr::future<>>;
 
     void dump_detail(Formatter *f) const final;