[1/4] block: Move the percpu_ref_exit(&q->q_usage_counter) call into __blk_release_queue()
diff mbox series

Message ID 20190401212014.192753-2-bvanassche@acm.org
State New
Headers show
  • Fir a race between request queue cleanup and running queues
Related show

Commit Message

Bart Van Assche April 1, 2019, 9:20 p.m. UTC
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 <hch@infradead.org>
Cc: Hannes Reinecke <hare@suse.com>
Cc: James Smart <james.smart@broadcom.com>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Jianchao Wang <jianchao.w.wang@oracle.com>
Cc: Dongli Zhang <dongli.zhang@oracle.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
 block/blk-core.c  | 2 --
 block/blk-sysfs.c | 1 +
 2 files changed, 1 insertion(+), 2 deletions(-)

diff mbox series

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))
-	percpu_ref_exit(&q->q_usage_counter);
 	/* @q is and will stay empty, shutdown and put */
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)
+	percpu_ref_exit(&q->q_usage_counter);
 	ida_simple_remove(&blk_queue_ida, q->id);
 	call_rcu(&q->rcu_head, blk_free_queue_rcu);