From patchwork Wed Oct 16 14:15:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11193423 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 382D815AB for ; Wed, 16 Oct 2019 14:17:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 18DB921928 for ; Wed, 16 Oct 2019 14:17:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GM5TrleV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392279AbfJPOR6 (ORCPT ); Wed, 16 Oct 2019 10:17:58 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:45306 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730937AbfJPOR6 (ORCPT ); Wed, 16 Oct 2019 10:17:58 -0400 Received: by mail-qt1-f193.google.com with SMTP id c21so36264992qtj.12 for ; Wed, 16 Oct 2019 07:17:57 -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:mime-version :content-transfer-encoding; bh=muyrwKCkKeapXczyZQbXCsQey1nBdQol/tef0UdG3SI=; b=GM5TrleVwG9yaVD6iv+CS/z0xrNsp6+EmNZUcfcs7pyIzYnoe5MCyLcFIB7EPdyl89 vVo2lZ4siRmS2ALccwmEZWtZ30iIJi9HgTRGMBgOj8caUgSBiMVAxgbHvHAxaTA+qgWn IdV9ev5VFjPGaiGcUU3E3CQ9YRNTamU7hkokIdUo7N06XJzoBQxWZjz2v6UtoTIpEVOV +v+BOgK9IJ/8OSWb4uOhyNzBsTRbpKDRzUShJ4bXGzTEUnhaCrInpGQ/3szoIWB+q2s1 Rgbpfd/02/w9ArhEFRojrLxSBdvEp+t2/WqCNRqLeUc2/9HT6GOZEkYPGc9rY19OWo1L QS6Q== 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:mime-version :content-transfer-encoding; bh=muyrwKCkKeapXczyZQbXCsQey1nBdQol/tef0UdG3SI=; b=kzEHad8JFsttrcszvx+lV3JrbR9FNUKf52TnYQsslI0c4jvCOcAKWcz9A4g5SWiOXe NwEsxH8q/H+kl9npW26ZC6LqZ/chQz/vgHz4g+X/AwkqbEOt3Vebl07S7CSBth1g3XjG J9ZtT7C1ja+uel6MhHvXFhGtAlXSCuc1Pmi6IhdvNkTVYDJU0vK8B58X/nN0LLRTrJuV OJ9pT1///nbX5C9OVy/th+k1LStf/JqBaRuNwEHa81H/Wb7c+Q5HLNFumHmSRcrOpQdl 3RrF9LOlndpthbq1pM8tfOYibFn8T6ufAJGAH8xjYbJ5ZNNf7k9fQzdSZZngN5n7L4ZI pRWg== X-Gm-Message-State: APjAAAUjvnF6VNWWTdrYXM9PuyQGiJAvFFHFtmGar9qsLsoy7rGzyfzY m3HtihvFtny+3b8W4tUfCi0qPhY= X-Google-Smtp-Source: APXvYqwYmnLzikNE6Lv0RunAhR3vjALRoakiYvgVeGAk7t9RtZuyxYzldfbA8yNTcflyZRuWKOmHVw== X-Received: by 2002:a05:6214:841:: with SMTP id dg1mr41838943qvb.55.1571235476441; Wed, 16 Oct 2019 07:17:56 -0700 (PDT) Received: from localhost.localdomain ([66.187.232.65]) by smtp.gmail.com with ESMTPSA id g31sm14925361qte.78.2019.10.16.07.17.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2019 07:17:55 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Cc: Neil Brown , Chuck Lever , Anna Schumaker , "J. Bruce Fields" Subject: [PATCH 1/3] SUNRPC: The TCP back channel mustn't disappear while requests are outstanding Date: Wed, 16 Oct 2019 10:15:44 -0400 Message-Id: <20191016141546.32277-1-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org If there are TCP back channel requests either being processed by the server threads, then we should hold a reference to the transport to ensure it doesn't get freed from underneath us. Reported-by: Neil Brown Fixes: 2ea24497a1b3 ("SUNRPC: RPC callbacks may be split across several..") Signed-off-by: Trond Myklebust --- net/sunrpc/backchannel_rqst.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/sunrpc/backchannel_rqst.c b/net/sunrpc/backchannel_rqst.c index 339e8c077c2d..7eb251372f94 100644 --- a/net/sunrpc/backchannel_rqst.c +++ b/net/sunrpc/backchannel_rqst.c @@ -307,8 +307,8 @@ void xprt_free_bc_rqst(struct rpc_rqst *req) */ dprintk("RPC: Last session removed req=%p\n", req); xprt_free_allocation(req); - return; } + xprt_put(xprt); } /* @@ -339,7 +339,7 @@ struct rpc_rqst *xprt_lookup_bc_request(struct rpc_xprt *xprt, __be32 xid) spin_unlock(&xprt->bc_pa_lock); if (new) { if (req != new) - xprt_free_bc_rqst(new); + xprt_free_allocation(new); break; } else if (req) break; @@ -368,6 +368,7 @@ void xprt_complete_bc_request(struct rpc_rqst *req, uint32_t copied) set_bit(RPC_BC_PA_IN_USE, &req->rq_bc_pa_state); dprintk("RPC: add callback request to list\n"); + xprt_get(xprt); spin_lock(&bc_serv->sv_cb_lock); list_add(&req->rq_bc_list, &bc_serv->sv_cb_list); wake_up(&bc_serv->sv_cb_waitq); From patchwork Wed Oct 16 14:15:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11193425 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4BAA915AB for ; Wed, 16 Oct 2019 14:18:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2BA1E218DE for ; Wed, 16 Oct 2019 14:18:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Xtk6Olq4" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392276AbfJPOR7 (ORCPT ); Wed, 16 Oct 2019 10:17:59 -0400 Received: from mail-qk1-f195.google.com ([209.85.222.195]:37105 "EHLO mail-qk1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730937AbfJPOR7 (ORCPT ); Wed, 16 Oct 2019 10:17:59 -0400 Received: by mail-qk1-f195.google.com with SMTP id u184so22902633qkd.4 for ; Wed, 16 Oct 2019 07:17:59 -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 :mime-version:content-transfer-encoding; bh=HDETNY7WK9PJBRVGF2Wq3OyOQEyyC9mkVXUUeP9/L9o=; b=Xtk6Olq4TjBdfm8dEJi0Ty3kIAg1risZ49Iw/vG1qGLuHM8jWEA9Pc75UbUQoH3w1E pYaB0YOG4Sa7f22PzA3NPBryD/ZvEReJ2kz5F2LA5K2nu2dqhAPh5kChNyn6LC+/dRzJ yBTrDM+LBhjS8cma4d6A80qeL2BUMpFL1Rj9tPKBSZqFA9hCPGmvYa0D/OghQStz7yqc 4oNJWf+8iAamcx/zgthhB123FZrpFC/TK/zrx1GqqSKNsfqVkHZN9+N2kGEgbVKOsxfk RQeMxEXh46T5Mrym52ov8Q5kQ8LfyB/NHd8n93qUJDLfxExSUs268R+0g0V823RFICIU NXGQ== 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:mime-version:content-transfer-encoding; bh=HDETNY7WK9PJBRVGF2Wq3OyOQEyyC9mkVXUUeP9/L9o=; b=VM7xmBTNRkrrRCTPXmePyvjtpSf0UyHRZ+x/hFifREHR8OjdgZFVbtvItMXrCZloVq 7YlSZpwWvJd/ha6BVaOLAvXq1LsbJTm+l0zhOYNtE8UsO2RzdQEc6/ilCo70bZq65fzj s8ubCB5GOUuQWrGm8yx6tMNmBrM0guK2UAJEForAmPD2gevxnf22CydbyJjdkAlrD0wt unBwczgtk2Td9Vu6vrt1LidrcknwJSxFwfe8myosHoyJAszrGaJ8WbcObrllIS84gRsS otjTj2lINWMbypu9j0ashXay0+a7YD2ZNlxJOP6pU+w0FZQchXKDB7mneYTpoZ8JEx8U bWbA== X-Gm-Message-State: APjAAAUDzI333hYX8Blduv3BpvIBcANYy2X0s8TZjKBSccgC+OyOtBh1 J0AZdqa6lpRWFaW5YwOJFGL3aGg= X-Google-Smtp-Source: APXvYqw0Je+fp6MT1VQL90vkyOeK/ulUL48b365qxVR2HKQS8Il4v/vwPOb0e3qCuk4U3xGydLztyw== X-Received: by 2002:a37:9904:: with SMTP id b4mr39869163qke.499.1571235477996; Wed, 16 Oct 2019 07:17:57 -0700 (PDT) Received: from localhost.localdomain ([66.187.232.65]) by smtp.gmail.com with ESMTPSA id g31sm14925361qte.78.2019.10.16.07.17.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2019 07:17:57 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Cc: Neil Brown , Chuck Lever , Anna Schumaker , "J. Bruce Fields" Subject: [PATCH 2/3] SUNRPC: The RDMA back channel mustn't disappear while requests are outstanding Date: Wed, 16 Oct 2019 10:15:45 -0400 Message-Id: <20191016141546.32277-2-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191016141546.32277-1-trond.myklebust@hammerspace.com> References: <20191016141546.32277-1-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org If there are RDMA back channel requests either being processed by the server threads, then we should hold a reference to the transport to ensure it doesn't get freed from underneath us. Reported-by: Neil Brown Fixes: 63cae47005af ("xprtrdma: Handle incoming backward direction RPC calls") Signed-off-by: Trond Myklebust --- net/sunrpc/xprtrdma/backchannel.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/sunrpc/xprtrdma/backchannel.c b/net/sunrpc/xprtrdma/backchannel.c index 50e075fcdd8f..b458bf53ca69 100644 --- a/net/sunrpc/xprtrdma/backchannel.c +++ b/net/sunrpc/xprtrdma/backchannel.c @@ -163,6 +163,7 @@ void xprt_rdma_bc_free_rqst(struct rpc_rqst *rqst) spin_lock(&xprt->bc_pa_lock); list_add_tail(&rqst->rq_bc_pa_list, &xprt->bc_pa_list); spin_unlock(&xprt->bc_pa_lock); + xprt_put(xprt); } static struct rpc_rqst *rpcrdma_bc_rqst_get(struct rpcrdma_xprt *r_xprt) @@ -259,6 +260,7 @@ void rpcrdma_bc_receive_call(struct rpcrdma_xprt *r_xprt, /* Queue rqst for ULP's callback service */ bc_serv = xprt->bc_serv; + xprt_get(xprt); spin_lock(&bc_serv->sv_cb_lock); list_add(&rqst->rq_bc_list, &bc_serv->sv_cb_list); spin_unlock(&bc_serv->sv_cb_lock); From patchwork Wed Oct 16 14:15:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11193427 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 530FE1668 for ; Wed, 16 Oct 2019 14:18:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3534321925 for ; Wed, 16 Oct 2019 14:18:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ozqy19Y1" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392913AbfJPOSA (ORCPT ); Wed, 16 Oct 2019 10:18:00 -0400 Received: from mail-qt1-f196.google.com ([209.85.160.196]:42627 "EHLO mail-qt1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730937AbfJPOSA (ORCPT ); Wed, 16 Oct 2019 10:18:00 -0400 Received: by mail-qt1-f196.google.com with SMTP id w14so36285634qto.9 for ; Wed, 16 Oct 2019 07:18:00 -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 :mime-version:content-transfer-encoding; bh=BdHrLxCp9g5Df1l1kF4KftxpClGxEjwux4GL0qZITMk=; b=Ozqy19Y1fdooxczI7Ku9sZKiDiw2Tzo09xfUi5VqAmCwCQnE1yloC5Ff6O6xeoQElh ePPycxWevBZl0/wV+5rDz4mEjHwKUcWyaYjeYAXvb5sIFnzSj3X/IykJT3bR61MxLxYY D8v4klDksNRvbW9uY8mV25Rcpkl9iIB+zXL/gD2787Ot+yqcHIo21FKUcUZBLl9iy10P WTJbdX2pWMLGXXKTLMysuScMa1Pdbf+yprRlhSKFUaLrkgwYYdtzBKZ1BHpDrwrC/GFG WwY0I4qmIkotff02z94zPb/lgT0S617pkIsXDL/qWjoNhxf3Z35O8q2556IV8gV59FgA //gg== 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:mime-version:content-transfer-encoding; bh=BdHrLxCp9g5Df1l1kF4KftxpClGxEjwux4GL0qZITMk=; b=IXKC8pq8t+E+0FFVRPuU+bCBzG+dobvudKSdxnci7PUBUpDpZq7OgmCfP8VVJcxXBY fdS5Ng2oX3CgjrPCKGef+54l2J5Z8aZequXpgoF0XNdc5fuZ0C0s5OEexe1JAElXPbvB J1bUNd3SnGjE5UAfLtCJ0N8nlQW3hofpnalcO5+Cx4/4R7oZ+gOXst90b5rlz+NO/MwN aeFYB5vG/7GEPz7xEXE2wOtTqxBST8DTtxHfWVkaMhyolHGLjOSePkO/tQGkr6QRX91D c6JFq+DJqRem5euABwQpcAz/8tLLeVJO36iZLf6S/LE8ffSUiiJW7/kV8gCkvaNTq/PH jHTg== X-Gm-Message-State: APjAAAVDou80TXnWCnt9UHJ/KsF6c3c6in2Z6RtAK1g5PuoNSWzZ8k/v 3smh2yjxHe+2inCAFQt6G8/25I0= X-Google-Smtp-Source: APXvYqyKypfgGjFD7lV/bQMomAMjOCD7lYuyBQVbRtt19DnB/sriw3dDTDsKT+h4VxsVSDDK4UhAhg== X-Received: by 2002:ac8:6ed9:: with SMTP id f25mr7129373qtv.207.1571235479387; Wed, 16 Oct 2019 07:17:59 -0700 (PDT) Received: from localhost.localdomain ([66.187.232.65]) by smtp.gmail.com with ESMTPSA id g31sm14925361qte.78.2019.10.16.07.17.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2019 07:17:58 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Cc: Neil Brown , Chuck Lever , Anna Schumaker , "J. Bruce Fields" Subject: [PATCH 3/3] SUNRPC: Destroy the back channel when we destroy the host transport Date: Wed, 16 Oct 2019 10:15:46 -0400 Message-Id: <20191016141546.32277-3-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191016141546.32277-2-trond.myklebust@hammerspace.com> References: <20191016141546.32277-1-trond.myklebust@hammerspace.com> <20191016141546.32277-2-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org When we're destroying the host transport mechanism, we should ensure that we do not leak memory by failing to release any back channel slots that might still exist. Reported-by: Neil Brown Signed-off-by: Trond Myklebust --- net/sunrpc/xprt.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index 8a45b3ccc313..41df4c507193 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c @@ -1942,6 +1942,11 @@ static void xprt_destroy_cb(struct work_struct *work) rpc_destroy_wait_queue(&xprt->sending); rpc_destroy_wait_queue(&xprt->backlog); kfree(xprt->servername); + /* + * Destroy any existing back channel + */ + xprt_destroy_backchannel(xprt, UINT_MAX); + /* * Tear down transport state and free the rpc_xprt */