Skip to content

Commit 579ed34

Browse files
committed
RAID10: ignore discard error
This is the counterpart of raid10 fix. If a write error occurs, raid10 will try to rewrite the bio in small chunk size. If the rewrite fails, raid10 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. Cc: Sitsofe Wheeler <sitsofe@gmail.com> Cc: stable@vger.kernel.org (v3.6) Signed-off-by: Shaohua Li <shli@fb.com>
1 parent e3f948c commit 579ed34

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

drivers/md/raid10.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,9 @@ static void raid10_end_write_request(struct bio *bio)
447447
struct r10conf *conf = r10_bio->mddev->private;
448448
int slot, repl;
449449
struct md_rdev *rdev = NULL;
450+
bool discard_error;
451+
452+
discard_error = bio->bi_error && bio_op(bio) == REQ_OP_DISCARD;
450453

451454
dev = find_bio_disk(conf, r10_bio, bio, &slot, &repl);
452455

@@ -460,7 +463,7 @@ static void raid10_end_write_request(struct bio *bio)
460463
/*
461464
* this branch is our 'one mirror IO has finished' event handler:
462465
*/
463-
if (bio->bi_error) {
466+
if (bio->bi_error && !discard_error) {
464467
if (repl)
465468
/* Never record new bad blocks to replacement,
466469
* just fail it.
@@ -503,7 +506,7 @@ static void raid10_end_write_request(struct bio *bio)
503506
if (is_badblock(rdev,
504507
r10_bio->devs[slot].addr,
505508
r10_bio->sectors,
506-
&first_bad, &bad_sectors)) {
509+
&first_bad, &bad_sectors) && !discard_error) {
507510
bio_put(bio);
508511
if (repl)
509512
r10_bio->devs[slot].repl_bio = IO_MADE_GOOD;

0 commit comments

Comments
 (0)