All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] blk-mq: fix read/write 'nr_requests' in case of 'none' scheduler
@ 2018-06-02  4:59 Ming Lei
  2018-06-02  7:16 ` Ming Lei
  0 siblings, 1 reply; 2+ messages in thread
From: Ming Lei @ 2018-06-02  4:59 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, Ming Lei, Marco Patalano, Ewan D. Milne

If the current io scheduler is 'none', the max allowed 'nr_requests'
should be from set->queue_depth, instead of the tags's depth, which
can be adjusted before.

This patch fixes this issue by using set->queue_depth as the max
allowed 'nr_requests', meantime updating q->nr_requests when switching
to 'none' scheduler.

Cc: Marco Patalano <mpatalan@redhat.com>
Cc: "Ewan D. Milne" <emilne@redhat.com>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---

This issue can be reproduced by the blktests block/021, which will
be posted soon.


 block/blk-mq-sched.c | 1 +
 block/blk-mq-tag.c   | 6 ++++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c
index b0f2c2a40a0c..b087d8884a08 100644
--- a/block/blk-mq-sched.c
+++ b/block/blk-mq-sched.c
@@ -585,6 +585,7 @@ int blk_mq_init_sched(struct request_queue *q, struct elevator_type *e)
 
 	if (!e) {
 		q->elevator = NULL;
+		q->nr_requests = q->tag_set->queue_depth;
 		return 0;
 	}
 
diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c
index a4e58fc28a06..a178d862a29a 100644
--- a/block/blk-mq-tag.c
+++ b/block/blk-mq-tag.c
@@ -423,7 +423,9 @@ int blk_mq_tag_update_depth(struct blk_mq_hw_ctx *hctx,
 			    struct blk_mq_tags **tagsptr, unsigned int tdepth,
 			    bool can_grow)
 {
+	struct blk_mq_tag_set *set = hctx->queue->tag_set;
 	struct blk_mq_tags *tags = *tagsptr;
+	unsigned int max_depth;
 
 	if (tdepth <= tags->nr_reserved_tags)
 		return -EINVAL;
@@ -434,8 +436,8 @@ int blk_mq_tag_update_depth(struct blk_mq_hw_ctx *hctx,
 	 * If we are allowed to grow beyond the original size, allocate
 	 * a new set of tags before freeing the old one.
 	 */
-	if (tdepth > tags->nr_tags) {
-		struct blk_mq_tag_set *set = hctx->queue->tag_set;
+	max_depth = can_grow ? tags->nr_tags: set->queue_depth;
+	if (tdepth > max_depth) {
 		struct blk_mq_tags *new;
 		bool ret;
 
-- 
2.9.5

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

* Re: [PATCH] blk-mq: fix read/write 'nr_requests' in case of 'none' scheduler
  2018-06-02  4:59 [PATCH] blk-mq: fix read/write 'nr_requests' in case of 'none' scheduler Ming Lei
@ 2018-06-02  7:16 ` Ming Lei
  0 siblings, 0 replies; 2+ messages in thread
From: Ming Lei @ 2018-06-02  7:16 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block, Marco Patalano, Ewan D. Milne

On Sat, Jun 02, 2018 at 12:59:21PM +0800, Ming Lei wrote:
> If the current io scheduler is 'none', the max allowed 'nr_requests'
> should be from set->queue_depth, instead of the tags's depth, which
> can be adjusted before.
> 
> This patch fixes this issue by using set->queue_depth as the max
> allowed 'nr_requests', meantime updating q->nr_requests when switching
> to 'none' scheduler.
> 
> Cc: Marco Patalano <mpatalan@redhat.com>
> Cc: "Ewan D. Milne" <emilne@redhat.com>
> Signed-off-by: Ming Lei <ming.lei@redhat.com>
> ---
> 
> This issue can be reproduced by the blktests block/021, which will
> be posted soon.
> 
> 
>  block/blk-mq-sched.c | 1 +
>  block/blk-mq-tag.c   | 6 ++++--
>  2 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c
> index b0f2c2a40a0c..b087d8884a08 100644
> --- a/block/blk-mq-sched.c
> +++ b/block/blk-mq-sched.c
> @@ -585,6 +585,7 @@ int blk_mq_init_sched(struct request_queue *q, struct elevator_type *e)
>  
>  	if (!e) {
>  		q->elevator = NULL;
> +		q->nr_requests = q->tag_set->queue_depth;
>  		return 0;
>  	}
>  
> diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c
> index a4e58fc28a06..a178d862a29a 100644
> --- a/block/blk-mq-tag.c
> +++ b/block/blk-mq-tag.c
> @@ -423,7 +423,9 @@ int blk_mq_tag_update_depth(struct blk_mq_hw_ctx *hctx,
>  			    struct blk_mq_tags **tagsptr, unsigned int tdepth,
>  			    bool can_grow)
>  {
> +	struct blk_mq_tag_set *set = hctx->queue->tag_set;
>  	struct blk_mq_tags *tags = *tagsptr;
> +	unsigned int max_depth;
>  
>  	if (tdepth <= tags->nr_reserved_tags)
>  		return -EINVAL;
> @@ -434,8 +436,8 @@ int blk_mq_tag_update_depth(struct blk_mq_hw_ctx *hctx,
>  	 * If we are allowed to grow beyond the original size, allocate
>  	 * a new set of tags before freeing the old one.
>  	 */
> -	if (tdepth > tags->nr_tags) {
> -		struct blk_mq_tag_set *set = hctx->queue->tag_set;
> +	max_depth = can_grow ? tags->nr_tags: set->queue_depth;
> +	if (tdepth > max_depth) {
>  		struct blk_mq_tags *new;
>  		bool ret;

Turns out the change on blk_mq_tag_update_depth() isn't necessary,
will post a new one.

Thanks,
Ming

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

end of thread, other threads:[~2018-06-02  7:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-02  4:59 [PATCH] blk-mq: fix read/write 'nr_requests' in case of 'none' scheduler Ming Lei
2018-06-02  7:16 ` Ming Lei

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.