Message ID | 20230922092906.2645265-2-haowenchao2@huawei.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5436853vqi; Fri, 22 Sep 2023 02:40:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGvowVQ2QENa4z5lZuMM13fYmm7CHE2bCZqaIjHmwBw5GkFHSEZL/pK52col6gxZecetSBh X-Received: by 2002:a17:902:e881:b0:1c3:6667:5ff1 with SMTP id w1-20020a170902e88100b001c366675ff1mr8841214plg.27.1695375630243; Fri, 22 Sep 2023 02:40:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695375630; cv=none; d=google.com; s=arc-20160816; b=G3Wf9UaM5J2iuMi9aMVcxDmtlyI8mUoANlWsofNB6D4DKa2LX9espKR5Ek18W+rEgW /wMG6ApeztffR+lgyaxB/Ops+g3t7HhiCscCZO7owXIsndk3RcK9Qc/tNmqxmfVg6HIu QKJR6dTr3AJZqxIzlUzxYEy6WU/vafAcI/SdqnIhipGMsuF52MTRkcOnBLTSoOF8dku1 AKQogaxAFplUwO1kSSIS7onFBSPF/vsCaAbA9OiPbQS3mXWFyO/OD5irq/MN/ppCoUJk Q8g0OrCu/pCgSYQdWxSIz0Def0nRcsGVJ2Xvgiq/9z74CO6tNHALtwQUKvQqlUHu4HeA gMIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=N6WwxwIcbPfkgNi3aY9NOF3oFzlUeilablusCcr8qoQ=; fh=efbNbptNhbD3foczTZf5UTdQGTI/0Ud9virqYphOI9o=; b=KgghYFJOpOrTeF/hD4S9KcPX9wcR/qjpXhGhY6cChG/B3X4m2JBRaD2ZSx9Fyrwicv WDzuuYYKML1zLN5VBr9/2vxpEzrVkz8INNIEkz4bSadcYTgEoV21cuJrZEzxWI9DbKvV 1J09mjgyxBrnJ91qy7g6heku1ci5thnNxf1RN0/fx45Zl13MVv8eYtcRECDhIE9Kp+OE irbmPOR3E4o5Cq//w2lLE/1l8bdaRwvBCih9X2P5ovJMhMfZWCYMbLEmA76LYIJ7wckT kG2iNzLQvG5qUmEkAIaJTAxq97yk+N6T4oXJV7y1TwxJHJ00XbgMHTBO1hZrmRHr6TjQ hRCA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id o21-20020a170903211500b001c33d7759c8si3214018ple.47.2023.09.22.02.40.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 02:40:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 04222823C12C; Fri, 22 Sep 2023 02:30:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233199AbjIVJaE (ORCPT <rfc822;chrisfriedt@gmail.com> + 30 others); Fri, 22 Sep 2023 05:30:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44516 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233228AbjIVJ3s (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 22 Sep 2023 05:29:48 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43B50CC6; Fri, 22 Sep 2023 02:29:34 -0700 (PDT) Received: from kwepemm000012.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4RsRgw3H3lztSwS; Fri, 22 Sep 2023 17:25:16 +0800 (CST) Received: from build.huawei.com (10.175.101.6) by kwepemm000012.china.huawei.com (7.193.23.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Fri, 22 Sep 2023 17:29:32 +0800 From: Wenchao Hao <haowenchao2@huawei.com> To: "James E . J . Bottomley" <jejb@linux.ibm.com>, "Martin K . Petersen" <martin.petersen@oracle.com>, Douglas Gilbert <dgilbert@interlog.com>, <open-iscsi@googlegroups.com>, <linux-scsi@vger.kernel.org> CC: <linux-kernel@vger.kernel.org>, <louhongxiang@huawei.com>, Wenchao Hao <haowenchao2@huawei.com> Subject: [PATCH v5 01/10] scsi: scsi_debug: create scsi_debug directory in the debugfs filesystem Date: Fri, 22 Sep 2023 17:28:57 +0800 Message-ID: <20230922092906.2645265-2-haowenchao2@huawei.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20230922092906.2645265-1-haowenchao2@huawei.com> References: <20230922092906.2645265-1-haowenchao2@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.101.6] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemm000012.china.huawei.com (7.193.23.142) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 22 Sep 2023 02:30:08 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777730196631311849 X-GMAIL-MSGID: 1777730196631311849 |
Series |
scsi:scsi_debug: Add error injection for single device
|
|
Commit Message
Wenchao Hao
Sept. 22, 2023, 9:28 a.m. UTC
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> --- drivers/scsi/scsi_debug.c | 6 ++++++ 1 file changed, 6 insertions(+)
Comments
On 2023-09-22 05:28, Wenchao Hao wrote: > 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> > --- > drivers/scsi/scsi_debug.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c > index 9c0af50501f9..35c336271b13 100644 > --- a/drivers/scsi/scsi_debug.c > +++ b/drivers/scsi/scsi_debug.c > @@ -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,8 @@ static int __init scsi_debug_init(void) > goto driver_unreg; > } > > + sdebug_debugfs_root = debugfs_create_dir("scsi_debug", NULL); debugfs_create_dir() can fail and return NULL. Looking at other drivers, most seem to assume it will work. Since the scsi_debug driver is often used to test abnormal situations, perhaps adding something like: if (!sdebug_debugfs_root) pr_info("%s: failed to create initial debugfs directory\n", __func__); might save someone a bit of time if a NULL dereference on sdebug_debugfs_root follows later. That is what the mpt3sas driver does. Doug Gilbert > + > for (k = 0; k < hosts_to_add; k++) { > if (want_store && k == 0) { > ret = sdebug_add_host_helper(idx); > @@ -7057,6 +7062,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);
On 2023/9/28 9:13, Douglas Gilbert wrote: > On 2023-09-22 05:28, Wenchao Hao wrote: >> 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> >> --- >> drivers/scsi/scsi_debug.c | 6 ++++++ >> 1 file changed, 6 insertions(+) >> >> diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c >> index 9c0af50501f9..35c336271b13 100644 >> --- a/drivers/scsi/scsi_debug.c >> +++ b/drivers/scsi/scsi_debug.c >> @@ -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,8 @@ static int __init scsi_debug_init(void) >> goto driver_unreg; >> } >> + sdebug_debugfs_root = debugfs_create_dir("scsi_debug", NULL); > > debugfs_create_dir() can fail and return NULL. Looking at other drivers, most > seem to assume it will work. Since the scsi_debug driver is often used to test > abnormal situations, perhaps adding something like: > if (!sdebug_debugfs_root) > pr_info("%s: failed to create initial debugfs directory\n", __func__); > > might save someone a bit of time if a NULL dereference on sdebug_debugfs_root > follows later. That is what the mpt3sas driver does. > Yes, I would fix it by checking return value of debugfs related call after your review suggestions for other patches. > Doug Gilbert > >> + >> for (k = 0; k < hosts_to_add; k++) { >> if (want_store && k == 0) { >> ret = sdebug_add_host_helper(idx); >> @@ -7057,6 +7062,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); > >
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 9c0af50501f9..35c336271b13 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c @@ -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,8 @@ static int __init scsi_debug_init(void) goto driver_unreg; } + sdebug_debugfs_root = debugfs_create_dir("scsi_debug", NULL); + for (k = 0; k < hosts_to_add; k++) { if (want_store && k == 0) { ret = sdebug_add_host_helper(idx); @@ -7057,6 +7062,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);