Re: [PATCH v5 05/29] md/raid5: round bitmap stripes with sector division

[email protected] Sun, 02 Aug 2026 20:19:21 +0000
Newsgroups org.kernel.vger.linux-raid
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(=
s) to consider:

Pre-existing issues:
- [Critical] `prev_end` is incorrectly rounded down instead of up during a =
reshape, potentially causing silent data corruption.
--

--- Patch [5]: [PATCH v5 05/29] md/raid5: round bitmap stripes with sector =
division ---
commit ecc755c8b2e63f314261ab6ac1c1f566e26c875a
Author: Yu Kuai <[email protected]>
md/raid5: round bitmap stripes with sector division

This commit changes the rounding logic in raid5_bitmap_sector() and
raid5_bitmap_sector_map() to use sector_div() rather than round_down()
and round_up(). This aligns the array ranges to actual RAID5 stripe widths
that are not always a power of two.

Link: https://lore.kernel.org/all/20260726185916.2223460-1-mykola@meshstor.=
io/

> diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
> --- a/drivers/md/raid5.c
> +++ b/drivers/md/raid5.c

[ ... ]

> @@ -6048,8 +6051,10 @@ static void raid5_bitmap_sector(struct mddev *mdde=
v, sector_t *offset,
> =20
>  	sectors_per_chunk =3D conf->prev_chunk_sectors *
>  		(conf->previous_raid_disks - conf->max_degraded);
> -	prev_start =3D round_down(prev_start, sectors_per_chunk);
> -	prev_end =3D round_down(prev_end, sectors_per_chunk);
> +	sector_div(prev_start, sectors_per_chunk);
> +	prev_start *=3D sectors_per_chunk;
> +	sector_div(prev_end, sectors_per_chunk);
> +	prev_end *=3D sectors_per_chunk;

[Severity: Critical]
This is a pre-existing issue, but does rounding down prev_end leave the
tail of the IO unmarked in the bitmap for the previous layout?

If an active reshape reduces the RAID5 stripe width and a write request
spans across the boundary of an old chunk, it appears this code calculates
an incorrectly small component end sector.=20

If the max(end, prev_end) fallback fails to cover the affected component
sectors for the old layout, could they be left unmarked in the bitmap? A
system crash at this moment might skip rebuilding those dirty sectors upon
recovery, leading to inconsistent parity or outdated data.

Should this translation to sector_div() also include logic to round up
prev_end, similar to how end is handled in raid5_bitmap_sector_map()?

--=20
Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20260802195038.1642=
[email protected]?part=3D5