]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
osd: Truncate coding shards to minimal size
authorAlex Ainscow <aainscow@uk.ibm.com>
Sun, 29 Jun 2025 21:54:51 +0000 (22:54 +0100)
committerJon <jonathan.bailey1@ibm.com>
Fri, 3 Oct 2025 13:31:23 +0000 (14:31 +0100)
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 <aainscow@uk.ibm.com>
(cherry picked from commit a39a309631482b0caa071d586f192cd19a7ae470)

src/osd/ECTransaction.cc

index 2c5b0fe3ea085411fa687fde80e39ad55c9a3f25..bac4828378a45b5a7a0479404de80f2cbd01f532 100644 (file)
@@ -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) {