提交 ba3e8456 编写于 作者: M Ming Lei 提交者: Jens Axboe

block: move q_usage_counter release into blk_queue_release

After blk_cleanup_queue() returns, disk may not be released yet, so
probably bio may still be submitted and ->q_usage_counter may be
touched, so far this way seems safe, but not good from API's viewpoint.

Move the release q_usage_counter into blk_queue_release().
Signed-off-by: NMing Lei <ming.lei@redhat.com>
Reviewed-by: NBart Van Assche <bvanassche@acm.org>
Signed-off-by: NChristoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20220308055200.735835-12-hch@lst.deSigned-off-by: NJens Axboe <axboe@kernel.dk>
上级 de3d347f
...@@ -342,8 +342,6 @@ void blk_cleanup_queue(struct request_queue *q) ...@@ -342,8 +342,6 @@ void blk_cleanup_queue(struct request_queue *q)
blk_mq_sched_free_rqs(q); blk_mq_sched_free_rqs(q);
mutex_unlock(&q->sysfs_lock); mutex_unlock(&q->sysfs_lock);
percpu_ref_exit(&q->q_usage_counter);
/* @q is and will stay empty, shutdown and put */ /* @q is and will stay empty, shutdown and put */
blk_put_queue(q); blk_put_queue(q);
} }
......
...@@ -780,6 +780,8 @@ static void blk_release_queue(struct kobject *kobj) ...@@ -780,6 +780,8 @@ static void blk_release_queue(struct kobject *kobj)
might_sleep(); might_sleep();
percpu_ref_exit(&q->q_usage_counter);
if (q->poll_stat) if (q->poll_stat)
blk_stat_remove_callback(q, q->poll_cb); blk_stat_remove_callback(q, q->poll_cb);
blk_stat_free_callback(q->poll_cb); blk_stat_free_callback(q->poll_cb);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册