All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Smart <jsmart2021@gmail.com>
To: linux-scsi@vger.kernel.org
Cc: Dick Kennedy <dick.kennedy@broadcom.com>,
	James Smart <james.smart@broadcom.com>
Subject: [PATCH v2 04/21] lpfc: Fix lpfc nvme host rejecting IO with Not Ready message
Date: Fri, 29 Sep 2017 17:34:30 -0700	[thread overview]
Message-ID: <20170930003447.10747-5-jsmart2021@gmail.com> (raw)
In-Reply-To: <20170930003447.10747-1-jsmart2021@gmail.com>

From: Dick Kennedy <dick.kennedy@broadcom.com>

In a link bounce scenario, a condition can occur where the
discovery engine swaps an ndlp structure (address changbe for
an nport). While the swap was successfully executed by the
discovery engine, the driver did not properly detect a change in
the ndlp bound to the nvme rport.  This error resulted in the nvme
host transport issuing an IO to the correct nvme rport, but the
lpfc driver addressed a ndlp with an NLP_UNUSED status and failed
the io. This resulting it it looking like there were missing
namespaces and applications failed due to io errors.

To fix, in lpfc_nvme_register_rport, rework the "rebind" case
to break the nvme rport<->ndlp association when the ndlp
already has an nrport. Then rebind the rport to the correct
ndlp data and backpointers.

Signed-off-by: Dick Kennedy <dick.kennedy@broadcom.com>
Signed-off-by: James Smart <james.smart@broadcom.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
---
 drivers/scsi/lpfc/lpfc_nvme.c | 46 ++++++++++++++++++++++++++-----------------
 1 file changed, 28 insertions(+), 18 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_nvme.c b/drivers/scsi/lpfc/lpfc_nvme.c
index 79ba3ce063a4..2ad23b356bfe 100644
--- a/drivers/scsi/lpfc/lpfc_nvme.c
+++ b/drivers/scsi/lpfc/lpfc_nvme.c
@@ -2296,6 +2296,7 @@ lpfc_nvme_register_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
 	struct lpfc_nvme_rport *rport;
 	struct nvme_fc_remote_port *remote_port;
 	struct nvme_fc_port_info rpinfo;
