]> www.infradead.org Git - nvme.git/commitdiff
scsi: scsi_debug: Create scsi_debug directory in the debugfs filesystem
authorWenchao Hao <haowenchao2@huawei.com>
Tue, 10 Oct 2023 09:20:42 +0000 (17:20 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 17 Oct 2023 00:50:10 +0000 (20:50 -0400)
Create directory scsi_debug in the root of the debugfs filesystem.  Prepare
to add interface for manage error injection.

Acked-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: Wenchao Hao <haowenchao2@huawei.com>
Link: https://lore.kernel.org/r/20231010092051.608007-2-haowenchao2@huawei.com
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/scsi_debug.c

index 9c0af50501f9ac934b49873899d18e25efe5db5f..562a48f53cda290731739478978ad9d46949127d 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/random.h>
 #include <linux/xarray.h>
 #include <linux/prefetch.h>
+#include <linux/debugfs.h>
 
 #include <net/checksum.h>
 
@@ -862,6 +863,8 @@ static const int device_qfull_result =
 
 static const int condition_met_result = SAM_STAT_CONDITION_MET;
 
+static struct dentry *sdebug_debugfs_root;
+
 
 /* Only do the extra work involved in logical block provisioning if one or
  * more of the lbpu, lbpws or lbpws10 parameters are given and we are doing
@@ -7011,6 +7014,10 @@ static int __init scsi_debug_init(void)
                goto driver_unreg;
        }
 
+       sdebug_debugfs_root = debugfs_create_dir("scsi_debug", NULL);
+       if (IS_ERR_OR_NULL(sdebug_debugfs_root))
+               pr_info("%s: failed to create initial debugfs directory\n", __func__);
+
        for (k = 0; k < hosts_to_add; k++) {
                if (want_store && k == 0) {
                        ret = sdebug_add_host_helper(idx);
@@ -7057,6 +7064,7 @@ static void __exit scsi_debug_exit(void)
 
        sdebug_erase_all_stores(false);
        xa_destroy(per_store_ap);
+       debugfs_remove(sdebug_debugfs_root);
 }
 
 device_initcall(scsi_debug_init);