From: Alex Ainscow Date: Sun, 29 Jun 2025 21:54:51 +0000 (+0100) Subject: osd: Truncate coding shards to minimal size X-Git-Tag: testing/wip-jcollin-testing-20250917.124222-tentacle~1^2~14 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1e299a9e4d26273ba20408f947922388afd264d5;p=ceph-ci.git osd: Truncate coding shards to minimal size Scrub detected a bug where if an object was truncated to a size where the first shard is smaller than the chunk size (only possible for >4k chunk sizes), then the coding shards were being aligned to the chunk size, rather than to 4k. This fixes changes how the write plan is calculated to write the correct size. Signed-off-by: Alex Ainscow (cherry picked from commit a39a309631482b0caa071d586f192cd19a7ae470) --- diff --git a/src/osd/ECTransaction.cc b/src/osd/ECTransaction.cc index 2c5b0fe3ea0..bac4828378a 100644 --- a/src/osd/ECTransaction.cc +++ b/src/osd/ECTransaction.cc @@ -255,17 +255,22 @@ ECTransaction::WritePlanObj::WritePlanObj( */ if (op.truncate && op.truncate->first < orig_size) { ECUtil::shard_extent_set_t truncate_read(sinfo.get_k_plus_m()); - extent_set truncate_write; uint64_t prev_stripe = sinfo.ro_offset_to_prev_stripe_ro_offset(op.truncate->first); uint64_t next_align = ECUtil::align_next(op.truncate->first); - sinfo.ro_range_to_shard_extent_set_with_superset( + sinfo.ro_range_to_shard_extent_set( prev_stripe, next_align - prev_stripe, - truncate_read, truncate_write); + truncate_read); - /* We must always update the entire parity chunk, even if we only read - * a small amount of one shard. + /* Unless we are doing a full stripe write, we must always read the data + * for the partial stripe and update the parity. For the purposes of + * parity, the truncated shards are all zero. */ - truncate_write.align(sinfo.get_chunk_size()); + extent_set truncate_write; + + if (next_align != 0) { + truncate_write = truncate_read.at(shard_id_t(0)); + truncate_write.align(EC_ALIGN_SIZE); + } if (!truncate_read.empty()) { if (to_read) {