]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
Fix rejected nvme LS Req.
authorJames Smart <jsmart2021@gmail.com>
Fri, 21 Apr 2017 23:04:47 +0000 (16:04 -0700)
committerChristoph Hellwig <hch@lst.de>
Mon, 24 Apr 2017 07:25:48 +0000 (09:25 +0200)
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

index a39d72c2e72158664a202c2ade5400607699c666..cbf3fe3f8637a25ee5d329b1a552544d98a769d8 100644 (file)
@@ -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,