public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, Marco Patalano <mpatalan@redhat.com>,
	"Ewan D. Milne" <emilne@redhat.com>
Subject: Re: [PATCH] blk-mq: fix read/write 'nr_requests' in case of 'none' scheduler
Date: Sat, 2 Jun 2018 15:16:08 +0800	[thread overview]
Message-ID: <20180602071600.GA4123@ming.t460p> (raw)
In-Reply-To: <20180602045921.20603-1-ming.lei@redhat.com>

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

      reply	other threads:[~2018-06-02  7:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180602071600.GA4123@ming.t460p \
    --to=ming.lei@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=emilne@redhat.com \
    --cc=linux-block@vger.kernel.org \
    --cc=mpatalan@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox