diff mbox series

scsi: vmw_pvscsi: Return DID_RESET for status SAM_STAT_COMMAND_TERMINATED

Message ID 20180802211329.GA18666@petr-dev3.eng.vmware.com (mailing list archive)
State Accepted
Headers show
Series scsi: vmw_pvscsi: Return DID_RESET for status SAM_STAT_COMMAND_TERMINATED | expand

Commit Message

Jim Gill Aug. 2, 2018, 9:13 p.m. UTC
Commands that are reset are returned with status SAM_STAT_COMMAND_TERMINATED. PVSCSI currently
returns DID_OK | SAM_STAT_COMMAND_TERMINATED which fails the command. Instead, set hostbyte to
DID_RESET to allow upper layers to retry.

Tested by copying a large file between two pvscsi disks on same adapter while performing a bus
reset at 1-second intervals. Before fix, commands sometimes fail with DID_OK. After fix, commands
observed to fail with DID_RESET.

Signed-off-by: Jim Gill <jgill@vmware.com>
---
 drivers/scsi/vmw_pvscsi.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

Comments

Martin K. Petersen Aug. 3, 2018, 5:57 p.m. UTC | #1
Jim,

> Commands that are reset are returned with status
> SAM_STAT_COMMAND_TERMINATED. PVSCSI currently returns DID_OK |
> SAM_STAT_COMMAND_TERMINATED which fails the command. Instead, set
> hostbyte to DID_RESET to allow upper layers to retry.

Applied to 4.18/scsi-fixes, thank you!
diff mbox series

Patch

diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c
index 777e5f1..0cd947f 100644
--- a/drivers/scsi/vmw_pvscsi.c
+++ b/drivers/scsi/vmw_pvscsi.c
@@ -561,9 +561,14 @@  static void pvscsi_complete_request(struct pvscsi_adapter *adapter,
 	    (btstat == BTSTAT_SUCCESS ||
 	     btstat == BTSTAT_LINKED_COMMAND_COMPLETED ||
 	     btstat == BTSTAT_LINKED_COMMAND_COMPLETED_WITH_FLAG)) {
-		cmd->result = (DID_OK << 16) | sdstat;
-		if (sdstat == SAM_STAT_CHECK_CONDITION && cmd->sense_buffer)
-			cmd->result |= (DRIVER_SENSE << 24);
+		if (sdstat == SAM_STAT_COMMAND_TERMINATED) {
+			cmd->result = (DID_RESET << 16);
+		} else {
+			cmd->result = (DID_OK << 16) | sdstat;
+			if (sdstat == SAM_STAT_CHECK_CONDITION &&
+			    cmd->sense_buffer)
+				cmd->result |= (DRIVER_SENSE << 24);
+		}
 	} else
 		switch (btstat) {
 		case BTSTAT_SUCCESS: