浏览代码

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>
Shaohua Li 8 年之前
父节点
当前提交
579ed34f7b
共有 1 个文件被更改,包括 5 次插入2 次删除
  1. 5 2
      drivers/md/raid10.c

+ 5 - 2
drivers/md/raid10.c

@@ -447,6 +447,9 @@ static void raid10_end_write_request(struct bio *bio)
 	struct r10conf *conf = r10_bio->mddev->private;
 	struct r10conf *conf = r10_bio->mddev->private;
 	int slot, repl;
 	int slot, repl;
 	struct md_rdev *rdev = NULL;
 	struct md_rdev *rdev = NULL;
+	bool discard_error;
+
+	discard_error = bio->bi_error && bio_op(bio) == REQ_OP_DISCARD;
 
 
 	dev = find_bio_disk(conf, r10_bio, bio, &slot, &repl);
 	dev = find_bio_disk(conf, r10_bio, bio, &slot, &repl);
 
 
@@ -460,7 +463,7 @@ static void raid10_end_write_request(struct bio *bio)
 	/*
 	/*
 	 * this branch is our 'one mirror IO has finished' event handler:
 	 * this branch is our 'one mirror IO has finished' event handler:
 	 */
 	 */
-	if (bio->bi_error) {
+	if (bio->bi_error && !discard_error) {
 		if (repl)
 		if (repl)
 			/* Never record new bad blocks to replacement,
 			/* Never record new bad blocks to replacement,
 			 * just fail it.
 			 * just fail it.
@@ -503,7 +506,7 @@ static void raid10_end_write_request(struct bio *bio)
 		if (is_badblock(rdev,
 		if (is_badblock(rdev,
 				r10_bio->devs[slot].addr,
 				r10_bio->devs[slot].addr,
 				r10_bio->sectors,
 				r10_bio->sectors,
-				&first_bad, &bad_sectors)) {
+				&first_bad, &bad_sectors) && !discard_error) {
 			bio_put(bio);
 			bio_put(bio);
 			if (repl)
 			if (repl)
 				r10_bio->devs[slot].repl_bio = IO_MADE_GOOD;
 				r10_bio->devs[slot].repl_bio = IO_MADE_GOOD;