[RFC PATCH v3 19/19] scsi: iscsi_tcp: Add param to control LUN based error handle
From: JiangJianJun
Date: Thu Mar 13 2025 - 21:13:03 EST
From: Wenchao Hao <haowenchao2@xxxxxxxxxx>
Add new param lun_eh to control if enable LUN based error handler,
since iscsi_tcp defined callback eh_target_reset, so make it
fallback to further recover when LUN based recovery can not recover
all error commands.
Signed-off-by: Wenchao Hao <haowenchao2@xxxxxxxxxx>
---
drivers/scsi/iscsi_tcp.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c
index e81f60985193..6212d88a4259 100644
--- a/drivers/scsi/iscsi_tcp.c
+++ b/drivers/scsi/iscsi_tcp.c
@@ -35,6 +35,7 @@
#include <scsi/scsi_host.h>
#include <scsi/scsi.h>
#include <scsi/scsi_transport_iscsi.h>
+#include <scsi/scsi_eh.h>
#include <trace/events/iscsi.h>
#include <trace/events/sock.h>
@@ -63,6 +64,10 @@ module_param_named(debug_iscsi_tcp, iscsi_sw_tcp_dbg, int,
MODULE_PARM_DESC(debug_iscsi_tcp, "Turn on debugging for iscsi_tcp module "
"Set to 1 to turn on, and zero to turn off. Default is off.");
+static bool iscsi_sw_tcp_lun_eh;
+module_param_named(lun_eh, iscsi_sw_tcp_lun_eh, bool, 0444);
+MODULE_PARM_DESC(lun_eh, "LUN based error handle (def=0)");
+
#define ISCSI_SW_TCP_DBG(_conn, dbg_fmt, arg...) \
do { \
if (iscsi_sw_tcp_dbg) \
@@ -1069,6 +1074,19 @@ static int iscsi_sw_tcp_sdev_configure(struct scsi_device *sdev,
return 0;
}
+static int iscsi_sw_tcp_sdev_alloc(struct scsi_device *sdev)
+{
+ if (iscsi_sw_tcp_lun_eh)
+ return scsi_device_setup_eh(sdev, 1);
+ return 0;
+}
+
+static void iscsi_sw_tcp_sdev_destroy(struct scsi_device *sdev)
+{
+ if (iscsi_sw_tcp_lun_eh)
+ return scsi_device_clear_eh(sdev);
+}
+
static const struct scsi_host_template iscsi_sw_tcp_sht = {
.module = THIS_MODULE,
.name = "iSCSI Initiator over TCP/IP",
@@ -1084,6 +1102,8 @@ static const struct scsi_host_template iscsi_sw_tcp_sht = {
.eh_target_reset_handler = iscsi_eh_recover_target,
.dma_boundary = PAGE_SIZE - 1,
.sdev_configure = iscsi_sw_tcp_sdev_configure,
+ .sdev_init = iscsi_sw_tcp_sdev_alloc,
+ .sdev_destroy = iscsi_sw_tcp_sdev_destroy,
.proc_name = "iscsi_tcp",
.this_id = -1,
.track_queue_depth = 1,
--
2.33.0