summaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorShaohua Li <shli@fb.com>2016-10-06 17:09:16 -0400
committerShaohua Li <shli@fb.com>2016-10-24 18:28:17 -0400
commite3f948cd3283e4fbe5907f1f3967c839912f480e (patch)
treef27499748322b39719a5b3b81a3867675ca74f1e /drivers/md
parent07d9a380680d1c0eb51ef87ff2eab5c994949e69 (diff)
RAID1: ignore discard error
If a write error occurs, raid1 will try to rewrite the bio in small chunk size. If the rewrite fails, raid1 will record the error in bad block. narrow_write_error will always use WRITE for the bio, but actually it could be a discard. Since discard bio hasn't payload, write the bio will cause different issues. But discard error isn't fatal, we can safely ignore it. This is what this patch does. This issue should exist since discard is added, but only exposed with recent arbitrary bio size feature. Reported-and-tested-by: Sitsofe Wheeler <sitsofe@gmail.com> Cc: stable@vger.kernel.org (v3.6) Signed-off-by: Shaohua Li <shli@fb.com>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/raid1.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 1961d827dbd1..db536a68b2ee 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -403,11 +403,14 @@ static void raid1_end_write_request(struct bio *bio)
403 struct bio *to_put = NULL; 403 struct bio *to_put = NULL;
404 int mirror = find_bio_disk(r1_bio, bio); 404 int mirror = find_bio_disk(r1_bio, bio);
405 struct md_rdev *rdev = conf->mirrors[mirror].rdev; 405 struct md_rdev *rdev = conf->mirrors[mirror].rdev;
406 bool discard_error;
407
408 discard_error = bio->bi_error && bio_op(bio) == REQ_OP_DISCARD;
406 409
407 /* 410 /*
408 * 'one mirror IO has finished' event handler: 411 * 'one mirror IO has finished' event handler:
409 */ 412 */
410 if (bio->bi_error) { 413 if (bio->bi_error && !discard_error) {
411 set_bit(WriteErrorSeen, &rdev->flags); 414 set_bit(WriteErrorSeen, &rdev->flags);
412 if (!test_and_set_bit(WantReplacement, &rdev->flags)) 415 if (!test_and_set_bit(WantReplacement, &rdev->flags))
413 set_bit(MD_RECOVERY_NEEDED, & 416 set_bit(MD_RECOVERY_NEEDED, &
@@ -444,7 +447,7 @@ static void raid1_end_write_request(struct bio *bio)
444 447
445 /* Maybe we can clear some bad blocks. */ 448 /* Maybe we can clear some bad blocks. */
446 if (is_badblock(rdev, r1_bio->sector, r1_bio->sectors, 449 if (is_badblock(rdev, r1_bio->sector, r1_bio->sectors,
447 &first_bad, &bad_sectors)) { 450 &first_bad, &bad_sectors) && !discard_error) {
448 r1_bio->bios[mirror] = IO_MADE_GOOD; 451 r1_bio->bios[mirror] = IO_MADE_GOOD;
449 set_bit(R1BIO_MadeGood, &r1_bio->state); 452 set_bit(R1BIO_MadeGood, &r1_bio->state);
450 } 453 }