From patchwork Fri Nov 3 22:56:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Smart X-Patchwork-Id: 10041297 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 17F3B60384 for ; Fri, 3 Nov 2017 22:56:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A92B299CE for ; Fri, 3 Nov 2017 22:56:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F3CF6299E1; Fri, 3 Nov 2017 22:56:57 +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 94E8D299CE for ; Fri, 3 Nov 2017 22:56:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756190AbdKCW4y (ORCPT ); Fri, 3 Nov 2017 18:56:54 -0400 Received: from mail-qt0-f194.google.com ([209.85.216.194]:43958 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756147AbdKCW4v (ORCPT ); Fri, 3 Nov 2017 18:56:51 -0400 Received: by mail-qt0-f194.google.com with SMTP id j58so5084448qtj.0 for ; Fri, 03 Nov 2017 15:56:51 -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=XLgemLabAfyw02i+QWeaRr43APDb2q9qNaaViH4l/1I=; b=vB9QKGsCnm9Cu/DAdPTaedHRgSp12lSYxG6zr8YFOjFp/DuYdXQ24IUfcIZ53bSNr4 NZg6IQTDeUJcQ98o0xthNowx9IEi3UA5VRyaOMpoagXb8uIqGz4C5GsX8CpojeZxWriK uHeb5WfM6mXDW+PCC3+mHGw6mAyM4Ex0FXKa6rF6/VmQzgl9OX6Jf6/T7BrJlpZL9fFe 7zd5Ib36sVsyDHuWFb2ySaPi3N7UnLP9eVubEAgnHIDzqoQiokx2dCKzARBrKlrgxh3d hDKCLt0QHB7fEvW7od0Z8qJBxmvEX9b1/3yTftNY/HZC5gDkbJODGZBCpTB66zSn5TJL jtJg== 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=XLgemLabAfyw02i+QWeaRr43APDb2q9qNaaViH4l/1I=; b=CNkWmhZSMQeLEqQHND0X8Bu2QY3XGwDmhJpwDeEOzb/0DhjgkF0thEMh1newYpoaNb XJNY9g6eU4lu2DKU54t1Hj7LaGT23Dymbk6ckD7g4To5VJTuvnQlpb7vXlmnR3gZedWb Xzf6Hv7wGTgz6ZBCvf+PD/rQy8v07CQvirGRRhFhaFOmW52ZRrUlfhLcYwV1aRyFmGsD gYD8f7GsJ9FsI/7xZXknPagDd98HKxPLBCQSus2zKsNMqXqIbk0BYAqMRBVR7FsBMz5l uKEsW0SS5ZXYMgLMru+ywSt/jRHdjibthkiOW/5lwzJ8VdDqfZPpK47lDHimkYTRMeYP qc8A== X-Gm-Message-State: AMCzsaXAVto4VJCToXpHV3RVblHCCqgJpw54QiB+oLueSgmbiuHnCk93 EFwcRiC0ONuKe9sy10FsN8Vn1J+I X-Google-Smtp-Source: ABhQp+S8C5ZajsDcGZj4GXiJ99IMKq4HNJJ8sWn7bML7aLTDFqM5FzVIlsL3mBSnNWA6Jk/mvNdSfA== X-Received: by 10.200.45.178 with SMTP id p47mr12126926qta.263.1509749810539; Fri, 03 Nov 2017 15:56:50 -0700 (PDT) Received: from pallmd1.broadcom.com ([192.19.255.250]) by smtp.gmail.com with ESMTPSA id v21sm4765626qtv.21.2017.11.03.15.56.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 03 Nov 2017 15:56:50 -0700 (PDT) From: James Smart To: linux-scsi@vger.kernel.org Cc: James Smart , Dick Kennedy , James Smart Subject: [PATCH 14/17] lpfc: Fix crash during driver unload with running nvme traffic Date: Fri, 3 Nov 2017 15:56:25 -0700 Message-Id: <20171103225628.24716-15-jsmart2021@gmail.com> X-Mailer: git-send-email 2.13.1 In-Reply-To: <20171103225628.24716-1-jsmart2021@gmail.com> References: <20171103225628.24716-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 When the driver is unloading, the nvme transport could be in the process of submitting new requests, will send abort requests to terminate associations, or may make LS-related requests. The driver's abort and request entry points currently is ignorant of the unloading state and is starting the requests even though the infrastructure to complete them continues to teardown. Change the entry points for new requests to check whether unloading and if so, reject the requests. Abort routines check unloading, and if so, noop the request. An abort is noop'd as the teardown paths are already aborting/terminating the io outstanding at the time the teardown initiated. Signed-off-by: Dick Kennedy Signed-off-by: James Smart --- drivers/scsi/lpfc/lpfc_nvme.c | 14 ++++++++++++++ drivers/scsi/lpfc/lpfc_nvmet.c | 11 +++++++++++ 2 files changed, 25 insertions(+) diff --git a/drivers/scsi/lpfc/lpfc_nvme.c b/drivers/scsi/lpfc/lpfc_nvme.c index 12d09a6a4563..ea7a0e65bbfd 100644 --- a/drivers/scsi/lpfc/lpfc_nvme.c +++ b/drivers/scsi/lpfc/lpfc_nvme.c @@ -423,6 +423,9 @@ lpfc_nvme_ls_req(struct nvme_fc_local_port *pnvme_lport, if (vport->load_flag & FC_UNLOADING) return -ENODEV; + if (vport->load_flag & FC_UNLOADING) + return -ENODEV; + ndlp = lpfc_findnode_did(vport, pnvme_rport->port_id); if (!ndlp || !NLP_CHK_NODE_ACT(ndlp)) { lpfc_printf_vlog(vport, KERN_ERR, LOG_NODE | LOG_NVME_IOERR, @@ -538,6 +541,9 @@ lpfc_nvme_ls_abort(struct nvme_fc_local_port *pnvme_lport, vport = lport->vport; phba = vport->phba; + if (vport->load_flag & FC_UNLOADING) + return; + ndlp = lpfc_findnode_did(vport, pnvme_rport->port_id); if (!ndlp) { lpfc_printf_vlog(vport, KERN_ERR, LOG_NVME_ABTS, @@ -1273,6 +1279,11 @@ lpfc_nvme_fcp_io_submit(struct nvme_fc_local_port *pnvme_lport, goto out_fail; } + if (vport->load_flag & FC_UNLOADING) { + ret = -ENODEV; + goto out_fail; + } + /* Validate pointers. */ if (!pnvme_lport || !pnvme_rport || !freqpriv) { lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_IOERR | LOG_NODE, @@ -1500,6 +1511,9 @@ lpfc_nvme_fcp_abort(struct nvme_fc_local_port *pnvme_lport, vport = lport->vport; phba = vport->phba; + if (vport->load_flag & FC_UNLOADING) + return; + /* Announce entry to new IO submit field. */ lpfc_printf_vlog(vport, KERN_INFO, LOG_NVME_ABTS, "6002 Abort Request to rport DID x%06x " diff --git a/drivers/scsi/lpfc/lpfc_nvmet.c b/drivers/scsi/lpfc/lpfc_nvmet.c index 84cf1b9079f7..2b50aecc2722 100644 --- a/drivers/scsi/lpfc/lpfc_nvmet.c +++ b/drivers/scsi/lpfc/lpfc_nvmet.c @@ -635,6 +635,9 @@ lpfc_nvmet_xmt_ls_rsp(struct nvmet_fc_target_port *tgtport, if (phba->pport->load_flag & FC_UNLOADING) return -ENODEV; + if (phba->pport->load_flag & FC_UNLOADING) + return -ENODEV; + lpfc_printf_log(phba, KERN_INFO, LOG_NVME_DISC, "6023 NVMET LS rsp oxid x%x\n", ctxp->oxid); @@ -721,6 +724,11 @@ lpfc_nvmet_xmt_fcp_op(struct nvmet_fc_target_port *tgtport, goto aerr; } + if (phba->pport->load_flag & FC_UNLOADING) { + rc = -ENODEV; + goto aerr; + } + #ifdef CONFIG_SCSI_LPFC_DEBUG_FS if (ctxp->ts_cmd_nvme) { if (rsp->op == NVMET_FCOP_RSP) @@ -823,6 +831,9 @@ lpfc_nvmet_xmt_fcp_abort(struct nvmet_fc_target_port *tgtport, if (phba->pport->load_flag & FC_UNLOADING) return; + if (phba->pport->load_flag & FC_UNLOADING) + return; + lpfc_printf_log(phba, KERN_INFO, LOG_NVME_ABTS, "6103 NVMET Abort op: oxri x%x flg x%x ste %d\n", ctxp->oxid, ctxp->flag, ctxp->state);