diff mbox series

scsi: add debugfs directories

Message ID 20190101153946.15872-1-dgilbert@interlog.com (mailing list archive)
State Superseded
Headers show
Series scsi: add debugfs directories | expand

Commit Message

Douglas Gilbert Jan. 1, 2019, 3:39 p.m. UTC
Add a top level "scsi" directory in debugfs (usually at 
/sys/kernel/debugfs/scsi) with two subdirectories: "uld" and "lld".
The idea is to place mid-level related 'knobs' in the "scsi"
directory, and for the ULDs to make subsirectories like
"scsi/uld/sd" and "scsi/uld/st" as required. LLDs could follow a
similar pattern.

Signed-off-by: Douglas Gilbert <dgilbert@interlog.com>
---

My intention is to add a /sys/kernel/debugfs/scsi/uld/sg
directory containing at least a pseudo file called debug to have
the same actions as /proc/scsi/sg/debug , as part of my v4
patchset.

 drivers/scsi/scsi.c         | 23 +++++++++++++++++++++++
 drivers/scsi/scsi_debugfs.c |  6 ++++++
 drivers/scsi/scsi_debugfs.h |  8 ++++++++
 3 files changed, 37 insertions(+)

Comments

kernel test robot Jan. 1, 2019, 4:49 p.m. UTC | #1
Hi Douglas,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on scsi/for-next]
[also build test ERROR on v4.20 next-20181224]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Douglas-Gilbert/scsi-add-debugfs-directories/20190101-234113
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
config: i386-randconfig-s0-201900 (attached as .config)
compiler: gcc-6 (Debian 6.4.0-9) 6.4.0 20171026
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

   drivers/scsi/scsi.o: In function `exit_scsi':
>> drivers/scsi/scsi.c:856: undefined reference to `scsi_debugfs_root'
   drivers/scsi/scsi.o: In function `init_scsi':
   drivers/scsi/scsi.c:817: undefined reference to `scsi_debugfs_root'
>> drivers/scsi/scsi.c:820: undefined reference to `scsi_debugfs_uld'
   drivers/scsi/scsi.c:823: undefined reference to `scsi_debugfs_root'
>> drivers/scsi/scsi.c:823: undefined reference to `scsi_debugfs_lld'
   drivers/scsi/scsi.c:833: undefined reference to `scsi_debugfs_root'

vim +856 drivers/scsi/scsi.c

   790	
   791	static int __init init_scsi(void)
   792	{
   793		int error;
   794	
   795		error = scsi_init_queue();
   796		if (error)
   797			return error;
   798		error = scsi_init_procfs();
   799		if (error)
   800			goto cleanup_queue;
   801		error = scsi_init_devinfo();
   802		if (error)
   803			goto cleanup_procfs;
   804		error = scsi_init_hosts();
   805		if (error)
   806			goto cleanup_devlist;
   807		error = scsi_init_sysctl();
   808		if (error)
   809			goto cleanup_hosts;
   810		error = scsi_sysfs_register();
   811		if (error)
   812			goto cleanup_sysctl;
   813	
   814		scsi_netlink_init();
   815	
   816	#ifdef CONFIG_DEBUG_FS
   817		scsi_debugfs_root = debugfs_create_dir("scsi", NULL);
   818		if (!scsi_debugfs_root)
   819			goto cleanup_netlink;
 > 820		scsi_debugfs_uld = debugfs_create_dir("uld", scsi_debugfs_root);
   821		if (!scsi_debugfs_uld)
   822			goto cleanup_debugfs;
 > 823		scsi_debugfs_lld = debugfs_create_dir("lld", scsi_debugfs_root);
   824		if (!scsi_debugfs_lld)
   825			goto cleanup_debugfs;
   826	#endif
   827	
   828		printk(KERN_NOTICE "SCSI subsystem initialized\n");
   829		return 0;
   830	
   831	#ifdef CONFIG_DEBUG_FS
   832	cleanup_debugfs:
   833		debugfs_remove_recursive(scsi_debugfs_root);
   834	cleanup_netlink:
   835		scsi_netlink_exit();
   836	#endif
   837	cleanup_sysctl:
   838		scsi_exit_sysctl();
   839	cleanup_hosts:
   840		scsi_exit_hosts();
   841	cleanup_devlist:
   842		scsi_exit_devinfo();
   843	cleanup_procfs:
   844		scsi_exit_procfs();
   845	cleanup_queue:
   846		scsi_exit_queue();
   847		printk(KERN_ERR "SCSI subsystem failed to initialize, error = %d\n",
   848		       -error);
   849		return error;
   850	}
   851	
   852	static void __exit exit_scsi(void)
   853	{
   854	
   855	#ifdef CONFIG_DEBUG_FS
 > 856		debugfs_remove_recursive(scsi_debugfs_root);
   857	#endif
   858		scsi_netlink_exit();
   859		scsi_sysfs_unregister();
   860		scsi_exit_sysctl();
   861		scsi_exit_hosts();
   862		scsi_exit_devinfo();
   863		scsi_exit_procfs();
   864		scsi_exit_queue();
   865		async_unregister_domain(&scsi_sd_probe_domain);
   866	}
   867	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
