Linux RAID subsystem development
 help / color / mirror / Atom feed
* [patch]MD: ignore discard request for hard disks of hybid raid1/raid10 array
@ 2013-04-28 10:26 Shaohua Li
  2013-04-29  1:03 ` NeilBrown
  0 siblings, 1 reply; 2+ messages in thread
From: Shaohua Li @ 2013-04-28 10:26 UTC (permalink / raw)
  To: linux-raid; +Cc: neilb, M4rkusXXL

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.

Reported-and-tested-by: Markus <M4rkusXXL@web.de>
Signed-off-by: Shaohua Li <shli@fusionio.com>
---
 drivers/md/raid1.c  |    7 ++++++-
 drivers/md/raid10.c |    7 ++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)

Index: linux/drivers/md/raid1.c
===================================================================
--- linux.orig/drivers/md/raid1.c	2013-03-07 14:14:05.950824173 +0800
+++ linux/drivers/md/raid1.c	2013-04-28 08:57:17.874058434 +0800
@@ -981,7 +981,12 @@ static void raid1_unplug(struct blk_plug
 	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: linux/drivers/md/raid10.c
===================================================================
--- linux.orig/drivers/md/raid10.c	2013-03-07 14:14:05.950824173 +0800
+++ linux/drivers/md/raid10.c	2013-04-28 08:57:44.765719067 +0800
@@ -1133,7 +1133,12 @@ static void raid10_unplug(struct blk_plu
 	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);

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [patch]MD: ignore discard request for hard disks of hybid raid1/raid10 array
  2013-04-28 10:26 [patch]MD: ignore discard request for hard disks of hybid raid1/raid10 array Shaohua Li
@ 2013-04-29  1:03 ` NeilBrown
  0 siblings, 0 replies; 2+ messages in thread
From: NeilBrown @ 2013-04-29  1:03 UTC (permalink / raw)
  To: Shaohua Li; +Cc: linux-raid, M4rkusXXL

[-- Attachment #1: Type: text/plain, Size: 1984 bytes --]

On Sun, 28 Apr 2013 18:26:38 +0800 Shaohua Li <shli@kernel.org> wrote:

> 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.
> 
> Reported-and-tested-by: Markus <M4rkusXXL@web.de>
> Signed-off-by: Shaohua Li <shli@fusionio.com>
> ---
>  drivers/md/raid1.c  |    7 ++++++-
>  drivers/md/raid10.c |    7 ++++++-
>  2 files changed, 12 insertions(+), 2 deletions(-)
> 
> Index: linux/drivers/md/raid1.c
> ===================================================================
> --- linux.orig/drivers/md/raid1.c	2013-03-07 14:14:05.950824173 +0800
> +++ linux/drivers/md/raid1.c	2013-04-28 08:57:17.874058434 +0800
> @@ -981,7 +981,12 @@ static void raid1_unplug(struct blk_plug
>  	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: linux/drivers/md/raid10.c
> ===================================================================
> --- linux.orig/drivers/md/raid10.c	2013-03-07 14:14:05.950824173 +0800
> +++ linux/drivers/md/raid10.c	2013-04-28 08:57:44.765719067 +0800
> @@ -1133,7 +1133,12 @@ static void raid10_unplug(struct blk_plu
>  	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);


Applied, thanks.

NeilBrown

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-04-29  1:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-28 10:26 [patch]MD: ignore discard request for hard disks of hybid raid1/raid10 array Shaohua Li
2013-04-29  1:03 ` NeilBrown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox