Skip to contentSkip to conversation

scsi: scsi_transport_srp: don't block target in failfast state

PATCH Applied [email protected] 3 participants 3 messages Jan 11, 2021 – Jan 13, 2021 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: scsi_transport_srp: don't block target in failfast state

From: Martin Wilck <[email protected]>

If the port is in SRP_RPORT_FAIL_FAST state when srp_reconnect_rport() is entered, a transition to SDEV_BLOCK would be illegal, and a kernel WARNING would be triggered. Skip scsi_target_block() in this case.

---
 drivers/scsi/scsi_transport_srp.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/scsi/scsi_transport_srp.c +8 -1
index cba1cf6a1c12..1e939a2a387f 100644
@@ -541,7 +541,14 @@ int srp_reconnect_rport(struct srp_rport *rport)
 	res = mutex_lock_interruptible(&rport->mutex);
 	if (res)
 		goto out;
-	scsi_target_block(&shost->shost_gendev);
+	if (rport->state != SRP_RPORT_FAIL_FAST)
+		/*
+		 * sdev state must be SDEV_TRANSPORT_OFFLINE, transition
+		 * to SDEV_BLOCK is illegal. Calling scsi_target_unblock()
+		 * later is ok though, scsi_internal_device_unblock_nowait()
+		 * treats SDEV_TRANSPORT_OFFLINE like SDEV_BLOCK.
+		 */
+		scsi_target_block(&shost->shost_gendev);
 	res = rport->state != SRP_RPORT_LOST ? i->f->reconnect(rport) : -ENODEV;
 	pr_debug("%s (state %d): transport.reconnect() returned %d\n",
 		 dev_name(&shost->shost_gendev), rport->state, res);
Signature · 1 line
2.29.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 21 lines · On 1/11/21 6:25 AM, [email protected] wrote:

From: Martin Wilck <[email protected]>

If the port is in SRP_RPORT_FAIL_FAST state when srp_reconnect_rport() is entered, a transition to SDEV_BLOCK would be illegal, and a kernel WARNING would be triggered. Skip scsi_target_block() in this case.

---
 drivers/scsi/scsi_transport_srp.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/scsi/scsi_transport_srp.c +1 -1
index cba1cf6a1c12..1e939a2a387f 100644
@@ -541,7 +541,14 @@ int srp_reconnect_rport(struct srp_rport *rport)
 	res = mutex_lock_interruptible(&rport->mutex);
 	if (res)
 		goto out;
-	scsi_target_block(&shost->shost_gendev);
+	if (rport->state != SRP_RPORT_FAIL_FAST)

drivers/scsi/scsi_transport_srp.c int srp_reconnect_rport(struct srp_rport *rport) · line 554

Quoted 10 lines
drivers/scsi/scsi_transport_srp.c +7 -0
+		/*
+		 * sdev state must be SDEV_TRANSPORT_OFFLINE, transition
+		 * to SDEV_BLOCK is illegal. Calling scsi_target_unblock()
+		 * later is ok though, scsi_internal_device_unblock_nowait()
+		 * treats SDEV_TRANSPORT_OFFLINE like SDEV_BLOCK.
+		 */
+		scsi_target_block(&shost->shost_gendev);
 	res = rport->state != SRP_RPORT_LOST ? i->f->reconnect(rport) : -ENODEV;
 	pr_debug("%s (state %d): transport.reconnect() returned %d\n",
 		 dev_name(&shost->shost_gendev), rport->state, res);
#2 lore raw
In reply to [email protected]
Quoted 3 lines · On Mon, 11 Jan 2021 15:25:41 +0100, [email protected] wrote:

If the port is in SRP_RPORT_FAIL_FAST state when srp_reconnect_rport() is entered, a transition to SDEV_BLOCK would be illegal, and a kernel WARNING would be triggered. Skip scsi_target_block() in this case.

Applied to 5.11/scsi-fixes, thanks!

[1/1] scsi: scsi_transport_srp: don't block target in failfast state

      https://git.kernel.org/mkp/scsi/c/72eeb7c71513
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering