[PATCH] nvmet: Initialize discovery subsys after debugfs is initialized

Mohamed Khalfella posted 1 patch 2 months, 1 week ago
drivers/nvme/target/core.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
[PATCH] nvmet: Initialize discovery subsys after debugfs is initialized
Posted by Mohamed Khalfella 2 months, 1 week ago
During nvme target initialization discovery subsystem is initialized
before "nvmet" debugfs directory is created. This results in discovery
subsystem debugfs directory to be created in debugfs root directory.

nvmet_init() ->
  nvmet_init_discovery() ->
    nvmet_subsys_alloc() ->
      nvmet_debugfs_subsys_setup()

In other words, the codepath above is exeucted before nvmet_debugfs is
created. We get /sys/kernel/debug/nqn.2014-08.org.nvmexpress.discovery
instead of /sys/kernel/debug/nvmet/nqn.2014-08.org.nvmexpress.discovery.
Move nvmet_init_discovery() call after nvmet_init_debugfs() to fix it.

Fixes: 649fd41420a8 ("nvmet: add debugfs support")
Signed-off-by: Mohamed Khalfella <mkhalfella@purestorage.com>
---
 drivers/nvme/target/core.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index 175c5b6d4dd5..b6247e4afc9c 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -1962,24 +1962,24 @@ static int __init nvmet_init(void)
 	if (!nvmet_wq)
 		goto out_free_buffered_work_queue;
 
-	error = nvmet_init_discovery();
+	error = nvmet_init_debugfs();
 	if (error)
 		goto out_free_nvmet_work_queue;
 
-	error = nvmet_init_debugfs();
+	error = nvmet_init_discovery();
 	if (error)
-		goto out_exit_discovery;
+		goto out_exit_debugfs;
 
 	error = nvmet_init_configfs();
 	if (error)
-		goto out_exit_debugfs;
+		goto out_exit_discovery;
 
 	return 0;
 
-out_exit_debugfs:
-	nvmet_exit_debugfs();
 out_exit_discovery:
 	nvmet_exit_discovery();
+out_exit_debugfs:
+	nvmet_exit_debugfs();
 out_free_nvmet_work_queue:
 	destroy_workqueue(nvmet_wq);
 out_free_buffered_work_queue:
-- 
2.49.1
Re: [PATCH] nvmet: Initialize discovery subsys after debugfs is initialized
Posted by Christoph Hellwig 2 months, 1 week ago
Thanks, applied to nvme-6.17.
Re: [PATCH] nvmet: Initialize discovery subsys after debugfs is initialized
Posted by Nitesh Shetty 2 months, 1 week ago
On 25/07/25 01:50PM, Mohamed Khalfella wrote:
>During nvme target initialization discovery subsystem is initialized
>before "nvmet" debugfs directory is created. This results in discovery
>subsystem debugfs directory to be created in debugfs root directory.
>
>nvmet_init() ->
>  nvmet_init_discovery() ->
>    nvmet_subsys_alloc() ->
>      nvmet_debugfs_subsys_setup()
>
>In other words, the codepath above is exeucted before nvmet_debugfs is
>created. We get /sys/kernel/debug/nqn.2014-08.org.nvmexpress.discovery
>instead of /sys/kernel/debug/nvmet/nqn.2014-08.org.nvmexpress.discovery.
>Move nvmet_init_discovery() call after nvmet_init_debugfs() to fix it.
>
>Fixes: 649fd41420a8 ("nvmet: add debugfs support")
>Signed-off-by: Mohamed Khalfella <mkhalfella@purestorage.com>
>---

Reviewed-by: Nitesh Shetty <nj.shetty@samsung.com>
Re: [PATCH] nvmet: Initialize discovery subsys after debugfs is initialized
Posted by Hannes Reinecke 2 months, 1 week ago
On 7/25/25 22:50, Mohamed Khalfella wrote:
> During nvme target initialization discovery subsystem is initialized
> before "nvmet" debugfs directory is created. This results in discovery
> subsystem debugfs directory to be created in debugfs root directory.
> 
> nvmet_init() ->
>    nvmet_init_discovery() ->
>      nvmet_subsys_alloc() ->
>        nvmet_debugfs_subsys_setup()
> 
> In other words, the codepath above is exeucted before nvmet_debugfs is
> created. We get /sys/kernel/debug/nqn.2014-08.org.nvmexpress.discovery
> instead of /sys/kernel/debug/nvmet/nqn.2014-08.org.nvmexpress.discovery.
> Move nvmet_init_discovery() call after nvmet_init_debugfs() to fix it.
> 
> Fixes: 649fd41420a8 ("nvmet: add debugfs support")
> Signed-off-by: Mohamed Khalfella <mkhalfella@purestorage.com>
> ---
>   drivers/nvme/target/core.c | 12 ++++++------
>   1 file changed, 6 insertions(+), 6 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@kernel.org>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                  Kernel Storage Architect
hare@suse.de                                +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
Re: [PATCH] nvmet: Initialize discovery subsys after debugfs is initialized
Posted by Chaitanya Kulkarni 2 months, 1 week ago
On 7/25/25 13:50, Mohamed Khalfella wrote:
> During nvme target initialization discovery subsystem is initialized
> before "nvmet" debugfs directory is created. This results in discovery
> subsystem debugfs directory to be created in debugfs root directory.
>
> nvmet_init() ->
>    nvmet_init_discovery() ->
>      nvmet_subsys_alloc() ->
>        nvmet_debugfs_subsys_setup()
>
> In other words, the codepath above is exeucted before nvmet_debugfs is
> created. We get /sys/kernel/debug/nqn.2014-08.org.nvmexpress.discovery
> instead of /sys/kernel/debug/nvmet/nqn.2014-08.org.nvmexpress.discovery.
> Move nvmet_init_discovery() call after nvmet_init_debugfs() to fix it.
>
> Fixes: 649fd41420a8 ("nvmet: add debugfs support")
> Signed-off-by: Mohamed Khalfella<mkhalfella@purestorage.com>
> ---

Looks good.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>

-ck


Re: [PATCH] nvmet: Initialize discovery subsys after debugfs is initialized
Posted by Daniel Wagner 2 months, 1 week ago
On Fri, Jul 25, 2025 at 01:50:05PM -0700, Mohamed Khalfella wrote:
> During nvme target initialization discovery subsystem is initialized
> before "nvmet" debugfs directory is created. This results in discovery
> subsystem debugfs directory to be created in debugfs root directory.
> 
> nvmet_init() ->
>   nvmet_init_discovery() ->
>     nvmet_subsys_alloc() ->
>       nvmet_debugfs_subsys_setup()
> 
> In other words, the codepath above is exeucted before nvmet_debugfs is
> created. We get /sys/kernel/debug/nqn.2014-08.org.nvmexpress.discovery
> instead of /sys/kernel/debug/nvmet/nqn.2014-08.org.nvmexpress.discovery.
> Move nvmet_init_discovery() call after nvmet_init_debugfs() to fix it.
> 
> Fixes: 649fd41420a8 ("nvmet: add debugfs support")
> Signed-off-by: Mohamed Khalfella <mkhalfella@purestorage.com>

Reviewed-by: Daniel Wagner <dwagner@suse.de>