Skip to content

Commit c467e97

Browse files
David Jefferyliu-song-6
authored andcommitted
md/raid6: use valid sector values to determine if an I/O should wait on the reshape
During a reshape or a RAID6 array such as expanding by adding an additional disk, I/Os to the region of the array which have not yet been reshaped can stall indefinitely. This is from errors in the stripe_ahead_of_reshape function causing md to think the I/O is to a region in the actively undergoing the reshape. stripe_ahead_of_reshape fails to account for the q disk having a sector value of 0. By not excluding the q disk from the for loop, raid6 will always generate a min_sector value of 0, causing a return value which stalls. The function's max_sector calculation also uses min() when it should use max(), causing the max_sector value to always be 0. During a backwards rebuild this can cause the opposite problem where it allows I/O to advance when it should wait. Fixing these errors will allow safe I/O to advance in a timely manner and delay only I/O which is unsafe due to stripes in the middle of undergoing the reshape. Fixes: 486f605 ("md/raid5: Check all disks in a stripe_head for reshape progress") Cc: stable@vger.kernel.org # v6.0+ Signed-off-by: David Jeffery <djeffery@redhat.com> Tested-by: Laurence Oberman <loberman@redhat.com> Signed-off-by: Song Liu <song@kernel.org> Link: https://lore.kernel.org/r/20231128181233.6187-1-djeffery@redhat.com
1 parent 45b4789 commit c467e97

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/md/raid5.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5892,11 +5892,11 @@ static bool stripe_ahead_of_reshape(struct mddev *mddev, struct r5conf *conf,
58925892
int dd_idx;
58935893

58945894
for (dd_idx = 0; dd_idx < sh->disks; dd_idx++) {
5895-
if (dd_idx == sh->pd_idx)
5895+
if (dd_idx == sh->pd_idx || dd_idx == sh->qd_idx)
58965896
continue;
58975897

58985898
min_sector = min(min_sector, sh->dev[dd_idx].sector);
5899-
max_sector = min(max_sector, sh->dev[dd_idx].sector);
5899+
max_sector = max(max_sector, sh->dev[dd_idx].sector);
59005900
}
59015901

59025902
spin_lock_irq(&conf->device_lock);

0 commit comments

Comments
 (0)