block: only allocate/free mq_usage_counter in blk-mq
The percpu counter is only used for blk-mq, so move
its allocation and free inside blk-mq, and don't
allocate it for legacy queue device.
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 0785175..e8b5f74 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -1781,6 +1781,9 @@
if (!q)
goto err_hctxs;
+ if (percpu_counter_init(&q->mq_usage_counter, 0))
+ goto err_map;
+
q->mq_map = blk_mq_make_queue_map(set);
if (!q->mq_map)
goto err_map;
@@ -1867,6 +1870,8 @@
blk_mq_exit_hw_queues(q, set, set->nr_hw_queues);
blk_mq_free_hw_queues(q, set);
+ percpu_counter_destroy(&q->mq_usage_counter);
+
free_percpu(q->queue_ctx);
kfree(q->queue_hw_ctx);
kfree(q->mq_map);