Re: [PATCH v4 05/25] md/raid5: round bitmap stripes with sector division
[email protected] Sat, 01 Aug 2026 17:39:26 +0000
| Newsgroups | gmane.linux.raid |
|---|---|
| Message-ID | <[email protected]> |
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 o= f 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 <[email protected]> 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/ > 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 [ ... ] > @@ -5975,8 +5978,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: 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 exclus= ive 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 bounda= ry 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++; > =20 > prev_start =3D raid5_compute_sector(conf, prev_start, 1, &dd_idx, NULL); > prev_end =3D raid5_compute_sector(conf, prev_end, 1, &dd_idx, NULL); --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20260801172519.2982= [email protected]?part=3D5