[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230723234422.1629194-4-haowenchao2@huawei.com>
Date: Mon, 24 Jul 2023 07:44:12 +0800
From: Wenchao Hao <haowenchao2@...wei.com>
To: "James E . J . Bottomley" <jejb@...ux.ibm.com>,
"Martin K . Petersen" <martin.petersen@...cle.com>,
Hannes Reinecke <hare@...e.de>, <linux-scsi@...r.kernel.org>,
<linux-kernel@...r.kernel.org>
CC: Dan Carpenter <error27@...il.com>, <louhongxiang@...wei.com>,
Wenchao Hao <haowenchao2@...wei.com>
Subject: [PATCH 03/13] scsi:scsi_error: Check if to do reset in scsi_try_xxx_reset
This is preparation for a genernal LUN/target based error handle
strategy, the strategy would reuse some origin error handler APIs,
but some steps of these function should not be performed. For
example, we should not perform target reset if we just stop IOs
on one single LUN.
This change add checks in scsi_try_xxx_reset to make sure
the reset operations would not be performed only if the condition
is not satisfied.
Signed-off-by: Wenchao Hao <haowenchao2@...wei.com>
---
drivers/scsi/scsi_error.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 879fdd7c165b..d80492366527 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -930,6 +930,9 @@ static enum scsi_disposition scsi_try_host_reset(struct scsi_cmnd *scmd)
struct Scsi_Host *host = scmd->device->host;
const struct scsi_host_template *hostt = host->hostt;
+ if (!scsi_host_in_recovery(host))
+ return FAILED;
+
SCSI_LOG_ERROR_RECOVERY(3,
shost_printk(KERN_INFO, host, "Snd Host RST\n"));
@@ -960,6 +963,9 @@ static enum scsi_disposition scsi_try_bus_reset(struct scsi_cmnd *scmd)
struct Scsi_Host *host = scmd->device->host;
const struct scsi_host_template *hostt = host->hostt;
+ if (!scsi_host_in_recovery(host))
+ return FAILED;
+
SCSI_LOG_ERROR_RECOVERY(3, scmd_printk(KERN_INFO, scmd,
"%s: Snd Bus RST\n", __func__));
@@ -1001,6 +1007,10 @@ static enum scsi_disposition scsi_try_target_reset(struct scsi_cmnd *scmd)
enum scsi_disposition rtn;
struct Scsi_Host *host = scmd->device->host;
const struct scsi_host_template *hostt = host->hostt;
+ struct scsi_target *starget = scsi_target(scmd->device);
+
+ if (!(scsi_target_in_recovery(starget) || scsi_host_in_recovery(host)))
+ return FAILED;
if (!hostt->eh_target_reset_handler)
return FAILED;
@@ -1008,7 +1018,7 @@ static enum scsi_disposition scsi_try_target_reset(struct scsi_cmnd *scmd)
rtn = hostt->eh_target_reset_handler(scmd);
if (rtn == SUCCESS) {
spin_lock_irqsave(host->host_lock, flags);
- __starget_for_each_device(scsi_target(scmd->device), NULL,
+ __starget_for_each_device(starget, NULL,
__scsi_report_device_reset);
spin_unlock_irqrestore(host->host_lock, flags);
}
--
2.35.3
Powered by blists - more mailing lists