md: disable WRITE SAME if it fails in underlayer disks
authorShaohua Li <shli@fb.com>
Tue, 14 Feb 2017 00:21:49 +0000 (16:21 -0800)
committerShaohua Li <shli@fb.com>
Tue, 14 Feb 2017 03:24:16 +0000 (19:24 -0800)
This makes md do the same thing as dm for write same IO failure. Please
see 7eee4ae(dm: disable WRITE SAME if it fails) for details why we need
this.

We did a little bit different than dm. Instead of disabling writesame in
the first IO error, we disable it till next writesame IO coming after
the first IO error. This way we don't need to clone a bio.

Also reported here: https://bugzilla.kernel.org/show_bug.cgi?id=118581

Suggested-by: NeilBrown <neilb@suse.com>
Acked-by: NeilBrown <neilb@suse.com>
Signed-off-by: Shaohua Li <shli@fb.com>
drivers/md/linear.c
drivers/md/md.h
drivers/md/multipath.c
drivers/md/raid0.c

index 26a73b2002cfcec2608f818bbe4ee86c5d6e420a..789008bc94ffd21b8716691555028ac88cf8c98b 100644 (file)
@@ -291,6 +291,7 @@ static void linear_make_request(struct mddev *mddev, struct bio *bio)
                                trace_block_bio_remap(bdev_get_queue(split->bi_bdev),
                                                      split, disk_devt(mddev->gendisk),
                                                      bio_sector);
+                       mddev_check_writesame(mddev, split);
                        generic_make_request(split);
                }
        } while (split != bio);
index 2a514036a83dc0da07c0966b7fe247c18356bbbf..42f8398181a81a6b8a5d2f2bcfc4f9c918410e1d 100644 (file)
@@ -710,4 +710,11 @@ static inline void mddev_clear_unsupported_flags(struct mddev *mddev,
 {
        mddev->flags &= ~unsupported_flags;
 }
+
+static inline void mddev_check_writesame(struct mddev *mddev, struct bio *bio)
+{
+       if (bio_op(bio) == REQ_OP_WRITE_SAME &&
+           !bdev_get_queue(bio->bi_bdev)->limits.max_write_same_sectors)
+               mddev->queue->limits.max_write_same_sectors = 0;
+}
 #endif /* _MD_MD_H */
index aa8c4e5c1ee28f3c5302eb64f525c6ece820c0e7..065fe2823285350ee5d7ca47039ea4d84e68965d 100644 (file)
@@ -138,6 +138,7 @@ static void multipath_make_request(struct mddev *mddev, struct bio * bio)
        mp_bh->bio.bi_opf |= REQ_FAILFAST_TRANSPORT;
        mp_bh->bio.bi_end_io = multipath_end_request;
        mp_bh->bio.bi_private = mp_bh;
+       mddev_check_writesame(mddev, &mp_bh->bio);
        generic_make_request(&mp_bh->bio);
        return;
 }
index 848365d474f3a3bca26168ac3619f2c52edd7618..b3d264452fd55f06d8b24be61e23b0b0e0927e48 100644 (file)
@@ -503,6 +503,7 @@ static void raid0_make_request(struct mddev *mddev, struct bio *bio)
                                trace_block_bio_remap(bdev_get_queue(split->bi_bdev),
                                                      split, disk_devt(mddev->gendisk),
                                                      bio_sector);
+                       mddev_check_writesame(mddev, split);
                        generic_make_request(split);
                }
        } while (split != bio);