Received: by 10.192.165.148 with SMTP id m20csp2530120imm; Sun, 22 Apr 2018 08:58:42 -0700 (PDT) X-Google-Smtp-Source: AIpwx487SzbZmyNpQ7d7lsaj9qYGw5Gyx/6vvC9pEjb8MQQBCA3rEeRvq9RBkK5oEaHtMlBvAdtB X-Received: by 2002:a17:902:4301:: with SMTP id i1-v6mr9997489pld.280.1524412721984; Sun, 22 Apr 2018 08:58:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524412721; cv=none; d=google.com; s=arc-20160816; b=lcV2QfIBIeTA572DYBEIc2PUuerqpTBMQSS+f+pN4VAPwLQAJpkMDqiKsK194knqpw 5t/eM1E43B3bs7UPfH+DGe2y9HHqnOCHwVn9DJ91OsFaqem9GLmWRfgee1U1lMHAcCjN m+oDgpl0Lg8PUvwowZ119B7KdHyJSr/d3uaMZ6Zfe1Cy0Aer+gQhg3B9/RFk/1/GK0Xm LUin/Mbe2sccnhNoPTECuGVx0S1MWcX0FAAnPkjO02jv/1c48VlP3qhOLiZIck34ZzR5 hiMSX46aKdihgUpAkD3rSGjkvW8wnNm0m2hGzwYK3nnn22NUdfFX2DedtLAJCYPMBElm OXBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Xmay377TEhvHfoFIryt0iBpwOn0jyUVetd9sXnvbeqI=; b=a10Y0Jk63Wd8mdLZEz0hUO1sNPVHTd61l4SfJxJjADV8Hii8KcaUmzYsNP0146JoYo 2mIOejmyy7rr5H6AVRHg3WXI8DwYtss9u8EibSr+/A4HPV8nGFo9vemCHFDNrFZC9C8V e9ORb+Yrf/drYcEHaMyZC+BbtS4OOBKRO18cZU3LfZbWIUMLq3wjaCEVU91Bjc8chn0T 3ILNr5m7HEU9jlSHEewXdOTqUo0NaLScUbnhzfK9lWlIbcL0MLxXZNfEiXoOirON0zbr RZkCTm7BdTdxdFwtGgi0ns5Yj9mGSopVvJtrqiufBEUrTkHOT70H2/7Zix8PTUuB39qM lJ4w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x10si8939848pfm.18.2018.04.22.08.58.28; Sun, 22 Apr 2018 08:58:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754320AbeDVN7V (ORCPT + 99 others); Sun, 22 Apr 2018 09:59:21 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:46560 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754266AbeDVN7I (ORCPT ); Sun, 22 Apr 2018 09:59:08 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id A080BCF2; Sun, 22 Apr 2018 13:59:07 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michal Kalderon , Chuck Lever , Anna Schumaker Subject: [PATCH 4.16 107/196] xprtrdma: Fix corner cases when handling device removal Date: Sun, 22 Apr 2018 15:52:07 +0200 Message-Id: <20180422135109.778367773@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180422135104.278511750@linuxfoundation.org> References: <20180422135104.278511750@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.16-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chuck Lever commit 25524288631fc5b7d33259fca1e0dc38146be5d6 upstream. Michal Kalderon has found some corner cases around device unload with active NFS mounts that I didn't have the imagination to test when xprtrdma device removal was added last year. - The ULP device removal handler is responsible for deallocating the PD. That wasn't clear to me initially, and my own testing suggested it was not necessary, but that is incorrect. - The transport destruction path can no longer assume that there is a valid ID. - When destroying a transport, ensure that ib_free_cq() is not invoked on a CQ that was already released. Reported-by: Michal Kalderon Fixes: bebd031866ca ("xprtrdma: Support unplugging an HCA from ...") Signed-off-by: Chuck Lever Cc: stable@vger.kernel.org # v4.12+ Signed-off-by: Anna Schumaker Signed-off-by: Greg Kroah-Hartman --- net/sunrpc/xprtrdma/verbs.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) --- a/net/sunrpc/xprtrdma/verbs.c +++ b/net/sunrpc/xprtrdma/verbs.c @@ -250,7 +250,6 @@ rpcrdma_conn_upcall(struct rdma_cm_id *i wait_for_completion(&ia->ri_remove_done); ia->ri_id = NULL; - ia->ri_pd = NULL; ia->ri_device = NULL; /* Return 1 to ensure the core destroys the id. */ return 1; @@ -445,7 +444,9 @@ rpcrdma_ia_remove(struct rpcrdma_ia *ia) ia->ri_id->qp = NULL; } ib_free_cq(ep->rep_attr.recv_cq); + ep->rep_attr.recv_cq = NULL; ib_free_cq(ep->rep_attr.send_cq); + ep->rep_attr.send_cq = NULL; /* The ULP is responsible for ensuring all DMA * mappings and MRs are gone. @@ -458,6 +459,8 @@ rpcrdma_ia_remove(struct rpcrdma_ia *ia) rpcrdma_dma_unmap_regbuf(req->rl_recvbuf); } rpcrdma_mrs_destroy(buf); + ib_dealloc_pd(ia->ri_pd); + ia->ri_pd = NULL; /* Allow waiters to continue */ complete(&ia->ri_remove_done); @@ -628,14 +631,16 @@ rpcrdma_ep_destroy(struct rpcrdma_ep *ep { cancel_delayed_work_sync(&ep->rep_connect_worker); - if (ia->ri_id->qp) { + if (ia->ri_id && ia->ri_id->qp) { rpcrdma_ep_disconnect(ep, ia); rdma_destroy_qp(ia->ri_id); ia->ri_id->qp = NULL; } - ib_free_cq(ep->rep_attr.recv_cq); - ib_free_cq(ep->rep_attr.send_cq); + if (ep->rep_attr.recv_cq) + ib_free_cq(ep->rep_attr.recv_cq); + if (ep->rep_attr.send_cq) + ib_free_cq(ep->rep_attr.send_cq); } /* Re-establish a connection after a device removal event.