kernel test robot Jan. 1, 2019, 7:23 p.m. UTC | #2
Hi Douglas,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on scsi/for-next]
[also build test ERROR on v4.20 next-20181224]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Douglas-Gilbert/scsi-add-debugfs-directories/20190101-234113
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
config: x86_64-randconfig-s5-01020141 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

>> ERROR: "scsi_debugfs_uld" [drivers/scsi/scsi_mod.ko] undefined!
>> ERROR: "scsi_debugfs_root" [drivers/scsi/scsi_mod.ko] undefined!
>> ERROR: "scsi_debugfs_lld" [drivers/scsi/scsi_mod.ko] undefined!

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
Douglas Gilbert Jan. 1, 2019, 8:52 p.m. UTC | #3
Thanks.

I built with the supplied config file and version 2 of this patch and there
was no problem.

Doug Gilbert

On 2019-01-01 2:23 p.m., kbuild test robot wrote:
> Hi Douglas,
> 
> Thank you for the patch! Yet something to improve:
> 
> [auto build test ERROR on scsi/for-next]
> [also build test ERROR on v4.20 next-20181224]
> [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
> 
> url:    https://github.com/0day-ci/linux/commits/Douglas-Gilbert/scsi-add-debugfs-directories/20190101-234113
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
> config: x86_64-randconfig-s5-01020141 (attached as .config)
> compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
> reproduce:
>          # save the attached .config to linux build tree
>          make ARCH=x86_64
> 
> All errors (new ones prefixed by >>):
> 
>>> ERROR: "scsi_debugfs_uld" [drivers/scsi/scsi_mod.ko] undefined!
>>> ERROR: "scsi_debugfs_root" [drivers/scsi/scsi_mod.ko] undefined!
>>> ERROR: "scsi_debugfs_lld" [drivers/scsi/scsi_mod.ko] undefined!
> 
> ---
> 0-DAY kernel test infrastructure                Open Source Technology Center
> https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
>
diff mbox series

Patch

diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index fc1356d101b0..01d4d0686699 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -68,6 +68,7 @@ 
 
 #include "scsi_priv.h"
 #include "scsi_logging.h"
+#include "scsi_debugfs.h"
 
 #define CREATE_TRACE_POINTS
 #include <trace/events/scsi.h>
@@ -812,9 +813,27 @@  static int __init init_scsi(void)
 
 	scsi_netlink_init();
 
+#ifdef CONFIG_DEBUG_FS
+	scsi_debugfs_root = debugfs_create_dir("scsi", NULL);
+	if (!scsi_debugfs_root)
+		goto cleanup_netlink;
+	scsi_debugfs_uld = debugfs_create_dir("uld", scsi_debugfs_root);
+	if (!scsi_debugfs_uld)
+		goto cleanup_debugfs;
+	scsi_debugfs_lld = debugfs_create_dir("lld", scsi_debugfs_root);
+	if (!scsi_debugfs_lld)
+		goto cleanup_debugfs;
+#endif
+
 	printk(KERN_NOTICE "SCSI subsystem initialized\n");
 	return 0;
 
+#ifdef CONFIG_DEBUG_FS
+cleanup_debugfs:
+	debugfs_remove_recursive(scsi_debugfs_root);
+cleanup_netlink:
+	scsi_netlink_exit();
+#endif
 cleanup_sysctl:
 	scsi_exit_sysctl();
 cleanup_hosts:
@@ -832,6 +851,10 @@  static int __init init_scsi(void)
 
 static void __exit exit_scsi(void)
 {
+
+#ifdef CONFIG_DEBUG_FS
+	debugfs_remove_recursive(scsi_debugfs_root);
+#endif
 	scsi_netlink_exit();
 	scsi_sysfs_unregister();
 	scsi_exit_sysctl();
diff --git a/drivers/scsi/scsi_debugfs.c b/drivers/scsi/scsi_debugfs.c
index c5a8756384bc..b06eee3a134e 100644
--- a/drivers/scsi/scsi_debugfs.c
+++ b/drivers/scsi/scsi_debugfs.c
@@ -4,6 +4,12 @@ 
 #include <scsi/scsi_dbg.h>
 #include "scsi_debugfs.h"
 
+#ifdef CONFIG_DEBUG_FS
+struct dentry *scsi_debugfs_root;
+struct dentry *scsi_debugfs_uld;
+struct dentry *scsi_debugfs_lld;
+#endif
+
 #define SCSI_CMD_FLAG_NAME(name)[const_ilog2(SCMD_##name)] = #name
 static const char *const scsi_cmd_flags[] = {
 	SCSI_CMD_FLAG_NAME(TAGGED),
diff --git a/drivers/scsi/scsi_debugfs.h b/drivers/scsi/scsi_debugfs.h
index 951b043e82d0..b1a8de6eaf07 100644
--- a/drivers/scsi/scsi_debugfs.h
+++ b/drivers/scsi/scsi_debugfs.h
@@ -1,4 +1,12 @@ 
+#include <linux/debugfs.h>
+
 struct request;
 struct seq_file;
 
+#ifdef CONFIG_DEBUG_FS
+extern struct dentry *scsi_debugfs_root;
+extern struct dentry *scsi_debugfs_uld;
+extern struct dentry *scsi_debugfs_lld;
+#endif
+
 void scsi_show_rq(struct seq_file *m, struct request *rq);