From cde762efa676d9cbb627751001cc5711215df2a5 Mon Sep 17 00:00:00 2001 From: Ming Lei Date: Wed, 29 Mar 2023 11:20:07 +0800 Subject: [PATCH] block: move q_usage_counter release into blk_queue_release mainline inclusion from mainline-v5.18-rc1 commit ba3e845665fbbb0252336f27200cd5cf288a3573 category: bugfix bugzilla: 187268, https://gitee.com/openeuler/kernel/issues/I5N162 Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ba3e845665fbbb0252336f27200cd5cf288a3573 ---------------------------------------- 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: Ming Lei Reviewed-by: Bart Van Assche Signed-off-by: Christoph Hellwig Link: https://lore.kernel.org/r/20220308055200.735835-12-hch@lst.de Signed-off-by: Jens Axboe conflicts: block/blk-core.c block/blk-sysfs.c Signed-off-by: Zhong Jinghua Reviewed-by: Hou Tao Signed-off-by: Jialin Zhang --- block/blk-core.c | 2 -- block/blk-sysfs.c | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index 2746db5f54d7..06fb25bd24df 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -431,8 +431,6 @@ void blk_cleanup_queue(struct request_queue *q) blk_mq_sched_free_rqs(q); mutex_unlock(&q->sysfs_lock); - 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 780f02cbda84..35cd1df55680 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -784,6 +784,8 @@ static void blk_release_queue(struct kobject *kobj) might_sleep(); + percpu_ref_exit(&q->q_usage_counter); + if (test_bit(QUEUE_FLAG_POLL_STATS, &q->queue_flags)) blk_stat_remove_callback(q, q->poll_cb); blk_stat_free_callback(q->poll_cb); -- GitLab