From patchwork Thu Oct 17 13:02:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11195841 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 3E30115AB for ; Thu, 17 Oct 2019 13:05:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1D4A02089C for ; Thu, 17 Oct 2019 13:05:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZVYnWn46" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390851AbfJQNFw (ORCPT ); Thu, 17 Oct 2019 09:05:52 -0400 Received: from mail-qk1-f194.google.com ([209.85.222.194]:39269 "EHLO mail-qk1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726898AbfJQNFw (ORCPT ); Thu, 17 Oct 2019 09:05:52 -0400 Received: by mail-qk1-f194.google.com with SMTP id 4so1762077qki.6 for ; Thu, 17 Oct 2019 06:05:52 -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=6BJ8UZmgpM+F3+lerDf1X37Zaq/sfSN3TB0kwtETXD4=; b=ZVYnWn4668stuOWg1A+AxWo2Hh+h0UpL+nyMyty9C+66/WJA7JBFAAng4ACfQRmNAo HGSXz2iVJMW1Q3nPlsuLljZECZTFVB3f+FX9md4/WRnFYsvFG+TMb0rdLXwSA/dLJx4o ZIgXxA4fHebJ0TqyEbHaiXExk6cOVsBdym4FLnyj+EBb745rSCj2jZcf9Z0lc/M8xmoc ZanA0Xr+ANhYO8ST5Kqp6wby4Yi3UoZ5+xqt+oVqK85M7bspA8IG+Svx7l/nO8xujiKr Usah0z47eSl+DMOcxTwbpr7K7CnwbBAYaxjzaO/5ThkjekE8yhc3xiMdr0kjwSYTtkxf /cVw== 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=6BJ8UZmgpM+F3+lerDf1X37Zaq/sfSN3TB0kwtETXD4=; b=YRq11n0kCt7uz4HUnZh9BY4P1wzlC6j6/8P/i0/ryPSFTKsPgREpOGENdLd/M3GN+4 VRU4J9K/UcW1IOdHKMSslg5gDRKTQ/9F+CY/TznKe9OgsGEUWumNM2JlmLZ+/4FCSbnR 4jKr3Gk6J8v4xXWC71ERujvr1OBRBXLeoqPLsV2IC7Hx1XnMRTcmOBg8T1I8e9TwOJxI glKioFGSdaoBzGBJ3q8F6x6ONUVzP+0i9vU79b19bJ9U6jQBLnTPk8WXg9i73hb94ExC gBq8IbrNQKQKWtrO+a+pSYnX6gFDiYaU42iJWWENX6wfX7CrQfVC/GbkhtXCLw2PqQUB KJlw== X-Gm-Message-State: APjAAAUtjRnOXuNXp8xQOsx3RZ6DzYL5tr7LIzgiTXsUI2MXITjjSnyy DH6yvZHcDuqZui8L9G0uwsNO3VE= X-Google-Smtp-Source: APXvYqyKp9OMJaLljXzlitz66+QyqnDeqdz0NzzUEcM4hxLOPAmVzzWrl5EExnerC3B6UZ0aKALSLw== X-Received: by 2002:a37:507:: with SMTP id 7mr3193100qkf.107.1571317550957; Thu, 17 Oct 2019 06:05:50 -0700 (PDT) Received: from localhost.localdomain ([66.187.232.65]) by smtp.gmail.com with ESMTPSA id g194sm1326648qke.46.2019.10.17.06.05.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:05:49 -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 v2 1/3] SUNRPC: The TCP back channel mustn't disappear while requests are outstanding Date: Thu, 17 Oct 2019 09:02:19 -0400 Message-Id: <20191017130221.7924-2-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191017130221.7924-1-trond.myklebust@hammerspace.com> References: <20191017130221.7924-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 TCP back channel requests 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 Thu Oct 17 13:02:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11195845 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 1E4EE912 for ; Thu, 17 Oct 2019 13:05:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F0F5C20640 for ; Thu, 17 Oct 2019 13:05:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nGV+SDNs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394098AbfJQNFy (ORCPT ); Thu, 17 Oct 2019 09:05:54 -0400 Received: from mail-qk1-f196.google.com ([209.85.222.196]:39275 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390908AbfJQNFx (ORCPT ); Thu, 17 Oct 2019 09:05:53 -0400 Received: by mail-qk1-f196.google.com with SMTP id 4so1762149qki.6 for ; Thu, 17 Oct 2019 06:05:53 -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=f4CXZMOsoJLn43utTVJO4GHlgyGENzJaiSYFpXxAT8U=; b=nGV+SDNs6c7kqY5bYEYi1+P1IM+QIeYMu8M7yIFHipJ4ndTStOYuOmDOSeU75VgJG0 OA25zNEXJHHpQj6AYfRANB8Qy4OMuBoUbGYpahEKR4BZPOnv7WkfAf1BSRAedWWCyskj jTEWL6qLep64ZMtZOtZB37bRvl4f5naabBPfS+Of2cvzyVunmDM+OD+lIte9nL3YHjtg Jd0asTydgEwF+tAw373lt1IkxQId/3YbrMlN7BFuhen+MeabQFq2wmbt4t1D1pJ4sS+A xCRxHdK0CQOebDTL+kcYCM4RjUQ+jTIFNPxqPO2aZ1dgQwCIseQ2HxYg6TEyymbTssVG sRiA== 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=f4CXZMOsoJLn43utTVJO4GHlgyGENzJaiSYFpXxAT8U=; b=mxfCFkEDggeSVu8g5Z6qG2ujlGUBL9AR9yZBovoa5Q1Evpk4SUIgkpXqOyv0mDzOeT GjLwpDTxVNZHRuJZdai09ATM8ZUJZ7HepgpJalqS3ULV6/bapUdJg6ZVcBWcjjdru6wP Wy9TWO0/1EJYaHnuZ0yZh5blYzxfzsCElZ+IQ2aUkCZcDV0Ll6VFkWljDwN/KKU29V/I qA/169p9WgCQ5swHFnOhYDFOgMqCwEzqimIlyS2efCad+4kMU/kjLl1gIkSmUR4DcG7S VT+Cce6w2vdf++bq+sKK6IbVEYsjvD8TyOWml7XzRGJAG8aiz+aImwOuvqbZgbIglZXt 8UrQ== X-Gm-Message-State: APjAAAWqv8ooLmI5sXJ3eUzEEzjXC6RM3nvmfdy0bQWz8p5m9PEpnRxq xfFQQZ16Nga0O3JMpwIndDu40cw= X-Google-Smtp-Source: APXvYqxDRGHaksQ7+L/7M3KkJAz03XoN845IWvOwmf/0VrMR6pWDcGdn1DsemF3z1/nIl+cbGIybZA== X-Received: by 2002:a05:620a:b07:: with SMTP id t7mr3079994qkg.382.1571317552337; Thu, 17 Oct 2019 06:05:52 -0700 (PDT) Received: from localhost.localdomain ([66.187.232.65]) by smtp.gmail.com with ESMTPSA id g194sm1326648qke.46.2019.10.17.06.05.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:05:51 -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 v2 2/3] SUNRPC: The RDMA back channel mustn't disappear while requests are outstanding Date: Thu, 17 Oct 2019 09:02:20 -0400 Message-Id: <20191017130221.7924-3-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191017130221.7924-2-trond.myklebust@hammerspace.com> References: <20191017130221.7924-1-trond.myklebust@hammerspace.com> <20191017130221.7924-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 If there are RDMA back channel requests 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 Thu Oct 17 13:02:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11195847 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 D12FB15AB for ; Thu, 17 Oct 2019 13:05:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B03CD2089C for ; Thu, 17 Oct 2019 13:05:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="c07EppAX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394182AbfJQNF4 (ORCPT ); Thu, 17 Oct 2019 09:05:56 -0400 Received: from mail-qk1-f196.google.com ([209.85.222.196]:36509 "EHLO mail-qk1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726898AbfJQNFz (ORCPT ); Thu, 17 Oct 2019 09:05:55 -0400 Received: by mail-qk1-f196.google.com with SMTP id y189so1778156qkc.3 for ; Thu, 17 Oct 2019 06:05:54 -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=0Hbi0LxoIEjtB80FxOJFZ9KyTGmSEe2iec6SZ8Suep4=; b=c07EppAXnzhpBgw0Dr/JCbeF/MWxeEEYJjiOXY+k5aS8Ydq1DTHxD8lolvUksPD/pW 4VRQ3QEm1FWrfTCI3hgRjpxzJlvjvjAmgna2E0964EWLcBFMxh0YCOjv5+o4BHucrp7A +s38f1HtvFtGQ38dsufRPi/zLfY5rNBiqlGptAPodTaRplAn9T1zdYtVXnnRENm33GxU rTUTzxX+7adY0yMQy3Gd+GPYUTaEXnT/yFuGn8nloM811G2N0zLJ4WVlmJX7CJinxn57 n1CFfaT4H43XMFVbyNboga4tRzAmUo92Tjd9+Z4VFBMvzVOEHfnHz+NwYVVg1qt/FQLU uFTw== 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=0Hbi0LxoIEjtB80FxOJFZ9KyTGmSEe2iec6SZ8Suep4=; b=QIt0ovAdFH2nBscHXnqBPxt6gmbEN+cFZAYmmalgEUdWJPY4i5PTM67VJ8Qh0ahKsf TOW33JbijeHp1ZH/dQHn3Jh4+KsgPZVZPVu9GwfDwLMAmqXyfwOPAJUvFEsBLDUZP+fB q4bg+yXy/hobz7JyhMbK3rjKhPgDA+1Mvsc0C14EXRU/gFjl9vlxL5WQSf403i8VmoMH ySfkRsyRUD+rwlj7Az7bFrcRChH4UZjdhpGMuprJ7+RAaUp905E/HUzKv9nL7Gz9KlVO Gg9cRIZPA4K/3ccsrae90uN1beo8Ka6M40oBT5mSR7RWJF5zEBSHg4dPmAS07+QtGkhA AUHw== X-Gm-Message-State: APjAAAWGda0Y63bBu89dnCeZp3fevczrsfYImHu7O7A2C8Xn0/7rEZ7C 7EbVohnVG1SNkjiYQEdAaG8urj8= X-Google-Smtp-Source: APXvYqyhsJvU3sV4lU8ZUnSgS9hgEP0UQDG4XdjnOca8RVo8aQhSKn9qyMdFuWzvv0MQDjGrzTzEZw== X-Received: by 2002:a37:7906:: with SMTP id u6mr3287888qkc.5.1571317553569; Thu, 17 Oct 2019 06:05:53 -0700 (PDT) Received: from localhost.localdomain ([66.187.232.65]) by smtp.gmail.com with ESMTPSA id g194sm1326648qke.46.2019.10.17.06.05.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 06:05:52 -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 v2 3/3] SUNRPC: Destroy the back channel when we destroy the host transport Date: Thu, 17 Oct 2019 09:02:21 -0400 Message-Id: <20191017130221.7924-4-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191017130221.7924-3-trond.myklebust@hammerspace.com> References: <20191017130221.7924-1-trond.myklebust@hammerspace.com> <20191017130221.7924-2-trond.myklebust@hammerspace.com> <20191017130221.7924-3-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 Reported-by: kbuild test robot Signed-off-by: Trond Myklebust --- include/linux/sunrpc/bc_xprt.h | 5 +++++ net/sunrpc/backchannel_rqst.c | 2 +- net/sunrpc/xprt.c | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/linux/sunrpc/bc_xprt.h b/include/linux/sunrpc/bc_xprt.h index 87d27e13d885..d796058cdff2 100644 --- a/include/linux/sunrpc/bc_xprt.h +++ b/include/linux/sunrpc/bc_xprt.h @@ -64,6 +64,11 @@ static inline int xprt_setup_backchannel(struct rpc_xprt *xprt, return 0; } +static inline void xprt_destroy_backchannel(struct rpc_xprt *xprt, + unsigned int max_reqs) +{ +} + static inline bool svc_is_backchannel(const struct svc_rqst *rqstp) { return false; diff --git a/net/sunrpc/backchannel_rqst.c b/net/sunrpc/backchannel_rqst.c index 7eb251372f94..195b40c5dae4 100644 --- a/net/sunrpc/backchannel_rqst.c +++ b/net/sunrpc/backchannel_rqst.c @@ -220,7 +220,7 @@ void xprt_destroy_bc(struct rpc_xprt *xprt, unsigned int max_reqs) goto out; spin_lock_bh(&xprt->bc_pa_lock); - xprt->bc_alloc_max -= max_reqs; + xprt->bc_alloc_max -= min(max_reqs, xprt->bc_alloc_max); list_for_each_entry_safe(req, tmp, &xprt->bc_pa_list, rq_bc_pa_list) { dprintk("RPC: req=%p\n", req); list_del(&req->rq_bc_pa_list); 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 */