MD: ignore discard request for hard disks of hybid raid1/raid10 array
authorShaohua Li <shli@kernel.org>
Sun, 28 Apr 2013 10:26:38 +0000 (18:26 +0800)
committerNeilBrown <neilb@suse.de>
Tue, 30 Apr 2013 04:49:36 +0000 (14:49 +1000)
In SSD/hard disk hybid storage, discard request should be ignored for hard
disk. We used to be doing this way, but the unplug path forgets it.

This is suitable for stable tree since v3.6.

Cc: stable@vger.kernel.org
Reported-and-tested-by: Markus <M4rkusXXL@web.de>
Signed-off-by: Shaohua Li <shli@fusionio.com>
Signed-off-by: NeilBrown <neilb@suse.de>
drivers/md/raid1.c
drivers/md/raid10.c

index c055b92d7eb5e9f8d93a66785db5246cfae167a3..851023e2ba5d5296824a46bdc12482056de648a1 100644 (file)
@@ -981,7 +981,12 @@ static void raid1_unplug(struct blk_plug_cb *cb, bool from_schedule)
        while (bio) { /* submit pending writes */
                struct bio *next = bio->bi_next;
                bio->bi_next = NULL;
-               generic_make_request(bio);
+               if (unlikely((bio->bi_rw & REQ_DISCARD) &&
+                   !blk_queue_discard(bdev_get_queue(bio->bi_bdev))))
+                       /* Just ignore it */
+                       bio_endio(bio, 0);
+               else
+                       generic_make_request(bio);
                bio = next;
        }
        kfree(plug);
index c35d912a7f9bc62dec0a80934f9b637a99d687d8..018741ba93104d9ad432d7524a136cf7e69b2227 100644 (file)
@@ -1133,7 +1133,12 @@ static void raid10_unplug(struct blk_plug_cb *cb, bool from_schedule)
        while (bio) { /* submit pending writes */
                struct bio *next = bio->bi_next;
                bio->bi_next = NULL;
-               generic_make_request(bio);
+               if (unlikely((bio->bi_rw & REQ_DISCARD) &&
+                   !blk_queue_discard(bdev_get_queue(bio->bi_bdev))))
+                       /* Just ignore it */
+                       bio_endio(bio, 0);
+               else
+                       generic_make_request(bio);
                bio = next;
        }
        kfree(plug);