All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nilesh Javali <njavali@marvell.com>
To: <martin.petersen@oracle.com>
Cc: <linux-scsi@vger.kernel.org>, <GR-QLogic-Storage-Upstream@marvell.com>
Subject: [PATCH v2 07/11] qla2xxx: Fix losing target when it reappears during delete
Date: Wed, 15 Jun 2022 22:35:04 -0700	[thread overview]
Message-ID: <20220616053508.27186-8-njavali@marvell.com> (raw)
In-Reply-To: <20220616053508.27186-1-njavali@marvell.com>

From: Arun Easi <aeasi@marvell.com>

FC target disappeared during port perturbation tests
due to a race that tramples target state.
Fix the issue by adding state checks before proceeding.

Fixes: 44c57f205876 ("scsi: qla2xxx: Changes to support FCP2 Target")
Cc: stable@vger.kernel.org
Signed-off-by: Arun Easi <aeasi@marvell.com>
Signed-off-by: Nilesh Javali <njavali@marvell.com>
---
 drivers/scsi/qla2xxx/qla_attr.c | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index 8b87fefda423..feca9e44b21c 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -2714,17 +2714,24 @@ qla2x00_dev_loss_tmo_callbk(struct fc_rport *rport)
 	if (!fcport)
 		return;
 
-	/* Now that the rport has been deleted, set the fcport state to
-	   FCS_DEVICE_DEAD */
-	qla2x00_set_fcport_state(fcport, FCS_DEVICE_DEAD);
+
+	/*
+	 * Now that the rport has been deleted, set the fcport state to
+	 * FCS_DEVICE_DEAD, if the fcport is still lost.
+	 */
+	if (fcport->scan_state != QLA_FCPORT_FOUND)
+		qla2x00_set_fcport_state(fcport, FCS_DEVICE_DEAD);
 
 	/*
 	 * Transport has effectively 'deleted' the rport, clear
 	 * all local references.
 	 */
 	spin_lock_irqsave(host->host_lock, flags);
-	fcport->rport = fcport->drport = NULL;
-	*((fc_port_t **)rport->dd_data) = NULL;
+	/* Confirm port has not reappeared before clearing pointers. */
+	if (rport->port_state != FC_PORTSTATE_ONLINE) {
+		fcport->rport = fcport->drport = NULL;
+		*((fc_port_t **)rport->dd_data) = NULL;
+	}
 	spin_unlock_irqrestore(host->host_lock, flags);
 
 	if (test_bit(ABORT_ISP_ACTIVE, &fcport->vha->dpc_flags))
@@ -2757,9 +2764,12 @@ qla2x00_terminate_rport_io(struct fc_rport *rport)
 	/*
 	 * At this point all fcport's software-states are cleared.  Perform any
 	 * final cleanup of firmware resources (PCBs and XCBs).
+	 *
+	 * Attempt to cleanup only lost devices.
 	 */
 	if (fcport->loop_id != FC_NO_LOOP_ID) {
-		if (IS_FWI2_CAPABLE(fcport->vha->hw)) {
+		if (IS_FWI2_CAPABLE(fcport->vha->hw) &&
+		    fcport->scan_state != QLA_FCPORT_FOUND) {
 			if (fcport->loop_id != FC_NO_LOOP_ID)
 				fcport->logout_on_delete = 1;
 
@@ -2769,7 +2779,7 @@ qla2x00_terminate_rport_io(struct fc_rport *rport)
 				       __LINE__);
 				qlt_schedule_sess_for_deletion(fcport);
 			}
-		} else {
+		} else if (!IS_FWI2_CAPABLE(fcport->vha->hw)) {
 			qla2x00_port_logout(fcport->vha, fcport);
 		}
 	}
-- 
2.19.0.rc0


  parent reply	other threads:[~2022-06-16  5:35 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-16  5:34 [PATCH v2 00/11] qla2xxx bug fixes Nilesh Javali
2022-06-16  5:34 ` [PATCH v2 01/11] qla2xxx: Fix excessive IO error messages by default Nilesh Javali
2022-06-16  5:34 ` [PATCH v2 02/11] qla2xxx: Add a new v2 dport diagnostic feature Nilesh Javali
2022-06-16  5:35 ` [PATCH v2 03/11] qla2xxx: Wind down adapter after pcie error Nilesh Javali
2022-06-16  5:35 ` [PATCH v2 04/11] qla2xxx: Turn off multi-queue for 8G adapter Nilesh Javali
2022-06-16  5:35 ` [PATCH v2 05/11] qla2xxx: Fix crash due to stale srb access around IO timeouts Nilesh Javali
2022-06-16  5:35 ` [PATCH v2 06/11] qla2xxx: Fix losing FCP-2 targets during port perturbation tests Nilesh Javali
2022-06-16  5:35 ` Nilesh Javali [this message]
2022-06-16  5:35 ` [PATCH v2 08/11] qla2xxx: Add debug prints in the device remove path Nilesh Javali
2022-06-16  5:35 ` [PATCH v2 09/11] qla2xxx: Fix losing FCP-2 targets on long port disable with IOs Nilesh Javali
2022-06-16  5:35 ` [PATCH v2 10/11] qla2xxx: Fix erroneous mailbox timeout after pci error inject Nilesh Javali
2022-06-16  5:35 ` [PATCH v2 11/11] qla2xxx: Update version to 10.02.07.700-k Nilesh Javali
2022-06-17  2:00 ` [PATCH v2 00/11] qla2xxx bug fixes Martin K. Petersen
2022-06-22  2:10 ` Martin K. Petersen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220616053508.27186-8-njavali@marvell.com \
    --to=njavali@marvell.com \
    --cc=GR-QLogic-Storage-Upstream@marvell.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.