]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/.../scrub_events: fix progress lifetime in deep_scan_object 56375/head
authorSamuel Just <sjust@redhat.com>
Tue, 19 Mar 2024 23:11:48 +0000 (23:11 +0000)
committerSamuel Just <sjust@redhat.com>
Tue, 19 Mar 2024 23:11:48 +0000 (23:11 +0000)
seastar::repeat may or may not move the passed action after the first
invocation, so we can't actually rely on references to variables
captured by value being stable.  Instead, allocate with std::make_unique
and move into a finally lambda.

Fixes: https://tracker.ceph.com/issues/64996
Signed-off-by: Samuel Just <sjust@redhat.com>
src/crimson/osd/osd_operations/scrub_events.cc

index a7b782a71000d3ecdea57232c1ba05295944c8ac..dbe22a086bb49a8b24f791019d850a6a13f2c926 100644 (file)
@@ -258,9 +258,10 @@ ScrubScan::ifut<> ScrubScan::deep_scan_object(
   DEBUGDPP("obj: {}", pg, obj);
   using crimson::common::local_conf;
   auto &entry = ret.objects[obj.hobj];
+  auto progress_ref = std::make_unique<obj_scrub_progress_t>();
+  auto &progress = *progress_ref;
   return interruptor::repeat(
-    [FNAME, this, progress = obj_scrub_progress_t(),
-     &obj, &entry, &pg]() mutable
+    [FNAME, this, &progress, &obj, &entry, &pg]()
     -> interruptible_future<seastar::stop_iteration> {
       if (progress.offset) {
        DEBUGDPP("op: {}, obj: {}, progress: {} scanning data",
@@ -272,7 +273,10 @@ ScrubScan::ifut<> ScrubScan::deep_scan_object(
          obj,
          *(progress.offset),
          stride
-       ).safe_then([stride, &progress, &entry](auto bl) {
+       ).safe_then([this, FNAME, stride, &obj, &progress, &entry, &pg](auto bl) {
+         size_t offset = *progress.offset;
+         DEBUGDPP("op: {}, obj: {}, progress: {} got offset {}",
+                  pg, *this, obj, progress, offset);
          progress.data_hash << bl;
          if (bl.length() < stride) {
            progress.offset = std::nullopt;
@@ -373,7 +377,7 @@ ScrubScan::ifut<> ScrubScan::deep_scan_object(
          seastar::make_ready_future<seastar::stop_iteration>(
            seastar::stop_iteration::yes));
       }
-    });
+    }).finally([progress_ref=std::move(progress_ref)] {});
 }
 
 template class ScrubAsyncOpT<ScrubScan>;