blk-mq: fix nr_requests wrong value when modify it from sysfs
authorweiping zhang <zhangweiping@didichuxing.com>
Fri, 22 Sep 2017 15:36:28 +0000 (23:36 +0800)
committerJens Axboe <axboe@kernel.dk>
Fri, 3 Nov 2017 18:21:06 +0000 (12:21 -0600)
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/scheduler
echo 1000000 > /sys/block/nvme0n1/queue/nr_requests
cat /sys/block/nvme0n1/queue/nr_requests
1000000

Signed-off-by: weiping zhang <zhangweiping@didichuxing.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-mq.c

index 95ea5889b8252ae4f34b93a342fd50eae13bdfe9..9eea67ce82d90e2f77649a1bc46975e96f038358 100644 (file)
@@ -2743,8 +2743,7 @@ 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),
+                       ret = blk_mq_tag_update_depth(hctx, &hctx->tags, nr,
                                                        false);
                } else {
                        ret = blk_mq_tag_update_depth(hctx, &hctx->sched_tags,