From 143b007b239bd4d8224a55a39880ca14dc648119 Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Tue, 19 Mar 2024 23:11:48 +0000 Subject: [PATCH] crimson/.../scrub_events: fix progress lifetime in deep_scan_object 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 (cherry picked from commit 3276ad571640bc91fe290832a0001bd96f1f26de) --- src/crimson/osd/osd_operations/scrub_events.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/crimson/osd/osd_operations/scrub_events.cc b/src/crimson/osd/osd_operations/scrub_events.cc index a7b782a7100..dbe22a086bb 100644 --- a/src/crimson/osd/osd_operations/scrub_events.cc +++ b/src/crimson/osd/osd_operations/scrub_events.cc @@ -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(); + 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 { 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::yes)); } - }); + }).finally([progress_ref=std::move(progress_ref)] {}); } template class ScrubAsyncOpT; -- 2.39.5