Blob Blame History Raw
From db591bd2d7ca4d0fa3b770972f30646394ccbbe3 Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Wed, 22 Jul 2020 12:51:59 +0200
Subject: [PATCH 2/4] scsi: scsi_dh_alua: return BLK_STS_AGAIN for ALUA transitioning
 state
Git-commit: 268940b80fa4096397fd0a28e6ad807e64120215
Patch-mainline: v5.11-rc1
References: bsc#1165933, bsc#1171000

When the ALUA state indicates transitioning we should not retry the command
immediately, but rather complete the command with BLK_STS_AGAIN to signal
the completion handler that it might be retried.  This allows multipathing
to redirect the command to another path if possible, and avoid stalls
during lengthy transitioning times.

Link: https://lore.kernel.org/r/20200930080256.90964-3-hare@suse.de
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Signed-off-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Acked-by: Martin Wilck <mwilck@suse.com>
---
 drivers/scsi/device_handler/scsi_dh_alua.c |    2 +-
 drivers/scsi/scsi_lib.c                    |    5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -1091,7 +1091,7 @@ static blk_status_t alua_prep_fn(struct
 	case SCSI_ACCESS_STATE_LBA:
 		return BLK_STS_OK;
 	case SCSI_ACCESS_STATE_TRANSITIONING:
-		return BLK_STS_RESOURCE;
+		return BLK_STS_AGAIN;
 	default:
 		req->rq_flags |= RQF_QUIET;
 		return BLK_STS_IOERR;
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -1718,6 +1718,11 @@ out_put_budget:
 		if (scsi_device_blocked(sdev))
 			ret = BLK_STS_DEV_RESOURCE;
 		break;
+	case BLK_STS_AGAIN:
+		scsi_req(req)->result = DID_BUS_BUSY << 16;
+		if (req->rq_flags & RQF_DONTPREP)
+			scsi_mq_uninit_cmd(cmd);
+		break;
 	default:
 		if (unlikely(!scsi_device_online(sdev)))
 			scsi_req(req)->result = DID_NO_CONNECT << 16;