public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch]block: add plug for blkdev_issue_discard
@ 2012-10-09  1:11 Shaohua Li
  2012-10-09  1:56 ` Mike Snitzer
  0 siblings, 1 reply; 3+ messages in thread
From: Shaohua Li @ 2012-10-09  1:11 UTC (permalink / raw)
  To: axboe; +Cc: linux-kernel

Now discard merge works, add plug for blkdev_issue_discard. This will help
discard request merge especially for raid0 case. In raid0, a big discard
request is split to small requests, and if correct plug is added, such small
requests can be merged in low layer.

Signed-off-by: Shaohua Li <shli@fusionio.com>
---
 block/blk-lib.c |    3 +++
 1 file changed, 3 insertions(+)

Index: linux/block/blk-lib.c
===================================================================
--- linux.orig/block/blk-lib.c	2012-09-28 15:09:38.655327319 +0800
+++ linux/block/blk-lib.c	2012-10-09 08:45:04.358598888 +0800
@@ -48,6 +48,7 @@ int blkdev_issue_discard(struct block_de
 	struct bio_batch bb;
 	struct bio *bio;
 	int ret = 0;
+	struct blk_plug plug;
 
 	if (!q)
 		return -ENXIO;
@@ -81,6 +82,7 @@ int blkdev_issue_discard(struct block_de
 	bb.flags = 1 << BIO_UPTODATE;
 	bb.wait = &wait;
 
+	blk_start_plug(&plug);
 	while (nr_sects) {
 		unsigned int req_sects;
 		sector_t end_sect;
@@ -117,6 +119,7 @@ int blkdev_issue_discard(struct block_de
 		atomic_inc(&bb.done);
 		submit_bio(type, bio);
 	}
+	blk_finish_plug(&plug);
 
 	/* Wait for bios in-flight */
 	if (!atomic_dec_and_test(&bb.done))

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

* Re: [patch]block: add plug for blkdev_issue_discard
  2012-10-09  1:11 [patch]block: add plug for blkdev_issue_discard Shaohua Li
@ 2012-10-09  1:56 ` Mike Snitzer
  2012-10-09  1:59   ` Jens Axboe
  0 siblings, 1 reply; 3+ messages in thread
From: Mike Snitzer @ 2012-10-09  1:56 UTC (permalink / raw)
  To: Shaohua Li; +Cc: axboe, linux-kernel

On Mon, Oct 8, 2012 at 9:11 PM, Shaohua Li <shli@kernel.org> wrote:
> Now discard merge works, add plug for blkdev_issue_discard. This will help
> discard request merge especially for raid0 case. In raid0, a big discard
> request is split to small requests, and if correct plug is added, such small
> requests can be merged in low layer.
>
> Signed-off-by: Shaohua Li <shli@fusionio.com>
> ---
>  block/blk-lib.c |    3 +++
>  1 file changed, 3 insertions(+)
>
> Index: linux/block/blk-lib.c
> ===================================================================
> --- linux.orig/block/blk-lib.c  2012-09-28 15:09:38.655327319 +0800
> +++ linux/block/blk-lib.c       2012-10-09 08:45:04.358598888 +0800
> @@ -48,6 +48,7 @@ int blkdev_issue_discard(struct block_de
>         struct bio_batch bb;
>         struct bio *bio;
>         int ret = 0;
> +       struct blk_plug plug;
>
>         if (!q)
>                 return -ENXIO;
> @@ -81,6 +82,7 @@ int blkdev_issue_discard(struct block_de
>         bb.flags = 1 << BIO_UPTODATE;
>         bb.wait = &wait;
>
> +       blk_start_plug(&plug);
>         while (nr_sects) {
>                 unsigned int req_sects;
>                 sector_t end_sect;
> @@ -117,6 +119,7 @@ int blkdev_issue_discard(struct block_de
>                 atomic_inc(&bb.done);
>                 submit_bio(type, bio);
>         }
> +       blk_finish_plug(&plug);
>
>         /* Wait for bios in-flight */
>         if (!atomic_dec_and_test(&bb.done))

That plug looks rather coarse-grained.  Any adverse affects when mkfs
discards an entire (large) raid0 device?  (I suspect not but figured
I'd ask)

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

* Re: [patch]block: add plug for blkdev_issue_discard
  2012-10-09  1:56 ` Mike Snitzer
@ 2012-10-09  1:59   ` Jens Axboe
  0 siblings, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2012-10-09  1:59 UTC (permalink / raw)
  To: Mike Snitzer; +Cc: Shaohua Li, linux-kernel

On 2012-10-08 19:56, Mike Snitzer wrote:
> On Mon, Oct 8, 2012 at 9:11 PM, Shaohua Li <shli@kernel.org> wrote:
>> Now discard merge works, add plug for blkdev_issue_discard. This will help
>> discard request merge especially for raid0 case. In raid0, a big discard
>> request is split to small requests, and if correct plug is added, such small
>> requests can be merged in low layer.
>>
>> Signed-off-by: Shaohua Li <shli@fusionio.com>
>> ---
>>  block/blk-lib.c |    3 +++
>>  1 file changed, 3 insertions(+)
>>
>> Index: linux/block/blk-lib.c
>> ===================================================================
>> --- linux.orig/block/blk-lib.c  2012-09-28 15:09:38.655327319 +0800
>> +++ linux/block/blk-lib.c       2012-10-09 08:45:04.358598888 +0800
>> @@ -48,6 +48,7 @@ int blkdev_issue_discard(struct block_de
>>         struct bio_batch bb;
>>         struct bio *bio;
>>         int ret = 0;
>> +       struct blk_plug plug;
>>
>>         if (!q)
>>                 return -ENXIO;
>> @@ -81,6 +82,7 @@ int blkdev_issue_discard(struct block_de
>>         bb.flags = 1 << BIO_UPTODATE;
>>         bb.wait = &wait;
>>
>> +       blk_start_plug(&plug);
>>         while (nr_sects) {
>>                 unsigned int req_sects;
>>                 sector_t end_sect;
>> @@ -117,6 +119,7 @@ int blkdev_issue_discard(struct block_de
>>                 atomic_inc(&bb.done);
>>                 submit_bio(type, bio);
>>         }
>> +       blk_finish_plug(&plug);
>>
>>         /* Wait for bios in-flight */
>>         if (!atomic_dec_and_test(&bb.done))
> 
> That plug looks rather coarse-grained.  Any adverse affects when mkfs
> discards an entire (large) raid0 device?  (I suspect not but figured
> I'd ask)

Block core auto-unplugs after a certain depth is reached. So it's better
to make it coarse than try to second guess when to unplug.

-- 
Jens Axboe


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

end of thread, other threads:[~2012-10-09  2:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-09  1:11 [patch]block: add plug for blkdev_issue_discard Shaohua Li
2012-10-09  1:56 ` Mike Snitzer
2012-10-09  1:59   ` Jens Axboe

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