]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
md/raid5: avoid an extra write when writing to a known-bad-block.
authorNeilBrown <neilb@suse.de>
Mon, 4 Mar 2013 02:29:41 +0000 (13:29 +1100)
committerNeilBrown <neilb@suse.de>
Wed, 27 Mar 2013 06:14:55 +0000 (17:14 +1100)
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>
drivers/md/raid5.c

index 89c549d3ff0f0948de989f0eab52d0e6889f483e..b3ebffcabd2f57dc266b0a751c859d64a93873d4 100644 (file)
@@ -1885,8 +1885,15 @@ static void raid5_end_write_request(struct bio *bi, int error)
                                        &rdev->mddev->recovery);
                } else if (is_badblock(rdev, sh->sector,
                                       STRIPE_SECTORS,
-                                      &first_bad, &bad_sectors))
+                                      &first_bad, &bad_sectors)) {
                        set_bit(R5_MadeGood, &sh->dev[i].flags);
+                       if (test_bit(R5_ReadError, &sh->dev[i].flags))
+                               /* That was a successful write so make
+                                * sure it looks like we already did
+                                * a re-write.
+                                */
+                               set_bit(R5_ReWrite, &sh->dev[i].flags);
+               }
        }
        rdev_dec_pending(rdev, conf->mddev);