* [patch]blk: use correct sectors limitation for discard request
@ 2012-03-16 7:40 Shaohua Li
2012-03-20 16:31 ` Vivek Goyal
0 siblings, 1 reply; 3+ messages in thread
From: Shaohua Li @ 2012-03-16 7:40 UTC (permalink / raw)
To: linux-kernel@vger.kernel.org; +Cc: axboe@kernel.dk, Vivek Goyal
Subject: blk: use correct sectors limitation for discard request
max_discard_sectors doesn't equal to max_sectors/max_hw_sectors. Without
this,
discard request merge might be ignored.
Signed-off-by: Shaohua Li <shli@fusionio.com>
---
block/blk-merge.c | 13 ++++++++-----
include/linux/blkdev.h | 5 +++++
2 files changed, 13 insertions(+), 5 deletions(-)
Index: linux/block/blk-merge.c
===================================================================
--- linux.orig/block/blk-merge.c 2012-03-14 09:53:15.574255985 +0800
+++ linux/block/blk-merge.c 2012-03-14 11:06:01.504462095 +0800
@@ -228,9 +228,11 @@ no_merge:
int ll_back_merge_fn(struct request_queue *q, struct request *req,
struct bio *bio)
{
- unsigned short max_sectors;
+ unsigned int max_sectors;
- if (unlikely(req->cmd_type == REQ_TYPE_BLOCK_PC))
+ if (unlikely(req->cmd_flags & REQ_DISCARD))
+ max_sectors = queue_max_discard_sectors(q);
+ else if (unlikely(req->cmd_type == REQ_TYPE_BLOCK_PC))
max_sectors = queue_max_hw_sectors(q);
else
max_sectors = queue_max_sectors(q);
@@ -252,14 +254,15 @@ int ll_back_merge_fn(struct request_queu
int ll_front_merge_fn(struct request_queue *q, struct request *req,
struct bio *bio)
{
- unsigned short max_sectors;
+ unsigned int max_sectors;
- if (unlikely(req->cmd_type == REQ_TYPE_BLOCK_PC))
+ if (unlikely(req->cmd_flags & REQ_DISCARD))
+ max_sectors = queue_max_discard_sectors(q);
+ else if (unlikely(req->cmd_type == REQ_TYPE_BLOCK_PC))
max_sectors = queue_max_hw_sectors(q);
else
max_sectors = queue_max_sectors(q);
-
if (blk_rq_sectors(req) + bio_sectors(bio) > max_sectors) {
req->cmd_flags |= REQ_NOMERGE;
if (req == q->last_merge)
Index: linux/include/linux/blkdev.h
===================================================================
--- linux.orig/include/linux/blkdev.h 2012-03-14 10:17:19.523960440 +0800
+++ linux/include/linux/blkdev.h 2012-03-14 10:57:22.324465357 +0800
@@ -1006,6 +1006,11 @@ static inline unsigned int queue_max_hw_
return q->limits.max_hw_sectors;
}
+static inline unsigned int queue_max_discard_sectors(struct
request_queue *q)
+{
+ return q->limits.max_discard_sectors;
+}
+
static inline unsigned short queue_max_segments(struct request_queue *q)
{
return q->limits.max_segments;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch]blk: use correct sectors limitation for discard request
2012-03-16 7:40 [patch]blk: use correct sectors limitation for discard request Shaohua Li
@ 2012-03-20 16:31 ` Vivek Goyal
2012-03-21 1:26 ` Shaohua Li
0 siblings, 1 reply; 3+ messages in thread
From: Vivek Goyal @ 2012-03-20 16:31 UTC (permalink / raw)
To: Shaohua Li; +Cc: linux-kernel@vger.kernel.org, axboe@kernel.dk
On Fri, Mar 16, 2012 at 03:40:06PM +0800, Shaohua Li wrote:
>
> Subject: blk: use correct sectors limitation for discard request
>
> max_discard_sectors doesn't equal to max_sectors/max_hw_sectors.
> Without this,
> discard request merge might be ignored.
In other patch you are making discard request non-mergeable. So what's
the purpose of this patch.
Thanks
Vivek
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch]blk: use correct sectors limitation for discard request
2012-03-20 16:31 ` Vivek Goyal
@ 2012-03-21 1:26 ` Shaohua Li
0 siblings, 0 replies; 3+ messages in thread
From: Shaohua Li @ 2012-03-21 1:26 UTC (permalink / raw)
To: Vivek Goyal; +Cc: linux-kernel@vger.kernel.org, axboe@kernel.dk
2012/3/21 Vivek Goyal <vgoyal@redhat.com>:
> On Fri, Mar 16, 2012 at 03:40:06PM +0800, Shaohua Li wrote:
>>
>> Subject: blk: use correct sectors limitation for discard request
>>
>> max_discard_sectors doesn't equal to max_sectors/max_hw_sectors.
>> Without this,
>> discard request merge might be ignored.
>
> In other patch you are making discard request non-mergeable. So what's
> the purpose of this patch.
Yep, this one has no effect with that patch. But this is a bug, and eventually
we will support discard merge. Just to make sure it doesn't slip away.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-03-21 1:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-16 7:40 [patch]blk: use correct sectors limitation for discard request Shaohua Li
2012-03-20 16:31 ` Vivek Goyal
2012-03-21 1:26 ` Shaohua Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).