* [PATCH] blk-mq: fix possible creation failure for 'debugfs_dir'
@ 2022-04-01 3:51 Yu Kuai
2022-04-08 6:53 ` yukuai (C)
0 siblings, 1 reply; 2+ messages in thread
From: Yu Kuai @ 2022-04-01 3:51 UTC (permalink / raw)
To: axboe; +Cc: linux-block, linux-kernel, yukuai3, yi.zhang
'q->debugfs_dir' is created in blk_register_queue(), however, it's not
removed in blk_unregister_queue() and is delayed to blk_release_queue().
Thus it's possible that del_gendisk() is done and the old 'debugfs_dir'
is not removed yet, and in the mean time blk_register_queue() is called
for the new device with the same name. In this case, kernel will
compalin about creation failure for 'debugfs_dir' like following:
debugfs: Directory 'nullb1' with parent 'block' already present!
Fix the problem by moving forward the removal of 'debgfs_dir' to
blk_unregister_queue().
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
block/blk-sysfs.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 88bd41d4cb59..15fc3f0786e3 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -779,11 +779,6 @@ static void blk_release_queue(struct kobject *kobj)
if (queue_is_mq(q))
blk_mq_release(q);
- blk_trace_shutdown(q);
- mutex_lock(&q->debugfs_mutex);
- debugfs_remove_recursive(q->debugfs_dir);
- mutex_unlock(&q->debugfs_mutex);
-
if (queue_is_mq(q))
blk_mq_debugfs_unregister(q);
@@ -951,5 +946,11 @@ void blk_unregister_queue(struct gendisk *disk)
mutex_unlock(&q->sysfs_dir_lock);
+ blk_trace_shutdown(q);
+ mutex_lock(&q->debugfs_mutex);
+ blk_mq_debugfs_unregister_hctxs(q);
+ debugfs_remove_recursive(q->debugfs_dir);
+ mutex_unlock(&q->debugfs_mutex);
+
kobject_put(&disk_to_dev(disk)->kobj);
}
--
2.31.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] blk-mq: fix possible creation failure for 'debugfs_dir'
2022-04-01 3:51 [PATCH] blk-mq: fix possible creation failure for 'debugfs_dir' Yu Kuai
@ 2022-04-08 6:53 ` yukuai (C)
0 siblings, 0 replies; 2+ messages in thread
From: yukuai (C) @ 2022-04-08 6:53 UTC (permalink / raw)
To: axboe; +Cc: linux-block, linux-kernel, yi.zhang
friendly ping ...
在 2022/04/01 11:51, Yu Kuai 写道:
> 'q->debugfs_dir' is created in blk_register_queue(), however, it's not
> removed in blk_unregister_queue() and is delayed to blk_release_queue().
> Thus it's possible that del_gendisk() is done and the old 'debugfs_dir'
> is not removed yet, and in the mean time blk_register_queue() is called
> for the new device with the same name. In this case, kernel will
> compalin about creation failure for 'debugfs_dir' like following:
>
> debugfs: Directory 'nullb1' with parent 'block' already present!
>
> Fix the problem by moving forward the removal of 'debgfs_dir' to
> blk_unregister_queue().
>
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
> ---
> block/blk-sysfs.c | 11 ++++++-----
> 1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
> index 88bd41d4cb59..15fc3f0786e3 100644
> --- a/block/blk-sysfs.c
> +++ b/block/blk-sysfs.c
> @@ -779,11 +779,6 @@ static void blk_release_queue(struct kobject *kobj)
> if (queue_is_mq(q))
> blk_mq_release(q);
>
> - blk_trace_shutdown(q);
> - mutex_lock(&q->debugfs_mutex);
> - debugfs_remove_recursive(q->debugfs_dir);
> - mutex_unlock(&q->debugfs_mutex);
> -
> if (queue_is_mq(q))
> blk_mq_debugfs_unregister(q);
>
> @@ -951,5 +946,11 @@ void blk_unregister_queue(struct gendisk *disk)
>
> mutex_unlock(&q->sysfs_dir_lock);
>
> + blk_trace_shutdown(q);
> + mutex_lock(&q->debugfs_mutex);
> + blk_mq_debugfs_unregister_hctxs(q);
> + debugfs_remove_recursive(q->debugfs_dir);
> + mutex_unlock(&q->debugfs_mutex);
> +
> kobject_put(&disk_to_dev(disk)->kobj);
> }
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-04-08 6:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-01 3:51 [PATCH] blk-mq: fix possible creation failure for 'debugfs_dir' Yu Kuai
2022-04-08 6:53 ` yukuai (C)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®