From patchwork Thu Apr 20 22:04:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Smart X-Patchwork-Id: 9691409 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F1B1C6037F for ; Thu, 20 Apr 2017 22:05:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E4B4625D9E for ; Thu, 20 Apr 2017 22:05:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D98CF2849A; Thu, 20 Apr 2017 22:05:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7CE2228497 for ; Thu, 20 Apr 2017 22:05:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S947807AbdDTWFE (ORCPT ); Thu, 20 Apr 2017 18:05:04 -0400 Received: from mail-oi0-f67.google.com ([209.85.218.67]:34881 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S947788AbdDTWFC (ORCPT ); Thu, 20 Apr 2017 18:05:02 -0400 Received: by mail-oi0-f67.google.com with SMTP id m34so5011836oik.2 for ; Thu, 20 Apr 2017 15:05:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=j54PtRM/K5coxIfxhecTcQrOWHqR/Dgl8bw1tT7SG5E=; b=ckF4mtzA5RDNDEfd2Eu9rLo/6/7IpH6hycScmX9oaY+CK5c2vf44sRcLOAeCKo4FYu De8vrr6KduYu2+pNMy7M1Yo+iPnBso8gTyRIm32VDilQrsvVNdk/ozwMTIvDsfxjyQkX +5wM+X8ZHmGRjLinc1bwurviXgpx316Q6d8C8vHaKWCSWhYRA9oizXVgCxhIQptIb3v2 ElEDbCupuqX+nloLQOLgsmsSkxxvx6cKxI75nJSiklyLj0DJfDePRoiTyWk4yTLXxYW+ d62atJkQHO+HnaSXHnXqI5N2rdvNCFXRigkKEYPjj5DEULIWwogd9Th7ldH5sYnzEl+S eglw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=j54PtRM/K5coxIfxhecTcQrOWHqR/Dgl8bw1tT7SG5E=; b=Cctqg4zdXnYFh5xvrM4LEZoCHqBM9LITHRZ1FjqVtJSplAGN5mw6EMNt7DTyFSszLK iSj6mHpxW1D6pfS4/bLZpDCkeygdsbdmxW4fsBR+CWbI8st9yxMEkpZAIsepLKpoxOcU M95QcmKPlitPErqGPKyUPwxVnF+wOaAOU5jTjt480G6lI0r0fJuTC/wTxoVCqQljE/an pkx3ezGh9vyL0EUidHHWgCLjBbQ4eNvymdCMJq9JKToB8QDCCX8cTCPvbtmkdcmBfE8q QIG6Dn/qCxBALXMBLBtLLO1lUEI93Qefzr1ECHUyKaox1KvkUZhXlOvziYmawuOz3tAx dugQ== X-Gm-Message-State: AN3rC/7lLoOM3cU6V8EAjBEiqqqCisVzGTiZj64jLXS7ScLNyWtS8V1T 1YVVD7pp3H90Rw== X-Received: by 10.157.54.2 with SMTP id w2mr6094928otb.104.1492725901644; Thu, 20 Apr 2017 15:05:01 -0700 (PDT) Received: from localhost.localdomain ([192.19.245.250]) by smtp.gmail.com with ESMTPSA id p6sm3114681otg.28.2017.04.20.15.05.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Apr 2017 15:05:01 -0700 (PDT) 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 , Dick Kennedy , James Smart Subject: ["PATCH-v2" 03/22] Fix rejected nvme LS Req. Date: Thu, 20 Apr 2017 15:04:29 -0700 Message-Id: <20170420220448.27095-4-jsmart2021@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170420220448.27095-1-jsmart2021@gmail.com> References: <20170420220448.27095-1-jsmart2021@gmail.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: James Smart 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 Signed-off-by: James Smart Reviewed-by: Johannes Thumshirn --- 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,