In 7471fb77(md/raid6: Fix anomily when recovering a single device in RAID6.) It avoids to re-read P when it can be computed from other members. But it misses the chance to re-write the right data to P. Now it sets R5_ReadError if the re-read fails. Because it avoids the re-read, so it misses the chance to set R5_ReadError. The re-write is submitted in state machine when r5dev has flag R5_ReadError. So it doesn't re-write the right data to disk. We need to do this to keep the raid having right data. Because it don't send re-read, so it also misses the chance to reset rdev->read_erros to 0. It can fail the disk when there are many read errors on P member disk(other disks don't have read error) V2: upper layer read request don't read parity/Q data. So there is no need to consider such situation. This is Reported-by: kbuild test robot <lkp@xxxxxxxxx> Fixes: 7471fb77(md/raid6: Fix anomily when recovering a single device in RAID6.) Signed-off-by: Xiao Ni <xni@xxxxxxxxxx> --- drivers/md/raid5.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 9c4f765..7d2b2d9 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -2561,7 +2561,9 @@ static void raid5_end_read_request(struct bio * bi) && !test_bit(R5_ReadNoMerge, &sh->dev[i].flags)) retry = 1; if (retry) - if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags)) { + if (sh->qd_idx >= 0 && sh->pd_idx == i) + set_bit(R5_ReadError, &sh->dev[i].flags); + else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags)) { set_bit(R5_ReadError, &sh->dev[i].flags); clear_bit(R5_ReadNoMerge, &sh->dev[i].flags); } else -- 2.7.5