+	struct lpfc_nodelist *prev_ndlp;
 
 	lpfc_printf_vlog(ndlp->vport, KERN_INFO, LOG_NVME_DISC,
 			 "6006 Register NVME PORT. DID x%06x nlptype x%x\n",
@@ -2332,7 +2333,7 @@ lpfc_nvme_register_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
 		 * new rport.
 		 */
 		rport = remote_port->private;
-		if (ndlp->nrport == rport) {
+		if (ndlp->nrport) {
 			lpfc_printf_vlog(ndlp->vport, KERN_INFO,
 					 LOG_NVME_DISC,
 					 "6014 Rebinding lport to "
@@ -2343,24 +2344,33 @@ lpfc_nvme_register_port(struct lpfc_vport *vport, struct lpfc_nodelist *ndlp)
 					 remote_port->port_role,
 					 ndlp->nlp_type,
 					 ndlp->nlp_DID);
-		} else {
-			/* New rport. */
-			rport->remoteport = remote_port;
-			rport->lport = lport;
-			rport->ndlp = lpfc_nlp_get(ndlp);
-			if (!rport->ndlp)
-				return -1;
-			ndlp->nrport = rport;
-			lpfc_printf_vlog(vport, KERN_INFO,
-					 LOG_NVME_DISC | LOG_NODE,
-					 "6022 Binding new rport to "
-					 "lport %p Rport WWNN 0x%llx, "
-					 "Rport WWPN 0x%llx DID "
-					 "x%06x Role x%x\n",
-					 lport,
-					 rpinfo.node_name, rpinfo.port_name,
-					 rpinfo.port_id, rpinfo.port_role);
+			prev_ndlp = rport->ndlp;
+
+			/* Sever the ndlp<->rport connection before dropping
+			 * the ndlp ref from register.
+			 */
+			ndlp->nrport = NULL;
+			rport->ndlp = NULL;
+			if (prev_ndlp)
+				lpfc_nlp_put(ndlp);
 		}
+
+		/* Clean bind the rport to the ndlp. */
+		rport->remoteport = remote_port;
+		rport->lport = lport;
+		rport->ndlp = lpfc_nlp_get(ndlp);
+		if (!rport->ndlp)
+			return -1;
+		ndlp->nrport = rport;
+		lpfc_printf_vlog(vport, KERN_INFO,
+				 LOG_NVME_DISC | LOG_NODE,
+				 "6022 Binding new rport to "
+				 "lport %p Rport WWNN 0x%llx, "
+				 "Rport WWPN 0x%llx DID "
+				 "x%06x Role x%x\n",
+				 lport,
+				 rpinfo.node_name, rpinfo.port_name,
+				 rpinfo.port_id, rpinfo.port_role);
 	} else {
 		lpfc_printf_vlog(vport, KERN_ERR,
 				 LOG_NVME_DISC | LOG_NODE,
-- 
2.13.1

  parent reply	other threads:[~2017-09-30  0:34 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-30  0:34 [PATCH v2 00/21] lpfc updates for 11.4.0.4 James Smart
2017-09-30  0:34 ` [PATCH v2 01/21] lpfc: fix pci hot plug crash in timer management routines James Smart
2017-10-02  8:05   ` Johannes Thumshirn
2017-09-30  0:34 ` [PATCH v2 02/21] lpfc: fix pci hot plug crash in list_add call James Smart
2017-10-02  8:06   ` Johannes Thumshirn
2017-09-30  0:34 ` [PATCH v2 03/21] lpfc: Fix crash receiving ELS while detaching driver James Smart
2017-09-30  0:34 ` James Smart [this message]
2017-09-30  0:34 ` [PATCH v2 05/21] lpfc: Fix warning messages when NVME_TARGET_FC not defined James Smart
2017-09-30  0:34 ` [PATCH v2 06/21] lpfc: PLOGI failures during NPIV testing James Smart
2017-09-30  0:34 ` [PATCH v2 07/21] lpfc: Make ktime sampling more accurate James Smart
2017-10-02  8:08   ` Johannes Thumshirn
2017-09-30  0:34 ` [PATCH v2 08/21] lpfc: Move CQ processing to a soft IRQ James Smart
2017-09-30  0:34 ` [PATCH v2 09/21] lpfc: Fix FCP hba_wqidx assignment James Smart
2017-10-02  8:14   ` Johannes Thumshirn
2017-09-30  0:34 ` [PATCH v2 10/21] lpfc: Reduce log spew on controller reconnects James Smart
2017-09-30  0:34 ` [PATCH v2 11/21] lpfc: Set missing abort context James Smart
2017-09-30  0:34 ` [PATCH v2 12/21] lpfc: Revise NVME module parameter descriptions for better clarity James Smart
2017-09-30  0:34 ` [PATCH v2 13/21] lpfc: Fix oops if nvmet_fc_register_targetport fails James Smart
2017-09-30  0:34 ` [PATCH v2 14/21] lpfc: Disable NPIV support if NVME is enabled James Smart
2017-09-30  0:34 ` [PATCH v2 15/21] lpfc: Fix crash in lpfc_nvme_fcp_io_submit during LIP James Smart
2017-09-30  0:34 ` [PATCH v2 16/21] lpfc: Fix secure firmware updates James Smart
2017-09-30  0:34 ` [PATCH v2 17/21] lpfc: Ensure io aborts interlocked with the target James Smart
2017-09-30  0:34 ` [PATCH v2 18/21] lpfc: Extend RDP support James Smart
2017-09-30  0:34 ` [PATCH v2 19/21] lpfc: Fix oops of nvme host during driver unload James Smart
2017-10-02  8:28   ` Johannes Thumshirn
2017-09-30  0:34 ` [PATCH v2 20/21] lpfc: correct nvme sg segment count check James Smart
2017-10-02  8:33   ` Johannes Thumshirn
2017-09-30  0:34 ` [PATCH v2 21/21] lpfc: change version to 11.4.0.4 James Smart
2017-10-03  2:45 ` [PATCH v2 00/21] lpfc updates for 11.4.0.4 Martin K. Petersen
2017-10-03 18:13   ` James Smart

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=20170930003447.10747-5-jsmart2021@gmail.com \
    --to=jsmart2021@gmail.com \
    --cc=dick.kennedy@broadcom.com \
    --cc=james.smart@broadcom.com \
    --cc=linux-scsi@vger.kernel.org \
    /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.