public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: jsmart2021@gmail.com
To: linux-scsi@vger.kernel.org, linux-nvme@lists.infradead.org,
	sagi@grimberg.me, martin.petersen@oracle.com
Cc: James Smart <jsmart2021@gmail.com>,
	Dick Kennedy <dick.kennedy@broadcom.com>,
	James Smart <james.smart@broadcom.com>
Subject: [PATCH v3 03/22] Fix rejected nvme LS Req.
Date: Fri, 21 Apr 2017 16:04:47 -0700	[thread overview]
Message-ID: <20170421230506.925-4-jsmart2021@gmail.com> (raw)
In-Reply-To: <20170421230506.925-1-jsmart2021@gmail.com>

From: James Smart <jsmart2021@gmail.com>

In this case, the NVME initiator is sending an LS REQ command on an NDLP
that is not MAPPED.  The FW rejects it.

The lpfc_nvme_ls_req routine checks for a NULL ndlp pointer
but does not check the NDLP state.  This allows the routine
to send an LS IO when the ndlp is disconnected.

Check the ndlp for NULL, actual node, Target and MAPPED
or Initiator and UNMAPPED. This avoids Fabric nodes getting
the Create Association or Create Connection commands.  Initiators
are free to Reject either Create.
Also some of the messages numbers in lpfc_nvme_ls_req were changed because
they were already used in other log messages.

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 | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/lpfc/lpfc_nvme.c b/drivers/scsi/lpfc/lpfc_nvme.c
index a39d72c..cbf3fe3 100644
--- a/drivers/scsi/lpfc/lpfc_nvme.c
+++ b/drivers/scsi/lpfc/lpfc_nvme.c
@@ -401,6 +401,7 @@ lpfc_nvme_ls_req(struct nvme_fc_local_port *pnvme_lport,
 	struct lpfc_nodelist *ndlp;
 	struct ulp_bde64 *bpl;
 	struct lpfc_dmabuf *bmp;
+	uint16_t ntype, nstate;
 
 	/* there are two dma buf in the request, actually there is one and
 	 * the second one is just the start address + cmd size.
@@ -417,11 +418,26 @@ lpfc_nvme_ls_req(struct nvme_fc_local_port *pnvme_lport,
 	vport = lport->vport;
 
 	ndlp = lpfc_findnode_did(vport, pnvme_rport->port_id);
-	if (!ndlp) {
-		lpfc_printf_vlog(vport, KERN_ERR, LOG_NVME_DISC,
-				 "6043 Could not find node for DID %x\n",
+	if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) {
+		lpfc_printf_vlog(vport, KERN_ERR, LOG_NODE | LOG_NVME_IOERR,
+				 "6051 DID x%06x not an active rport.\n",
 				 pnvme_rport->port_id);
-		return 1;
+		return -ENODEV;
+	}
+
+	/* The remote node has to be a mapped nvme target or an
+	 * unmapped nvme initiator or it's an error.
+	 */
+	ntype = ndlp->nlp_type;
+	nstate = ndlp->nlp_state;
+	if ((ntype & NLP_NVME_TARGET && nstate != NLP_STE_MAPPED_NODE) ||
+	    (ntype & NLP_NVME_INITIATOR && nstate != NLP_STE_UNMAPPED_NODE)) {
+		lpfc_printf_vlog(vport, KERN_ERR, LOG_NODE | LOG_NVME_IOERR,
+				 "6088 DID x%06x not ready for "
+				 "IO. State x%x, Type x%x\n",
+				 pnvme_rport->port_id,
+				 ndlp->nlp_state, ndlp->nlp_type);
+		return -ENODEV;
 	}
 	bmp = kmalloc(sizeof(struct lpfc_dmabuf), GFP_KERNEL);
 	if (!bmp) {
@@ -456,7 +472,7 @@ lpfc_nvme_ls_req(struct nvme_fc_local_port *pnvme_lport,
 
 	/* Expand print to include key fields. */
 	lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_DISC,
-			 "6051 ENTER.  lport %p, rport %p lsreq%p rqstlen:%d "
+			 "6149 ENTER.  lport %p, rport %p lsreq%p rqstlen:%d "
 			 "rsplen:%d %pad %pad\n",
 			 pnvme_lport, pnvme_rport,
 			 pnvme_lsreq, pnvme_lsreq->rqstlen,
-- 
2.9.3

  parent reply	other threads:[~2017-04-21 23:05 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-21 23:04 [PATCH v3 00/22] lpfc updates for 11.2.0.12 jsmart2021
2017-04-21 23:04 ` [PATCH v3 01/22] Standardize nvme SGL segment count jsmart2021
2017-04-21 23:04 ` [PATCH v3 02/22] Fix nvme unregister port timeout jsmart2021
2017-04-21 23:04 ` jsmart2021 [this message]
2017-04-21 23:04 ` [PATCH v3 04/22] Fix log message in completion path jsmart2021
2017-04-21 23:04 ` [PATCH v3 05/22] Add debug messages for nvme/fcp resource allocation jsmart2021
2017-04-21 23:04 ` [PATCH v3 06/22] Fix spelling in comments jsmart2021
2017-04-21 23:04 ` [PATCH v3 07/22] Remove unused defines for NVME PostBuf jsmart2021
2017-04-21 23:04 ` [PATCH v3 08/22] Remove NULL ptr check before kfree jsmart2021
2017-04-21 23:04 ` [PATCH v3 09/22] Fix extra line print in rqpair debug print jsmart2021
2017-04-21 23:04 ` [PATCH v3 10/22] Fix PRLI ACC rsp for NVME jsmart2021
2017-04-21 23:04 ` [PATCH v3 11/22] Fix driver unload/reload operation jsmart2021
2017-04-21 23:04 ` [PATCH v3 12/22] Fix driver usage of 128B WQEs when WQ_CREATE is V1 jsmart2021
2017-04-21 23:04 ` [PATCH v3 13/22] Fix nvme initiator handling when not enabled jsmart2021
2017-04-21 23:04 ` [PATCH v3 14/22] Remove hba lock from NVMET issue WQE jsmart2021
2017-04-21 23:04 ` [PATCH v3 15/22] Fix driver load issues when MRQ=8 jsmart2021
2017-04-21 23:05 ` [PATCH v3 16/22] Fix crash after issuing lip reset jsmart2021
2017-04-21 23:05 ` [PATCH v3 17/22] Fix max_sgl_segments settings for NVME / NVMET jsmart2021
2017-04-21 23:05 ` [PATCH v3 18/22] Add Fabric assigned WWN support jsmart2021
2017-04-21 23:05 ` [PATCH v3 19/22] Fix implicit logo and RSCN handling for NVMET jsmart2021
2017-04-21 23:05 ` [PATCH v3 20/22] Update ABORT processing " jsmart2021
2017-04-21 23:05 ` [PATCH v3 21/22] Fix Express lane queue creation jsmart2021
2017-04-21 23:05 ` [PATCH v3 22/22] lpfc revison 11.2.0.12 jsmart2021
2017-04-24  7:26 ` [PATCH v3 00/22] lpfc updates for 11.2.0.12 Christoph Hellwig

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=20170421230506.925-4-jsmart2021@gmail.com \
    --to=jsmart2021@gmail.com \
    --cc=dick.kennedy@broadcom.com \
    --cc=james.smart@broadcom.com \
    --cc=linux-nvme@lists.infradead.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=sagi@grimberg.me \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox