From: Samuel Just Date: Tue, 19 Mar 2024 23:11:48 +0000 (+0000) Subject: crimson/.../scrub_events: fix progress lifetime in deep_scan_object X-Git-Tag: v20.0.0~2317^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3276ad571640bc91fe290832a0001bd96f1f26de;p=ceph.git 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 --- diff --git a/src/crimson/osd/osd_operations/scrub_events.cc b/src/crimson/osd/osd_operations/scrub_events.cc index a7b782a71000..dbe22a086bb4 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;