Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

blk-mq: split bitmap grow and resize case in blk_mq_update_nr_requests()

No functional changes are intended, make code cleaner and prepare to fix
the grow case in following patches.

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Reviewed-by: Nilay Shroff <nilay@linux.ibm.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

Yu Kuai and committed by
Jens Axboe
e6320040 7f2799c5

+27 -12
+27 -12
block/blk-mq.c
··· 4936 4936 blk_mq_quiesce_queue(q); 4937 4937 4938 4938 if (blk_mq_is_shared_tags(set->flags)) { 4939 + /* 4940 + * Shared tags, for sched tags, we allocate max initially hence 4941 + * tags can't grow, see blk_mq_alloc_sched_tags(). 4942 + */ 4939 4943 if (q->elevator) 4940 4944 blk_mq_tag_update_sched_shared_tags(q); 4941 4945 else 4942 4946 blk_mq_tag_resize_shared_tags(set, nr); 4943 - } else { 4947 + } else if (!q->elevator) { 4948 + /* 4949 + * Non-shared hardware tags, nr is already checked from 4950 + * queue_requests_store() and tags can't grow. 4951 + */ 4944 4952 queue_for_each_hw_ctx(q, hctx, i) { 4945 4953 if (!hctx->tags) 4946 4954 continue; 4947 - /* 4948 - * If we're using an MQ scheduler, just update the 4949 - * scheduler queue depth. This is similar to what the 4950 - * old code would do. 4951 - */ 4952 - if (hctx->sched_tags) 4953 - ret = blk_mq_tag_update_depth(hctx, 4954 - &hctx->sched_tags, nr); 4955 - else 4956 - ret = blk_mq_tag_update_depth(hctx, 4957 - &hctx->tags, nr); 4955 + sbitmap_queue_resize(&hctx->tags->bitmap_tags, 4956 + nr - hctx->tags->nr_reserved_tags); 4957 + } 4958 + } else if (nr <= q->elevator->et->nr_requests) { 4959 + /* Non-shared sched tags, and tags don't grow. */ 4960 + queue_for_each_hw_ctx(q, hctx, i) { 4961 + if (!hctx->sched_tags) 4962 + continue; 4963 + sbitmap_queue_resize(&hctx->sched_tags->bitmap_tags, 4964 + nr - hctx->sched_tags->nr_reserved_tags); 4965 + } 4966 + } else { 4967 + /* Non-shared sched tags, and tags grow */ 4968 + queue_for_each_hw_ctx(q, hctx, i) { 4969 + if (!hctx->sched_tags) 4970 + continue; 4971 + ret = blk_mq_tag_update_depth(hctx, &hctx->sched_tags, 4972 + nr); 4958 4973 if (ret) 4959 4974 goto out; 4960 4975 }