[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250816112417.3581253-13-jiangjianjun3@huawei.com>
Date: Sat, 16 Aug 2025 19:24:15 +0800
From: JiangJianJun <jiangjianjun3@...wei.com>
To: <James.Bottomley@...senPartnership.com>, <martin.petersen@...cle.com>,
<linux-scsi@...r.kernel.org>
CC: <linux-kernel@...r.kernel.org>, <hare@...e.de>, <bvanassche@....org>,
<michael.christie@...cle.com>, <hch@...radead.org>, <haowenchao22@...il.com>,
<john.g.garry@...cle.com>, <hewenliang4@...wei.com>, <yangyun50@...wei.com>,
<wuyifeng10@...wei.com>, <wubo40@...wei.com>, <yangxingui@...artners.com>
Subject: [PATCH 12/14] scsi: scsi_debug: Add params for configuring the error handler
From: JiangJianJun <jiangjianjun3@...artners.com>
Add a new module parameter to configure error handlers based on
LUN/targets and toggle the enable/disable fallback functionality.
Signed-off-by: JiangJianJun <jiangjianjun3@...artners.com>
---
drivers/scsi/scsi_debug.c | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 0847767d4d43..64d5b85d961b 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -961,6 +961,10 @@ static bool write_since_sync;
static bool sdebug_statistics = DEF_STATISTICS;
static bool sdebug_wp;
static bool sdebug_allow_restart;
+static bool sdebug_lun_eh;
+static bool sdebug_lun_eh_fallback;
+static bool sdebug_target_eh;
+static bool sdebug_target_eh_fallback;
static enum {
BLK_ZONED_NONE = 0,
BLK_ZONED_HA = 1,
@@ -7362,6 +7366,10 @@ 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_param_named(lun_eh, sdebug_lun_eh, bool, 0444);
+module_param_named(lun_eh_fallback, sdebug_lun_eh_fallback, bool, 0444);
+module_param_named(target_eh, sdebug_target_eh, bool, 0444);
+module_param_named(target_eh_fallback, sdebug_target_eh_fallback, bool, 0444);
MODULE_AUTHOR("Eric Youngdale + Douglas Gilbert");
MODULE_DESCRIPTION("SCSI debug adapter driver");
@@ -7441,6 +7449,10 @@ MODULE_PARM_DESC(zone_max_open, "Maximum number of open zones; [0] for no limit
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)");
+MODULE_PARM_DESC(lun_eh, "LUN based error handle (def=0)");
+MODULE_PARM_DESC(lun_eh_fallback, "Fallback to further recovery if LUN recovery failed (def=0)");
+MODULE_PARM_DESC(target_eh, "target based error handle (def=0)");
+MODULE_PARM_DESC(target_eh_fallback, "Fallback to further recovery if target recovery failed (def=0)");
#define SDEBUG_INFO_LEN 256
static char sdebug_info[SDEBUG_INFO_LEN];
@@ -8427,6 +8439,7 @@ static struct attribute *sdebug_drv_attrs[] = {
ATTRIBUTE_GROUPS(sdebug_drv);
static struct device *pseudo_primary;
+static struct scsi_host_template sdebug_driver_template;
static int __init scsi_debug_init(void)
{
@@ -8435,6 +8448,17 @@ static int __init scsi_debug_init(void)
int k, ret, hosts_to_add;
int idx = -1;
+ if (sdebug_lun_eh) {
+ sdebug_driver_template.sdev_setup_eh = scsi_device_setup_eh;
+ sdebug_driver_template.sdev_clear_eh = scsi_device_clear_eh;
+ sdebug_driver_template.sdev_eh_fallback = sdebug_lun_eh_fallback;
+ }
+ if (sdebug_target_eh) {
+ sdebug_driver_template.target_setup_eh = scsi_target_setup_eh;
+ sdebug_driver_template.target_clear_eh = scsi_target_clear_eh;
+ sdebug_driver_template.target_eh_fallback = sdebug_target_eh_fallback;
+ }
+
if (sdebug_ndelay >= 1000 * 1000 * 1000) {
pr_warn("ndelay must be less than 1 second, ignored\n");
sdebug_ndelay = 0;
@@ -9412,7 +9436,7 @@ static int sdebug_init_cmd_priv(struct Scsi_Host *shost, struct scsi_cmnd *cmd)
return 0;
}
-static const struct scsi_host_template sdebug_driver_template = {
+static struct scsi_host_template sdebug_driver_template = {
.show_info = scsi_debug_show_info,
.write_info = scsi_debug_write_info,
.proc_name = sdebug_proc_name,
--
2.33.0
Powered by blists - more mailing lists