Thread (50 messages) flat view 50 messages, 4 authors, 1d ago

Re: [PATCH v4 05/25] md/raid5: round bitmap stripes with sector division

From: sashiko-bot@kernel.org
Date: 2026-08-01 17:39:26

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] The IO boundary `prev_end` is incorrectly rounded down instead of up to the nearest stripe boundary, causing bitmap bits for the last chunk of an IO to be missed during reshape.
--
--- Patch [5]: [PATCH v4 05/25] md/raid5: round bitmap stripes with sector division ---
commit 804a4bf19f3825714694494e86aceb7594f387a3
Author: Yu Kuai [off-list ref]

md/raid5: round bitmap stripes with sector division

This commit fixes alignment of array ranges to full RAID5 stripe widths when
the width is not a power of two. It replaces the old mask-based round_down()
and round_up() logic with sector_div() arithmetic.

Link: https://lore.kernel.org/all/20260726185916.2223460-1-mykola@meshstor.io/ (local)
quoted hunk ↗ jump to hunk
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 4276b125f94cb..8b3483674398d 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
[ ... ]
quoted hunk ↗ jump to hunk
@@ -5975,8 +5978,10 @@ static void raid5_bitmap_sector(struct mddev *mddev, sector_t *offset,
 
 	sectors_per_chunk = conf->prev_chunk_sectors *
 		(conf->previous_raid_disks - conf->max_degraded);
-	prev_start = round_down(prev_start, sectors_per_chunk);
-	prev_end = round_down(prev_end, sectors_per_chunk);
+	sector_div(prev_start, sectors_per_chunk);
+	prev_start *= sectors_per_chunk;
+	sector_div(prev_end, sectors_per_chunk);
+	prev_end *= sectors_per_chunk;
[Severity: High]
This is a pre-existing issue, but does prev_end need to be rounded up here
instead of rounded down?

The original code incorrectly used round_down(prev_end, ...) for the exclusive
end boundary. By preserving that logic here with sector_div() and
multiplication, we truncate the boundary instead of rounding it up.

If a write occurs ahead of the reshape position (LOC_AHEAD_OF_RESHAPE) and
ends inside a partial stripe, could shrinking the exclusive prev_end boundary
cause us to miss bitmap bits for the trailing sectors?

If a crash happens during reshape, would the subsequent resync silently skip
these trailing sectors because they were omitted from the bitmap?

Should this include the same remainder check that was applied to the end
variable earlier in the file to properly round up?

	if (sector_div(prev_end, sectors_per_chunk))
		prev_end++;
 
 	prev_start = raid5_compute_sector(conf, prev_start, 1, &dd_idx, NULL);
 	prev_end = raid5_compute_sector(conf, prev_end, 1, &dd_idx, NULL);
-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260801172519.2982121-1-yukuai@kernel.org?part=5
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help