From 03c445690b6922b7f5b3d6df5b229d09a902e0c9 Mon Sep 17 00:00:00 2001 From: Alex Ainscow Date: Fri, 20 Jun 2025 11:48:59 +0100 Subject: [PATCH] osd: Fix incorrect invalidate_crc during slice iterate The CRCs were being invalidate at the wrong point, so the last CRC was not being invalidated. Signed-off-by: Alex Ainscow (cherry picked from commit 564b53c446201ed33b5345c936c3c4b5d32bdaab) --- src/osd/ECUtil.h | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/osd/ECUtil.h b/src/osd/ECUtil.h index 0d02130f93c..89ed7878bb0 100644 --- a/src/osd/ECUtil.h +++ b/src/osd/ECUtil.h @@ -211,22 +211,26 @@ class slice_iterator { // If we have reached the end of the extent, we need to move that on too. if (bl_iter == emap_iter.get_val().end()) { + // NOTE: Despite appearances, the following is happening BEFORE + // the caller gets to use the buffer pointers (since the in/out is + // set a few lines above). This means that the caller must not + // check the CRC. + if (out_set.contains(shard)) { + invalidate_crcs(shard); + } ++emap_iter; if (emap_iter == input[shard].end()) { erase = true; } else { - if (out_set.contains(shard)) { - bufferlist bl = emap_iter.get_val(); - bl.invalidate_crc(); - } iters.at(shard).second = emap_iter.get_val().begin(); if (zeros) { zeros->emplace(shard, emap_iter.get_off(), emap_iter.get_len()); } } } - } else + } else { ceph_assert(iter_offset > start); + } if (erase) { iter = iters.erase(iter); @@ -249,6 +253,11 @@ class slice_iterator { } } + void invalidate_crcs(shard_id_t shard) { + bufferlist bl = iters.at(shard).first.get_val(); + bl.invalidate_crc(); + } + public: slice_iterator( mini_flat_map &_input, -- 2.39.5