This patch makes it safe to access the queue usage counter from inside
blk_mq_run_hw_queues(). Other than deferring q_usage_counter freeing,
this patch does not change any functionality.

Cc: Christoph Hellwig <[email protected]>
Cc: Hannes Reinecke <[email protected]>
Cc: James Smart <[email protected]>
Cc: Ming Lei <[email protected]>
Cc: Jianchao Wang <[email protected]>
Cc: Dongli Zhang <[email protected]>
Cc: <[email protected]>
Signed-off-by: Bart Van Assche <[email protected]>
---
 block/blk-core.c  | 2 --
 block/blk-sysfs.c | 1 +
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/block/blk-core.c b/block/blk-core.c
index 4673ebe42255..fdcf6de2243f 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -377,8 +377,6 @@ void blk_cleanup_queue(struct request_queue *q)
        if (queue_is_mq(q))
                blk_mq_free_queue(q);
 
-       percpu_ref_exit(&q->q_usage_counter);
-
        /* @q is and will stay empty, shutdown and put */
        blk_put_queue(q);
 }
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 422327089e0f..b8b3d69cd0a5 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -870,6 +870,7 @@ static void __blk_release_queue(struct work_struct *work)
 
        bioset_exit(&q->bio_split);
 
+       percpu_ref_exit(&q->q_usage_counter);
        ida_simple_remove(&blk_queue_ida, q->id);
        call_rcu(&q->rcu_head, blk_free_queue_rcu);
 }
-- 
2.21.0.196.g041f5ea1cf98

Reply via email to