]> 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)
committerAlex Ainscow <aainscow@uk.ibm.com>
Fri, 25 Jul 2025 07:43:09 +0000 (08:43 +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>
src/osd/ECTransaction.cc

index 47f09873231629e1c7c73644ca0f03cab3584677..18544db6dc227742f92ab85f467e3a6e88cb5919 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) {