Commit c0b32972fb1e1110101702f096c0877afcab9f1d
1 parent
6f608040ce
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
md/raid5: avoid an extra write when writing to a known-bad-block.
If we write to a known-bad-block it will be flags as having a ReadError by analyse_stripe, but the write will proceed anyway (as it should). Then the read-error handling will kick in an write again, then re-read. We don't need that 'write-again', so set R5_ReWrite so it looks like it has already been done. Then we will just get the re-read, which we want. Reported-by: majianpeng <majianpeng@gmail.com> Signed-off-by: NeilBrown <neilb@suse.de>
Showing 1 changed file with 8 additions and 1 deletions Side-by-side Diff
drivers/md/raid5.c
... | ... | @@ -1887,8 +1887,15 @@ |
1887 | 1887 | &rdev->mddev->recovery); |
1888 | 1888 | } else if (is_badblock(rdev, sh->sector, |
1889 | 1889 | STRIPE_SECTORS, |
1890 | - &first_bad, &bad_sectors)) | |
1890 | + &first_bad, &bad_sectors)) { | |
1891 | 1891 | set_bit(R5_MadeGood, &sh->dev[i].flags); |
1892 | + if (test_bit(R5_ReadError, &sh->dev[i].flags)) | |
1893 | + /* That was a successful write so make | |
1894 | + * sure it looks like we already did | |
1895 | + * a re-write. | |
1896 | + */ | |
1897 | + set_bit(R5_ReWrite, &sh->dev[i].flags); | |
1898 | + } | |
1892 | 1899 | } |
1893 | 1900 | rdev_dec_pending(rdev, conf->mddev); |
1894 | 1901 |