From patchwork Fri Jan 4 16:18:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Douglas Gilbert X-Patchwork-Id: 10748435 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9BA6014E5 for ; Fri, 4 Jan 2019 16:18:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3495726BE9 for ; Fri, 4 Jan 2019 16:18:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 27D0228833; Fri, 4 Jan 2019 16:18:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F40A2882D for ; Fri, 4 Jan 2019 16:18:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726686AbfADQSn (ORCPT ); Fri, 4 Jan 2019 11:18:43 -0500 Received: from smtp.infotech.no ([82.134.31.41]:54750 "EHLO smtp.infotech.no" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726554AbfADQSn (ORCPT ); Fri, 4 Jan 2019 11:18:43 -0500 Received: from localhost (localhost [127.0.0.1]) by smtp.infotech.no (Postfix) with ESMTP id 1B2882041CF; Fri, 4 Jan 2019 17:18:41 +0100 (CET) X-Virus-Scanned: by amavisd-new-2.6.6 (20110518) (Debian) at infotech.no Received: from smtp.infotech.no ([127.0.0.1]) by localhost (smtp.infotech.no [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tZbiSm+gMWJT; Fri, 4 Jan 2019 17:18:39 +0100 (CET) Received: from xtwo70.texelconsulting.com (host-184-164-16-103.dyn.295.ca [184.164.16.103]) by smtp.infotech.no (Postfix) with ESMTPA id 52BF820418E; Fri, 4 Jan 2019 17:18:38 +0100 (CET) From: Douglas Gilbert To: linux-scsi@vger.kernel.org Cc: martin.petersen@oracle.com, jejb@linux.vnet.ibm.com, hare@suse.de, john.garry@huawei.com Subject: [PATCH v3] scsi: add debugfs directories Date: Fri, 4 Jan 2019 11:18:36 -0500 Message-Id: <20190104161836.8276-1-dgilbert@interlog.com> X-Mailer: git-send-email 2.17.1 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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. Changes since v2: - export symbols so other driver can use them [John Garry] - make prior code conditional on CONFIG_BLK_DEBUG_FS Changes since v1: - tweak Makefile to keep kbuild test robot happier Signed-off-by: Douglas Gilbert --- 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/Makefile | 2 +- drivers/scsi/scsi.c | 23 +++++++++++++++++++++++ drivers/scsi/scsi_debugfs.c | 16 ++++++++++++++++ drivers/scsi/scsi_debugfs.h | 10 ++++++++++ 4 files changed, 50 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/Makefile b/drivers/scsi/Makefile index fcb41ae329c4..49835e2e5f2d 100644 --- a/drivers/scsi/Makefile +++ b/drivers/scsi/Makefile @@ -163,7 +163,7 @@ scsi_mod-y += scsi_scan.o scsi_sysfs.o scsi_devinfo.o scsi_mod-$(CONFIG_SCSI_NETLINK) += scsi_netlink.o scsi_mod-$(CONFIG_SYSCTL) += scsi_sysctl.o scsi_mod-$(CONFIG_SCSI_PROC_FS) += scsi_proc.o -scsi_mod-$(CONFIG_BLK_DEBUG_FS) += scsi_debugfs.o +scsi_mod-$(CONFIG_DEBUG_FS) += scsi_debugfs.o scsi_mod-y += scsi_trace.o scsi_logging.o scsi_mod-$(CONFIG_PM) += scsi_pm.o scsi_mod-$(CONFIG_SCSI_DH) += scsi_dh.o 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 @@ -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..8d680656da38 100644 --- a/drivers/scsi/scsi_debugfs.c +++ b/drivers/scsi/scsi_debugfs.c @@ -4,6 +4,20 @@ #include #include "scsi_debugfs.h" +#ifdef CONFIG_DEBUG_FS +struct dentry *scsi_debugfs_root; +struct dentry *scsi_debugfs_uld; +struct dentry *scsi_debugfs_lld; + +EXPORT_SYMBOL(scsi_debugfs_root); +EXPORT_SYMBOL(scsi_debugfs_uld); +EXPORT_SYMBOL(scsi_debugfs_lld); + +#endif + + +#ifdef CONFIG_BLK_DEBUG_FS + #define SCSI_CMD_FLAG_NAME(name)[const_ilog2(SCMD_##name)] = #name static const char *const scsi_cmd_flags[] = { SCSI_CMD_FLAG_NAME(TAGGED), @@ -50,3 +64,5 @@ void scsi_show_rq(struct seq_file *m, struct request *rq) timeout_ms / 1000, timeout_ms % 1000, alloc_ms / 1000, alloc_ms % 1000); } + +#endif diff --git a/drivers/scsi/scsi_debugfs.h b/drivers/scsi/scsi_debugfs.h index 951b043e82d0..6de9b4691c82 100644 --- a/drivers/scsi/scsi_debugfs.h +++ b/drivers/scsi/scsi_debugfs.h @@ -1,4 +1,14 @@ +#include + +#ifdef CONFIG_DEBUG_FS +extern struct dentry *scsi_debugfs_root; +extern struct dentry *scsi_debugfs_uld; +extern struct dentry *scsi_debugfs_lld; +#endif + +#ifdef CONFIG_BLK_DEBUG_FS struct request; struct seq_file; void scsi_show_rq(struct seq_file *m, struct request *rq); +#endif