]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
blk-mq: cleanup shared tags case in blk_mq_update_nr_requests()
authorYu Kuai <yukuai3@huawei.com>
Wed, 10 Sep 2025 08:04:40 +0000 (16:04 +0800)
committerJens Axboe <axboe@kernel.dk>
Wed, 10 Sep 2025 11:25:56 +0000 (05:25 -0600)
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>
block/blk-mq-tag.c
block/blk-mq.c

index 56f9bc839000a32d322b8372f436bde73e429c19..936b68273cad7f2b7643a9c0cb7fbef1867b68f1 100644 (file)
@@ -622,13 +622,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;
index 9b97f2f3f2c90c573ef267d61552d727eceb20e3..80c20700bce85b8efefa36449b1cf32bcd5aa822 100644 (file)
@@ -4935,34 +4935,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);