summaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorYu Kuai <yukuai3@huawei.com>2025-09-10 16:04:40 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-10-15 12:03:29 +0200
commit64cb378502fbca246ff7103386afbba0b8ae1e54 (patch)
treeee86f2eef91a2abc90f653f08577c2197fd8a789 /block
parentb1b9ba3c2ea2e6b09f8b23ae0cf54a3b5c63c288 (diff)
downloadlinux-64cb378502fbca246ff7103386afbba0b8ae1e54.tar.gz
linux-64cb378502fbca246ff7103386afbba0b8ae1e54.tar.bz2
linux-64cb378502fbca246ff7103386afbba0b8ae1e54.zip
blk-mq: cleanup shared tags case in blk_mq_update_nr_requests()
[ Upstream commit 7f2799c546dba9e12f9ff4d07936601e416c640d ] For shared tags case, all hctx->sched_tags/tags are the same, it doesn't make sense to call into blk_mq_tag_update_depth() multiple times for the same tags. Signed-off-by: Yu Kuai <yukuai3@huawei.com> Reviewed-by: Nilay Shroff <nilay@linux.ibm.com> Signed-off-by: Jens Axboe <axboe@kernel.dk> Stable-dep-of: b86433721f46 ("blk-mq: fix potential deadlock while nr_requests grown") Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'block')
-rw-r--r--block/blk-mq-tag.c7
-rw-r--r--block/blk-mq.c43
2 files changed, 22 insertions, 28 deletions
diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c
index 725210f27471..aed84c5d5c2b 100644
--- a/block/blk-mq-tag.c
+++ b/block/blk-mq-tag.c
@@ -596,13 +596,6 @@ int blk_mq_tag_update_depth(struct blk_mq_hw_ctx *hctx,
struct blk_mq_tag_set *set = hctx->queue->tag_set;
struct blk_mq_tags *new;
- /*
- * Only the sbitmap needs resizing since we allocated the max
- * initially.
- */
- if (blk_mq_is_shared_tags(set->flags))
- return 0;
-
new = blk_mq_alloc_map_and_rqs(set, hctx->queue_num, tdepth);
if (!new)
return -ENOMEM;
diff --git a/block/blk-mq.c b/block/blk-mq.c
index a81ef562014d..bcb7495893a0 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -4934,34 +4934,35 @@ int blk_mq_update_nr_requests(struct request_queue *q, unsigned int nr)
blk_mq_quiesce_queue(q);
- queue_for_each_hw_ctx(q, hctx, i) {
- if (!hctx->tags)
- continue;
- /*
- * If we're using an MQ scheduler, just update the scheduler
- * queue depth. This is similar to what the old code would do.
- */
- if (hctx->sched_tags) {
- ret = blk_mq_tag_update_depth(hctx, &hctx->sched_tags,
- nr);
- } else {
- ret = blk_mq_tag_update_depth(hctx, &hctx->tags, nr);
- }
- if (ret)
- goto out;
- }
-
- q->nr_requests = nr;
- if (q->elevator && q->elevator->type->ops.depth_updated)
- q->elevator->type->ops.depth_updated(q);
-
if (blk_mq_is_shared_tags(set->flags)) {
if (q->elevator)
blk_mq_tag_update_sched_shared_tags(q);
else
blk_mq_tag_resize_shared_tags(set, nr);
+ } else {
+ queue_for_each_hw_ctx(q, hctx, i) {
+ if (!hctx->tags)
+ continue;
+ /*
+ * If we're using an MQ scheduler, just update the
+ * scheduler queue depth. This is similar to what the
+ * old code would do.
+ */
+ if (hctx->sched_tags)
+ ret = blk_mq_tag_update_depth(hctx,
+ &hctx->sched_tags, nr);
+ else
+ ret = blk_mq_tag_update_depth(hctx,
+ &hctx->tags, nr);
+ if (ret)
+ goto out;
+ }
}
+ q->nr_requests = nr;
+ if (q->elevator && q->elevator->type->ops.depth_updated)
+ q->elevator->type->ops.depth_updated(q);
+
out:
blk_mq_unquiesce_queue(q);