mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wenchao Hao <haowenchao2@huawei.com>
To: "Martin K . Petersen" <martin.petersen@oracle.com>,
	Douglas Gilbert <dgilbert@interlog.com>
Cc: "James E . J . Bottomley" <jejb@linux.ibm.com>,
	<linux-scsi@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<louhongxiang@huawei.com>, Wenchao Hao <haowenchao2@huawei.com>
Subject: [PATCH v6 10/10] scsi: scsi_debug: Add param to control sdev's allow_restart
Date: Tue, 10 Oct 2023 17:20:51 +0800	[thread overview]
Message-ID: <20231010092051.608007-11-haowenchao2@huawei.com> (raw)
In-Reply-To: <20231010092051.608007-1-haowenchao2@huawei.com>

Add new module param "allow_restart" to control if setup scsi_device's
allow_restart flag, this flag determines if trigger EH after command
finished with sense_key 0x6, asc 0x4 and ascq 0x2, EH would be triggered
if allow_restart=1 in this condition.

The new param can be used with error inject added in patch6 to test how
commands finished with sense_key 0x6, asc 0x4 and ascq 0x2 are handled.

Signed-off-by: Wenchao Hao <haowenchao2@huawei.com>
Tested-by: Douglas Gilbert <dgilbert@interlog.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 2743eb36c58e..67922e2c4c19 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -843,6 +843,7 @@ static bool have_dif_prot;
 static bool write_since_sync;
 static bool sdebug_statistics = DEF_STATISTICS;
 static bool sdebug_wp;
+static bool sdebug_allow_restart;
 /* Following enum: 0: no zbc, def; 1: host aware; 2: host managed */
 static enum blk_zoned_model sdeb_zbc_model = BLK_ZONED_NONE;
 static char *sdeb_zbc_model_s;
@@ -5478,6 +5479,9 @@ static int scsi_debug_slave_configure(struct scsi_device *sdp)
 		sdp->no_uld_attach = 1;
 	config_cdb_len(sdp);
 
+	if (sdebug_allow_restart)
+		sdp->allow_restart = 1;
+
 	devip->debugfs_entry = debugfs_create_dir(dev_name(&sdp->sdev_dev),
 				sdebug_debugfs_root);
 	if (IS_ERR_OR_NULL(devip->debugfs_entry))
@@ -6202,6 +6206,7 @@ module_param_named(zone_cap_mb, sdeb_zbc_zone_cap_mb, int, S_IRUGO);
 module_param_named(zone_max_open, sdeb_zbc_max_open, int, S_IRUGO);
 module_param_named(zone_nr_conv, sdeb_zbc_nr_conv, int, S_IRUGO);
 module_param_named(zone_size_mb, sdeb_zbc_zone_size_mb, int, S_IRUGO);
+module_param_named(allow_restart, sdebug_allow_restart, bool, S_IRUGO | S_IWUSR);
 
 MODULE_AUTHOR("Eric Youngdale + Douglas Gilbert");
 MODULE_DESCRIPTION("SCSI debug adapter driver");
@@ -6274,6 +6279,7 @@ MODULE_PARM_DESC(zone_cap_mb, "Zone capacity in MiB (def=zone size)");
 MODULE_PARM_DESC(zone_max_open, "Maximum number of open zones; [0] for no limit (def=auto)");
 MODULE_PARM_DESC(zone_nr_conv, "Number of conventional zones (def=1)");
 MODULE_PARM_DESC(zone_size_mb, "Zone size in MiB (def=auto)");
+MODULE_PARM_DESC(allow_restart, "Set scsi_device's allow_restart flag(def=0)");
 
 #define SDEBUG_INFO_LEN 256
 static char sdebug_info[SDEBUG_INFO_LEN];
-- 
2.32.0


  parent reply	other threads:[~2023-10-10  9:22 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-10  9:20 [PATCH v6 00/10] scsi:scsi_debug: Add error injection for single device Wenchao Hao
2023-10-10  9:20 ` [PATCH v6 01/10] scsi: scsi_debug: create scsi_debug directory in the debugfs filesystem Wenchao Hao
2023-10-10  9:20 ` [PATCH v6 02/10] scsi: scsi_debug: Add interface to manage single device's error inject Wenchao Hao
2023-10-10  9:20 ` [PATCH v6 03/10] scsi: scsi_debug: Define grammar to remove added error injection Wenchao Hao
2023-10-10  9:20 ` [PATCH v6 04/10] scsi: scsi_debug: timeout command if the error is injected Wenchao Hao
2023-10-10  9:20 ` [PATCH v6 05/10] scsi: scsi_debug: Return failed value " Wenchao Hao
2023-10-10  9:20 ` [PATCH v6 06/10] scsi: scsi_debug: set command's result and sense data " Wenchao Hao
2023-10-10  9:20 ` [PATCH v6 07/10] scsi: scsi_debug: Add new error injection abort failed Wenchao Hao
2023-10-10  9:20 ` [PATCH v6 08/10] scsi: scsi_debug: Add new error injection reset lun failed Wenchao Hao
2023-10-10  9:20 ` [PATCH v6 09/10] scsi: scsi_debug: Add debugfs interface to fail target reset Wenchao Hao
2023-10-10  9:20 ` Wenchao Hao [this message]
2023-10-16  2:09 ` [PATCH v6 00/10] scsi:scsi_debug: Add error injection for single device Wenchao Hao
2023-10-17  0:53 ` Martin K. Petersen
2023-10-25  2:19 ` Martin K. Petersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231010092051.608007-11-haowenchao2@huawei.com \
    --to=haowenchao2@huawei.com \
    --cc=dgilbert@interlog.com \
    --cc=jejb@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=louhongxiang@huawei.com \
    --cc=martin.petersen@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®