[PATCH] scsi: mpt3sas: validate device handle before ata pending flag

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit ffb584565894 ("scsi: mpt3sas: fix hang on ata passthrough
commands") introduced ata_command_pending bit-flag to ensure sending
only one outstanding pass through ATA command to target device.

However if target device become irresponsive with ata_command_pending,
we won't be able to remove it timely, since we try to dispatch a
SYNCHRONIZE_CACHE command and bail out with SAM_STAT_BUSY repeatedly.

Move the invalid device handle checking a bit earlier than the
ata_command_pending.

Signed-off-by: Yuanyuan Zhong <yzhong@xxxxxxxxxxxxxxx>
---
 drivers/scsi/mpt3sas/mpt3sas_scsih.c | 21 ++++++++++-----------
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index b258f21..32fc0d8 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -4758,6 +4758,16 @@ static int _scsih_set_satl_pending(struct scsi_cmnd *scmd, bool pending)
 		return 0;
 	}
 
+	sas_target_priv_data = sas_device_priv_data->sas_target;
+
+	/* invalid device handle */
+	handle = sas_target_priv_data->handle;
+	if (handle == MPT3SAS_INVALID_DEVICE_HANDLE) {
+		scmd->result = DID_NO_CONNECT << 16;
+		scmd->scsi_done(scmd);
+		return 0;
+	}
+
 	/*
 	 * Bug work around for firmware SATL handling.  The loop
 	 * is based on atomic operations and ensures consistency
@@ -4771,17 +4781,6 @@ static int _scsih_set_satl_pending(struct scsi_cmnd *scmd, bool pending)
 		}
 	} while (_scsih_set_satl_pending(scmd, true));
 
-	sas_target_priv_data = sas_device_priv_data->sas_target;
-
-	/* invalid device handle */
-	handle = sas_target_priv_data->handle;
-	if (handle == MPT3SAS_INVALID_DEVICE_HANDLE) {
-		scmd->result = DID_NO_CONNECT << 16;
-		scmd->scsi_done(scmd);
-		return 0;
-	}
-
-
 	/* host recovery or link resets sent via IOCTLs */
 	if (ioc->shost_recovery || ioc->ioc_link_reset_in_progress)
 		return SCSI_MLQUEUE_HOST_BUSY;
-- 
1.9.1




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux