public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: weiping zhang <zhangweiping@didichuxing.com>
Cc: linux-block@vger.kernel.org
Subject: Re: [PATCH v2 1/2] blk-mq: fix nr_requests wrong value when modify it from sysfs
Date: Thu, 21 Sep 2017 10:37:48 -0600	[thread overview]
Message-ID: <ec64c9c3-fbdf-53c3-358d-370272f4baa6@kernel.dk> (raw)
In-Reply-To: <0dcb22e96bf2c3064c88dd554d6ac9eb95991a54.1506006064.git.zhangweiping@didichuxing.com>

On 09/21/2017 09:17 AM, weiping zhang wrote:
> if blk-mq use "none" io scheduler, nr_request get a wrong value when
> input a number > tag_set->queue_depth. blk_mq_tag_update_depth will get
> the smaller one min(nr, set->queue_depth), and then q->nr_request get a
> wrong value.
> 
> Reproduce:
> 
> echo none > /sys/block/nvme0n1/queue/ioscheduler
> echo 1000000 > /sys/block/nvme0n1/queue/nr_requests
> cat /sys/block/nvme0n1/queue/nr_requests
> 1000000
> 
> Signed-off-by: weiping zhang <zhangweiping@didichuxing.com>
> ---
>  block/blk-mq.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index 98a1860..479c35a 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -2642,8 +2642,12 @@ int blk_mq_update_nr_requests(struct request_queue *q, unsigned int nr)
>  		 * queue depth. This is similar to what the old code would do.
>  		 */
>  		if (!hctx->sched_tags) {
> -			ret = blk_mq_tag_update_depth(hctx, &hctx->tags,
> -							min(nr, set->queue_depth),
> +			if (nr > set->queue_depth) {
> +				ret = -EINVAL;
> +				break;
> +			}
> +
> +			ret = blk_mq_tag_update_depth(hctx, &hctx->tags, nr,
>  							false);

What am I missing here? blk_mq_tag_update_depth() should already return
-EINVAL for the case where we can't grow the tags. Looks like this patch
should simply remove the min(nr, set->queue_depth) and just pass in 'nr'.
Should not need the duplicated check for depth.

-- 
Jens Axboe

  reply	other threads:[~2017-09-21 16:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-21 15:16 [PATCH v2 0/2] fix wrong value when user modify nr_request by sysfs weiping zhang
2017-09-21 15:17 ` [PATCH v2 1/2] blk-mq: fix nr_requests wrong value when modify it from sysfs weiping zhang
2017-09-21 16:37   ` Jens Axboe [this message]
2017-09-21 17:09     ` weiping zhang
2017-09-21 15:17 ` [PATCH v2 2/2] blk-sysfs: return EINVAL when user modify nr_request less than BLKDEV_MIN_RQ weiping zhang
2017-09-21 16:38   ` Jens Axboe
2017-09-21 17:12     ` weiping zhang

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=ec64c9c3-fbdf-53c3-358d-370272f4baa6@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=zhangweiping@didichuxing.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