All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] blk-mq: fix nr_requests wrong value when modify it from sysfs
@ 2017-09-03 13:46 weiping zhang
  2017-09-04 10:02 ` Ming Lei
  2017-09-05 15:42 ` Bart Van Assche
  0 siblings, 2 replies; 9+ messages in thread
From: weiping zhang @ 2017-09-03 13:46 UTC (permalink / raw)
  To: axboe; +Cc: linux-block

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 | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/block/blk-mq.c b/block/blk-mq.c
index f84d145..8303e5e 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -2622,8 +2622,11 @@ 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) {
+				nr = set->queue_depth;
+				pr_warn("reduce nr_request to %u\n", nr);
+			}
+			ret = blk_mq_tag_update_depth(hctx, &hctx->tags, nr,
 							false);
 		} else {
 			ret = blk_mq_tag_update_depth(hctx, &hctx->sched_tags,
-- 
2.9.4

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

end of thread, other threads:[~2017-09-21 15:14 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-03 13:46 [PATCH] blk-mq: fix nr_requests wrong value when modify it from sysfs weiping zhang
2017-09-04 10:02 ` Ming Lei
2017-09-05 15:42 ` Bart Van Assche
2017-09-06  7:34   ` weiping zhang
2017-09-06 13:00     ` Bart Van Assche
2017-09-12 13:57       ` weiping zhang
2017-09-21 13:03         ` weiping zhang
2017-09-21 14:09           ` Jens Axboe
2017-09-21 15:14             ` weiping zhang

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.