From patchwork Mon Feb 10 19:13:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11373955 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 C7FC0924 for ; Mon, 10 Feb 2020 19:16:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A8B922051A for ; Mon, 10 Feb 2020 19:16:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fcApY0O2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727538AbgBJTQH (ORCPT ); Mon, 10 Feb 2020 14:16:07 -0500 Received: from mail-yb1-f195.google.com ([209.85.219.195]:36054 "EHLO mail-yb1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727029AbgBJTQG (ORCPT ); Mon, 10 Feb 2020 14:16:06 -0500 Received: by mail-yb1-f195.google.com with SMTP id q190so1109437ybg.3 for ; Mon, 10 Feb 2020 11:16:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=FgobD3V7uuOy4LVGAx9rHhnWTaPqCxK05Vocd+6bvMM=; b=fcApY0O2/E2Jfj+xceGJmVwXJ+4x+C6qxz9vcSb2EPwUJfz7bbsS7ojqVLfklGfHss qyanx1f17n9q5CKjoFdjk/A0PgiG+rDaTVSUgBanZUYSKmui9TSFJtmK4r3ojvDoCnnm 1qdIqW3gaCXTbGJE/uVe94DvlG6w8HOzaIrc3H7SrXW9YCK7hkQw3L0RMhMEmQ85x8WM B6r1Hnwhay9EEZkn29iAH2/FzLDzfipIuLNZtxQUiGW3OtomlujnZXoTb8soneL/7/7E 8WUGs8vPWl3wxBaQJjTLZHl4gHjh85Y8Lm5lZ/gXwqGth9enk36Lt0eQTgXyP+xkgBmj mg2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FgobD3V7uuOy4LVGAx9rHhnWTaPqCxK05Vocd+6bvMM=; b=S+cwcHqqTIbZCOQuvg+FyQBMbb6SyoEdPbNtrAxdLPBzFFsJJRsQgbbHd1viIWJGPv RZ6IX1fTM6OKqWtkkPuWRQcbzVAoHqZ9IDS7uKX+sAX8ECeqDAr1Kd5cvaPpwUlT+23z aUR6Y5je0y7jgT3Im4/U4B6+FbjdW+Hr2fzLHpKZK1dV2zQTE6hlInQ0fIibBMNwv7UB m92hZlbFllokt9q8gywx3Ka3Xsew89Ipd2fwsrRuKOOviU+BrvnGlgN8SVjnfuq2gw6a 5LydWg9N8VUIemuQHA0uaWsOLUpvpNVE1dF2V5sGFZeno2tiaIiyeghiEqyk+/TiUT8V i/qw== X-Gm-Message-State: APjAAAVp1AL0k6mLsj6hFM8gfoWT5ZHBmw9J5lTV8pg+MNFMr0eCcVFm 2cLXD7oQB3s+rgedGo+exUtV8+N/gA== X-Google-Smtp-Source: APXvYqwzfADJ5Fb/IXrQIk9hQDciNw15sFD5Y2925VsEhzNrcgXyekrTHKpHnX6yXvG1VU4/5nXgTQ== X-Received: by 2002:a5b:384:: with SMTP id k4mr2833453ybp.305.1581362165736; Mon, 10 Feb 2020 11:16:05 -0800 (PST) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id o4sm660222ywd.5.2020.02.10.11.16.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Feb 2020 11:16:05 -0800 (PST) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 1/8] NFS: alloc_nfs_open_context() must use the file cred when available Date: Mon, 10 Feb 2020 14:13:38 -0500 Message-Id: <20200210191345.557460-2-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200210191345.557460-1-trond.myklebust@hammerspace.com> References: <20200210191345.557460-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 we're creating a nfs_open_context() for a specific file pointer, we must use the cred assigned to that file. Fixes: a52458b48af1 ("NFS/NFSD/SUNRPC: replace generic creds with 'struct cred'.") Signed-off-by: Trond Myklebust --- fs/nfs/inode.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 11bf15800ac9..a10fb87c6ac3 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c @@ -959,16 +959,16 @@ struct nfs_open_context *alloc_nfs_open_context(struct dentry *dentry, struct file *filp) { struct nfs_open_context *ctx; - const struct cred *cred = get_current_cred(); ctx = kmalloc(sizeof(*ctx), GFP_KERNEL); - if (!ctx) { - put_cred(cred); + if (!ctx) return ERR_PTR(-ENOMEM); - } nfs_sb_active(dentry->d_sb); ctx->dentry = dget(dentry); - ctx->cred = cred; + if (filp) + ctx->cred = get_cred(filp->f_cred); + else + ctx->cred = get_current_cred(); ctx->ll_cred = NULL; ctx->state = NULL; ctx->mode = f_mode; From patchwork Mon Feb 10 19:13:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11373957 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 0BB1D138D for ; Mon, 10 Feb 2020 19:16:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E11BC2051A for ; Mon, 10 Feb 2020 19:16:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="sL1kiPZb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727555AbgBJTQI (ORCPT ); Mon, 10 Feb 2020 14:16:08 -0500 Received: from mail-yw1-f66.google.com ([209.85.161.66]:37197 "EHLO mail-yw1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727029AbgBJTQI (ORCPT ); Mon, 10 Feb 2020 14:16:08 -0500 Received: by mail-yw1-f66.google.com with SMTP id l5so3952827ywd.4 for ; Mon, 10 Feb 2020 11:16:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=DHtLO0P0Zh+VIrDFcyw7AYu4iOARJCtRd5zyI+nBa7U=; b=sL1kiPZbuQUD7GMMkSObcRQKjOtJUpRQMlgY2bTY5LAj22TX+Z6wooONERmedkCWIU uf4Gu7H6+zLVxgbRuNXOE753J3bdoTp67sGzPRY/UZSmhbMCpTqD5kKObOfc4wYi7vCj ZCVMLQZ/1h8bC9C6m9i3XClxUPyELkrf+YspgmiQ1+k9ozNdtGRj3H4rHS8uhs0V8wP7 jIirKPm1BABM9a5YjcwUu5Jnqlkn/0wf0/kQ2YwQXDBamQnRUf7OTgEpDpcNAfJXSpy+ R+TVLbrQrZlsVTKXoJtgVYt/VXKRHuHouTmaLANEfHngfNYOmPwDQZHEuvfG3U0B0vrG 08TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DHtLO0P0Zh+VIrDFcyw7AYu4iOARJCtRd5zyI+nBa7U=; b=WQQwMADrUEFciIVL+YaPXgxgj/l+fJ9ljB5KOW2uZl2QNfHQ2jKCSRfpDIWz+HtvUy GDC8IATQIOg0p5j2Qg2ktdlzHYpmUn0YG2/XxUUm5NzQqWIWOIk2T79x8iOJWzFAtplz nc8nytpnl9GGL4MF15tdIHdb5D8Iaashhqnt6L02dhMWHL59G4sE9yOTqTuOUkI0/eLo bBsWyBrlvBkH6oQU4fsl8j7dMXW/nBQNM/bhFBPvtLWDmAAYUWaKEzJ+aGv7r1vg2Lva aDMEGqyzPzFwFxfRDluMS3lVMTjbDUT1NuSkOSZ7DuhbOjKSGv+eLgMe6dVNFywGByt1 o/mw== X-Gm-Message-State: APjAAAWpCLDb0+mBl1byi1gywYQq6UwWFHDRWiq+YoUVrZ0+1MgLPR2S gNO0mKUnpvLONRnJ5wlzPvwHQQkA3g== X-Google-Smtp-Source: APXvYqyZtdlHbuj7v9r6j3S6VJVR1MFa600geyb7YpLpTf8PTQuFHODF5UqquuGox+UxiARe5f/KgA== X-Received: by 2002:a81:a642:: with SMTP id d63mr2367225ywh.202.1581362166768; Mon, 10 Feb 2020 11:16:06 -0800 (PST) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id o4sm660222ywd.5.2020.02.10.11.16.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Feb 2020 11:16:06 -0800 (PST) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 2/8] SUNRPC: Add a flag to avoid reference counts on credentials Date: Mon, 10 Feb 2020 14:13:39 -0500 Message-Id: <20200210191345.557460-3-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200210191345.557460-2-trond.myklebust@hammerspace.com> References: <20200210191345.557460-1-trond.myklebust@hammerspace.com> <20200210191345.557460-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 Add a flag to signal to the RPC layer that the credential is already pinned for the duration of the RPC call. Signed-off-by: Trond Myklebust --- include/linux/sunrpc/sched.h | 1 + net/sunrpc/clnt.c | 5 +++-- net/sunrpc/sched.c | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/linux/sunrpc/sched.h b/include/linux/sunrpc/sched.h index a6ef35184ef1..df696efdd675 100644 --- a/include/linux/sunrpc/sched.h +++ b/include/linux/sunrpc/sched.h @@ -132,6 +132,7 @@ struct rpc_task_setup { #define RPC_TASK_TIMEOUT 0x1000 /* fail with ETIMEDOUT on timeout */ #define RPC_TASK_NOCONNECT 0x2000 /* return ENOTCONN if not connected */ #define RPC_TASK_NO_RETRANS_TIMEOUT 0x4000 /* wait forever for a reply */ +#define RPC_TASK_CRED_NOREF 0x8000 /* No refcount on the credential */ #define RPC_IS_ASYNC(t) ((t)->tk_flags & RPC_TASK_ASYNC) #define RPC_IS_SWAPPER(t) ((t)->tk_flags & RPC_TASK_SWAPPER) diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 7324b21f923e..2345e563c2f4 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -1099,8 +1099,9 @@ rpc_task_set_rpc_message(struct rpc_task *task, const struct rpc_message *msg) task->tk_msg.rpc_proc = msg->rpc_proc; task->tk_msg.rpc_argp = msg->rpc_argp; task->tk_msg.rpc_resp = msg->rpc_resp; - if (msg->rpc_cred != NULL) - task->tk_msg.rpc_cred = get_cred(msg->rpc_cred); + task->tk_msg.rpc_cred = msg->rpc_cred; + if (!(task->tk_flags & RPC_TASK_CRED_NOREF)) + get_cred(task->tk_msg.rpc_cred); } } diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c index 55e900255b0c..6eff14119a88 100644 --- a/net/sunrpc/sched.c +++ b/net/sunrpc/sched.c @@ -1162,7 +1162,8 @@ static void rpc_release_resources_task(struct rpc_task *task) { xprt_release(task); if (task->tk_msg.rpc_cred) { - put_cred(task->tk_msg.rpc_cred); + if (!(task->tk_flags & RPC_TASK_CRED_NOREF)) + put_cred(task->tk_msg.rpc_cred); task->tk_msg.rpc_cred = NULL; } rpc_task_release_client(task); From patchwork Mon Feb 10 19:13:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11373961 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 367FE924 for ; Mon, 10 Feb 2020 19:16:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 188D520838 for ; Mon, 10 Feb 2020 19:16:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="G7rLe0vc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727029AbgBJTQK (ORCPT ); Mon, 10 Feb 2020 14:16:10 -0500 Received: from mail-yw1-f68.google.com ([209.85.161.68]:35402 "EHLO mail-yw1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727331AbgBJTQK (ORCPT ); Mon, 10 Feb 2020 14:16:10 -0500 Received: by mail-yw1-f68.google.com with SMTP id i190so3953347ywc.2 for ; Mon, 10 Feb 2020 11:16:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=8aMIdSbKzgajTBdWOQFKylPBEb9etNnzN78zz1ELB7I=; b=G7rLe0vcAN4k2w8fEwt+dfhRGowGdgQsW7H6EqQi0X7v958EekjBav0RJ2GIt/5XXX yyDDEztaQoh7CwUK/jTwype/bOBlCqekGZDuvUWz8N1CBNrQZC73j5P5sqZJemrxJKzf 19GWrq+DlNX2HqddfL7OB7/pYnBUwFI7kXsOmOmwSTi9++NidqCQEMOBd1ubA1+BlLCW /yzBSFEQNVm8B6Nj0CkTZINWZQtWsuYL0Df+GuKcbe9Pk8dBUDT2NrQYkqWlFwd4l2kj Xo6PXL92Li+0c1o+zZF6ajbLrBhYV8eYXXuC0lOl29wgYUS9I+k+sosFxt0TU62+s2SU 0mwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8aMIdSbKzgajTBdWOQFKylPBEb9etNnzN78zz1ELB7I=; b=efSfjIGGzncPbkkuFtuQJ3ijX0CTePFoJmE+FhiP90APeXjmryLVe07Mcqy0XCkCOz KJofMzh0b4QaYLD+jtB+F5q15PPvsU/nbcQYdAotasUOzImmy8FuSEH+/BhNcf7NTBKK 8TwmPzawowSYZmSBUSMrQodN9/jfa9LKMei9bwJeWtjxmAdMX1rXK7y/Q/lbonOkq5/D K+0UF9VUwBJ/giR9D6LbRfesAHH65iKxuUJOHOHUvroDrZX5VuMbcIdBWeh0ndi4+fsY b05WmQaNPP5WmQTiEkUYfG2t3J0ZAnDHvyvnrsL6SwNaXtJnhiacaNuD0C7E0QDxiPIP 3rXg== X-Gm-Message-State: APjAAAW8OrIjxxDFzl2fcObLUbcm+3iS/Isyo4UJZ87/QQzM0qRAIZHV coVXKZjZll1SIhCqFPG0Hp6Z2vVQyw== X-Google-Smtp-Source: APXvYqw6Lw96yfg2kRot6kWWIMC/Twgbh0BFhBjVOdPxZgDdgOP27mjsEn9+A7PhoIms29RGg/tt3g== X-Received: by 2002:a81:52cd:: with SMTP id g196mr2362676ywb.89.1581362167649; Mon, 10 Feb 2020 11:16:07 -0800 (PST) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id o4sm660222ywd.5.2020.02.10.11.16.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Feb 2020 11:16:07 -0800 (PST) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 3/8] SUNRPC: Don't take a reference to the cred on synchronous tasks Date: Mon, 10 Feb 2020 14:13:40 -0500 Message-Id: <20200210191345.557460-4-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200210191345.557460-3-trond.myklebust@hammerspace.com> References: <20200210191345.557460-1-trond.myklebust@hammerspace.com> <20200210191345.557460-2-trond.myklebust@hammerspace.com> <20200210191345.557460-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 If the RPC call is synchronous, assume the cred is already pinned by the caller. Signed-off-by: Trond Myklebust --- net/sunrpc/clnt.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 2345e563c2f4..252b044cdcdf 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -1127,6 +1127,9 @@ struct rpc_task *rpc_run_task(const struct rpc_task_setup *task_setup_data) task = rpc_new_task(task_setup_data); + if (!RPC_IS_ASYNC(task)) + task->tk_flags |= RPC_TASK_CRED_NOREF; + rpc_task_set_client(task, task_setup_data->rpc_client); rpc_task_set_rpc_message(task, task_setup_data->rpc_message); From patchwork Mon Feb 10 19:13:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11373959 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 C57C9138D for ; Mon, 10 Feb 2020 19:16:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A678D2051A for ; Mon, 10 Feb 2020 19:16:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WtHiTNJU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727433AbgBJTQK (ORCPT ); Mon, 10 Feb 2020 14:16:10 -0500 Received: from mail-yb1-f194.google.com ([209.85.219.194]:33598 "EHLO mail-yb1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727029AbgBJTQJ (ORCPT ); Mon, 10 Feb 2020 14:16:09 -0500 Received: by mail-yb1-f194.google.com with SMTP id s35so4114043ybi.0 for ; Mon, 10 Feb 2020 11:16:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=OMqptcmVRzEg42M/Hggynq9yT5bF0SzCr+29ph874gs=; b=WtHiTNJUUYm2HOKw903oyXMskaymXXDRO+BgikK+fDWnDwBQmx62+aS/meJ7QyvhYt Polkexse58XqBG9iEouFX//dYxFaJusjmF1muyM0i6YzSDUvrXzQ1HO0S5IkwHBRR/Lz tNu+p8ygigSmW/6KAhd1J3/EG37Wp8VRrA9vl/dUyunhgZZl52an7otRZxGu+nTPkXJj eZ3rwy7f0uBq+SYvahbJ3CZRoIq9Kq8kAUZDOEVwxOsfU6/qkycJ/n0l4a8rUjbeL1rM AV7+xujds8DQ1BtYRfx08rpcdFs130UZJnIjVwqzqG13T6rD6K0a9atuYtZCxNzv3/LG A+fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OMqptcmVRzEg42M/Hggynq9yT5bF0SzCr+29ph874gs=; b=V+8nqUnZpg4fEL2b30cjhL+QOPAa3SKcMRaAiM+ckvfvt8ZopBbeY2mTfNIj25/4ML XnjpjTs1y9gLDWUAnrrL1yj0q8pIYREPsAmRQYHpKxxoSq1cTi1joaCCvaUoj8X1/h6I xwJ62LCu7iJtg9NwDasCsp4cvwESzjQK4tNQW+ieGexlm52y41SEkDmszgckz6s3BEef FQwhSshV+K1TC+I2wsrz/U+pgPlRKUi6Y7hPBc6n48jFRvAD2c8igRwELN8tUYq5XiLy np2ZuLhZ1Rb6+r6urH4hw0cSvltCi2Pgy20kwnla9o/eysOm7Ulc/dfDMthXNAblmHZg BSZQ== X-Gm-Message-State: APjAAAW8AbfacCAfLm65UQpz+SMbGA0Ti0q9Eydqckgk1pGDfiGTOY5i YdMQPG6CnGHiSb9e2eZ+1bpTPk8upg== X-Google-Smtp-Source: APXvYqzO+gbVYHwgqMICdW6fFFbTxZ9yoP9aEKL/rpGFA517LTjqUIJNwO+EOsHPOl4xFRAurFNdfg== X-Received: by 2002:a25:cb90:: with SMTP id b138mr2770485ybg.128.1581362168661; Mon, 10 Feb 2020 11:16:08 -0800 (PST) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id o4sm660222ywd.5.2020.02.10.11.16.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Feb 2020 11:16:08 -0800 (PST) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 4/8] NFS: Assume cred is pinned by open context in I/O requests Date: Mon, 10 Feb 2020 14:13:41 -0500 Message-Id: <20200210191345.557460-5-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200210191345.557460-4-trond.myklebust@hammerspace.com> References: <20200210191345.557460-1-trond.myklebust@hammerspace.com> <20200210191345.557460-2-trond.myklebust@hammerspace.com> <20200210191345.557460-3-trond.myklebust@hammerspace.com> <20200210191345.557460-4-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 In read/write/commit, we should be able to assume that the cred is pinned by the open context. Signed-off-by: Trond Myklebust --- fs/nfs/pagelist.c | 2 +- fs/nfs/write.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c index 20b3717cd7ca..c9c3edefc5be 100644 --- a/fs/nfs/pagelist.c +++ b/fs/nfs/pagelist.c @@ -627,7 +627,7 @@ int nfs_initiate_pgio(struct rpc_clnt *clnt, struct nfs_pgio_header *hdr, .callback_ops = call_ops, .callback_data = hdr, .workqueue = nfsiod_workqueue, - .flags = RPC_TASK_ASYNC | flags, + .flags = RPC_TASK_ASYNC | RPC_TASK_CRED_NOREF | flags, }; int ret = 0; diff --git a/fs/nfs/write.c b/fs/nfs/write.c index c478b772cc49..5544ee6cfda8 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c @@ -1707,7 +1707,7 @@ int nfs_initiate_commit(struct rpc_clnt *clnt, struct nfs_commit_data *data, .callback_ops = call_ops, .callback_data = data, .workqueue = nfsiod_workqueue, - .flags = RPC_TASK_ASYNC | flags, + .flags = RPC_TASK_ASYNC | RPC_TASK_CRED_NOREF | flags, .priority = priority, }; /* Set up the initial task struct. */ From patchwork Mon Feb 10 19:13:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11373963 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 8F3A9138D for ; Mon, 10 Feb 2020 19:16:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 710DF20838 for ; Mon, 10 Feb 2020 19:16:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="g/4dgZhF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727575AbgBJTQL (ORCPT ); Mon, 10 Feb 2020 14:16:11 -0500 Received: from mail-yw1-f66.google.com ([209.85.161.66]:45424 "EHLO mail-yw1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727331AbgBJTQL (ORCPT ); Mon, 10 Feb 2020 14:16:11 -0500 Received: by mail-yw1-f66.google.com with SMTP id a125so3929597ywe.12 for ; Mon, 10 Feb 2020 11:16:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=bX+88Oqr9VbMzymWapnmRWOT+ucgpVL7mFGX75Ly+eA=; b=g/4dgZhF3gRGIk6czUZMOpVH5c0zuV6I5x7NptBcX0l0BYUtO3xKQNVJPLvlG9DEeu Q7OCzUgbH4CdWI2C1bac76ojrwwe0OKeiexeAtr5VLVyVnlCkwgcit8GxGp4Wvv+cHly TalQdJRmRnTH+B4PaqdUeOg7D5iq2ixSnINhEaYVBZ45xZT9s/YmllXgWzAXp+58i1f5 MCYW4FDzcnRh4Oa2LUJc3yUsSRiudeXdIfWdAxFrZFJh3GSA3NhGxbDxmTwIAdtPjBg6 LJHpxCVH8IqlHcd/8ojhwc3fWvc+2007ZY6u52waQk65mpXhOWfJ2+R2bv8BLU1OdumI Gckg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bX+88Oqr9VbMzymWapnmRWOT+ucgpVL7mFGX75Ly+eA=; b=cXlHf+Q05QjCyt06ZMClhOZErwyJpSuJyyPqf4cIzgMHdurVHzt+TLbK0+MhJvnSUr FMyaE88OWGXHgSInosU9lN2BkFKZmeOT6YVqhxcpf1t04KBU0VqZmLEign7wf+OCAzs2 srSQjDO0tybuK/kAt+yM7IhumZ+hVrtGnbOQ1McF+TI5JEhuKbXhJ/1sgo4vHKZuQGjB EyXDyyzT83a06/LLNSwYDzPWtQrpkcHlS9DH5PqNLQJ4WS0Wnab1QZ5veBLcog9EDZ47 GMLd3HKISg9sRyHPyqpKF3YDybViWdmYwJ9DqI99C6kcS122Z3rohJxd9OgeiKsIJcgr ar9Q== X-Gm-Message-State: APjAAAUsr3kJVHLJsy6KQXC45WVoDynM+RXv8IZ+yy5pdEaqWimWBjuf PqWshoWeFGQ5+NtW1/NtWOsOCZHIWg== X-Google-Smtp-Source: APXvYqylnCZKrv4hAD37Ae/hdiWNhSIDVvUqVEof1C/wpiAWSW5tvd3rwma8JLxbUC/fbEgFipN5Rw== X-Received: by 2002:a0d:e20a:: with SMTP id l10mr2251695ywe.17.1581362169562; Mon, 10 Feb 2020 11:16:09 -0800 (PST) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id o4sm660222ywd.5.2020.02.10.11.16.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Feb 2020 11:16:09 -0800 (PST) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 5/8] NFSv4: Avoid referencing the cred unnecessarily during NFSv4 I/O Date: Mon, 10 Feb 2020 14:13:42 -0500 Message-Id: <20200210191345.557460-6-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200210191345.557460-5-trond.myklebust@hammerspace.com> References: <20200210191345.557460-1-trond.myklebust@hammerspace.com> <20200210191345.557460-2-trond.myklebust@hammerspace.com> <20200210191345.557460-3-trond.myklebust@hammerspace.com> <20200210191345.557460-4-trond.myklebust@hammerspace.com> <20200210191345.557460-5-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 Avoid unnecessary references to the cred when we have already referenced it through the open context or the open owner. Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 00fe674c8a49..47464fb419dc 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -2346,7 +2346,7 @@ static int _nfs4_proc_open_confirm(struct nfs4_opendata *data) .callback_ops = &nfs4_open_confirm_ops, .callback_data = data, .workqueue = nfsiod_workqueue, - .flags = RPC_TASK_ASYNC, + .flags = RPC_TASK_ASYNC | RPC_TASK_CRED_NOREF, }; int status; @@ -2511,7 +2511,7 @@ static int nfs4_run_open_task(struct nfs4_opendata *data, .callback_ops = &nfs4_open_ops, .callback_data = data, .workqueue = nfsiod_workqueue, - .flags = RPC_TASK_ASYNC, + .flags = RPC_TASK_ASYNC | RPC_TASK_CRED_NOREF, }; int status; @@ -3651,7 +3651,7 @@ int nfs4_do_close(struct nfs4_state *state, gfp_t gfp_mask, int wait) .rpc_message = &msg, .callback_ops = &nfs4_close_ops, .workqueue = nfsiod_workqueue, - .flags = RPC_TASK_ASYNC, + .flags = RPC_TASK_ASYNC | RPC_TASK_CRED_NOREF, }; int status = -ENOMEM; @@ -6350,7 +6350,7 @@ static int _nfs4_proc_delegreturn(struct inode *inode, const struct cred *cred, .rpc_client = server->client, .rpc_message = &msg, .callback_ops = &nfs4_delegreturn_ops, - .flags = RPC_TASK_ASYNC | RPC_TASK_TIMEOUT, + .flags = RPC_TASK_ASYNC | RPC_TASK_CRED_NOREF | RPC_TASK_TIMEOUT, }; int status = 0; @@ -6933,7 +6933,7 @@ static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *f .rpc_message = &msg, .callback_ops = &nfs4_lock_ops, .workqueue = nfsiod_workqueue, - .flags = RPC_TASK_ASYNC, + .flags = RPC_TASK_ASYNC | RPC_TASK_CRED_NOREF, }; int ret; From patchwork Mon Feb 10 19:13:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11373965 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 C7A5B14B4 for ; Mon, 10 Feb 2020 19:16:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A95D920838 for ; Mon, 10 Feb 2020 19:16:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CMr80gXg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727331AbgBJTQM (ORCPT ); Mon, 10 Feb 2020 14:16:12 -0500 Received: from mail-yw1-f67.google.com ([209.85.161.67]:41708 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727572AbgBJTQM (ORCPT ); Mon, 10 Feb 2020 14:16:12 -0500 Received: by mail-yw1-f67.google.com with SMTP id l22so3939022ywc.8 for ; Mon, 10 Feb 2020 11:16:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ZcmMvtTswIf+YTA+DDJp0GV3gjjxF4a82aq2v6Pllwk=; b=CMr80gXgP7NEy5pxOzpF/mHW6wKRRgYI8oY4Ebw1PklTuLjqP1dyXNAbhzD3Ludaiz r2LbNmrFOGCTAQ27DbJFbMbQFyqv2ZHqCWKh7yjEO7FG0XCtLOiLtoMj9NMy+/0WMWrs y4CA+xFAm+WndqwNaVGHX5OWXi7Uetnk3J8K76gJSeZjyaWAaILYeJH5/a0CI+Ng/xoa UYN8XJKGcKOO0pyUWCqgSibFSbzGGhoHkzrXxZWnEzREa4LqmO8eOANyXbTOooW0dhWG O8z46N3hKThPwKla0flZgAJwVSxGgsYFgsfWdjbJBqnvPj36WrPPERgb0EnvBe8znMUZ mmBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZcmMvtTswIf+YTA+DDJp0GV3gjjxF4a82aq2v6Pllwk=; b=eCn7eiIrqlhvqfLs6dKc/nGIuAGGMGruE7UcaefYrC1doWLnmdXcjuCjYpxKHRHFz6 bhSmsz35pBo5JxHwZG4F5Mi05gtsQK3MQbFgMoQxEcbQd8qcEa7h9uUz3vJU+Ink+m17 Weh0C7LMXWX26fHR2KpCWEl1+oSp0I5WlCQL01nXDOnHt3GLE7rjL/ncDZYuBLIeFstY HSROOF07dM2Tv3RqO44bgEKziVzpg3NMP7IoUYctVjAsDzLYLsEEAj3OQTmA1jhWvtGZ AETxQjF8GOv4izrqSFy5K4aLofsxLzd3rffatvB1PRXlRt+6t2vCR3LZlqydsQKO1Ev5 0IbA== X-Gm-Message-State: APjAAAV1yHLdRjdzinERhzC+lG3tJ68Ppp6CiFDRqrrSC6dD61d0fdJT yF5PAMsyv53ocyyGyFcJl+efl2ZcWg== X-Google-Smtp-Source: APXvYqxg7MhfqQvz0QXyd8iYTAuqieE78vE6p4sHhMEorpTTGewJa3NpIcWBpNXDWL4rB8+HPcsIAw== X-Received: by 2002:a0d:db47:: with SMTP id d68mr2428247ywe.338.1581362170423; Mon, 10 Feb 2020 11:16:10 -0800 (PST) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id o4sm660222ywd.5.2020.02.10.11.16.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Feb 2020 11:16:10 -0800 (PST) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 6/8] NFSv4: Avoid unnecessary credential references in layoutget Date: Mon, 10 Feb 2020 14:13:43 -0500 Message-Id: <20200210191345.557460-7-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200210191345.557460-6-trond.myklebust@hammerspace.com> References: <20200210191345.557460-1-trond.myklebust@hammerspace.com> <20200210191345.557460-2-trond.myklebust@hammerspace.com> <20200210191345.557460-3-trond.myklebust@hammerspace.com> <20200210191345.557460-4-trond.myklebust@hammerspace.com> <20200210191345.557460-5-trond.myklebust@hammerspace.com> <20200210191345.557460-6-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 Layoutget is just using the credential attached to the open context. Signed-off-by: Trond Myklebust --- fs/nfs/nfs4proc.c | 2 +- fs/nfs/pnfs.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index 47464fb419dc..7f5802b6d404 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -9177,7 +9177,7 @@ nfs4_proc_layoutget(struct nfs4_layoutget *lgp, long *timeout) .rpc_message = &msg, .callback_ops = &nfs4_layoutget_call_ops, .callback_data = lgp, - .flags = RPC_TASK_ASYNC, + .flags = RPC_TASK_ASYNC | RPC_TASK_CRED_NOREF, }; struct pnfs_layout_segment *lseg = NULL; struct nfs4_exception exception = { diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index b21eb4882846..cb99ac954688 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c @@ -1073,7 +1073,7 @@ pnfs_alloc_init_layoutget_args(struct inode *ino, lgp->args.ctx = get_nfs_open_context(ctx); nfs4_stateid_copy(&lgp->args.stateid, stateid); lgp->gfp_flags = gfp_flags; - lgp->cred = get_cred(ctx->cred); + lgp->cred = ctx->cred; return lgp; } @@ -1084,7 +1084,6 @@ void pnfs_layoutget_free(struct nfs4_layoutget *lgp) nfs4_free_pages(lgp->args.layout.pages, max_pages); if (lgp->args.inode) pnfs_put_layout_hdr(NFS_I(lgp->args.inode)->layout); - put_cred(lgp->cred); put_nfs_open_context(lgp->args.ctx); kfree(lgp); } From patchwork Mon Feb 10 19:13:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11373967 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 C9FD4924 for ; Mon, 10 Feb 2020 19:16:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AB35120842 for ; Mon, 10 Feb 2020 19:16:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GgZ6eIZj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727587AbgBJTQN (ORCPT ); Mon, 10 Feb 2020 14:16:13 -0500 Received: from mail-yw1-f68.google.com ([209.85.161.68]:44119 "EHLO mail-yw1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727572AbgBJTQM (ORCPT ); Mon, 10 Feb 2020 14:16:12 -0500 Received: by mail-yw1-f68.google.com with SMTP id t141so3931965ywc.11 for ; Mon, 10 Feb 2020 11:16:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=a+13WK+Oz13ZrEk9aniPwYJ/cSiJ37KnFThG8SEGIeU=; b=GgZ6eIZjLQxLLqbZrVoSTkzMgVbN/ajMHuWoz4PQkrW7jzcD5ixDKQdVerWFEtdCS2 lM8e72DAHDvJbEPs6kiTSTyEnlU3eoLk2useIgl4NGJvJHA44hbwKuoJGLA/JD8uwgEK zQ//fVOgT40NWlJ+3MVvlEM4QYZRcwMDRB8AgwO8X9UMI98xeBactWnzq7hbxMaJJx/q pMbT6NeTEQr3unWM/NS5eZ6GAP6Oi4X4Cyxqwu/LJxW4L8ZA5qV2pNsD163OrOUgy8Ts Klyk1cOrVJHh84td5rgEPT11PTp5/sjvkIipTvUFpqvKsIPZXGv0N8FZ5NJDD6sOzw/q ez9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=a+13WK+Oz13ZrEk9aniPwYJ/cSiJ37KnFThG8SEGIeU=; b=ia1ofhLwAQBmSFD3YbqfGCwbxET/mC5nGrAqRmgpkN5Msp9QDITgp5gHygVfXO1aZq 3oA7VK04NMlsUuQXy1Kwbp3M+da+p81l4qiDBFEwVhhyoHr1Lf4zltwirdueubq+qU/Q HcwxvMLLu2u9ilC0gA71Rp8j+tO0yavAXEOx54Apr+PSTC5q0Mk0RcfArb6nGG2MGhet QpUiF3MvJ1VjgyKRlpGSBQ2/VReaF+R+kOGiRVpO+ZWSWS9vs+KALgcnJCLOc2P9k3PI NEcwrgse3sVZnAVUkptpEF5KzRl/9AdXcFBhzMw2WCS7bIZ2IjIzMJqpouVk9SIECy26 Kdlw== X-Gm-Message-State: APjAAAWvaPTE8gfP+QfSoLRyTD1xzZ4SAOjpxtiSCL1b+L8NMveMvV4b +wzPMKmNYtiTimgrdv33L/vYcwpnJA== X-Google-Smtp-Source: APXvYqzcB2M1xN6pV6/e7/B65yB6pNLPKEAsNNPm4WycGa3XwqCy93Mesnsej88RJuyMvqrRHQxKdQ== X-Received: by 2002:a0d:e186:: with SMTP id k128mr2310405ywe.178.1581362171224; Mon, 10 Feb 2020 11:16:11 -0800 (PST) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id o4sm660222ywd.5.2020.02.10.11.16.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Feb 2020 11:16:10 -0800 (PST) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 7/8] NFS: Avoid referencing the cred twice in async rename/unlink Date: Mon, 10 Feb 2020 14:13:44 -0500 Message-Id: <20200210191345.557460-8-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200210191345.557460-7-trond.myklebust@hammerspace.com> References: <20200210191345.557460-1-trond.myklebust@hammerspace.com> <20200210191345.557460-2-trond.myklebust@hammerspace.com> <20200210191345.557460-3-trond.myklebust@hammerspace.com> <20200210191345.557460-4-trond.myklebust@hammerspace.com> <20200210191345.557460-5-trond.myklebust@hammerspace.com> <20200210191345.557460-6-trond.myklebust@hammerspace.com> <20200210191345.557460-7-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 In both async rename and rename, we take a reference to the cred in the call arguments. Signed-off-by: Trond Myklebust --- fs/nfs/unlink.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/nfs/unlink.c b/fs/nfs/unlink.c index 0effeee28352..b27ebdccef70 100644 --- a/fs/nfs/unlink.c +++ b/fs/nfs/unlink.c @@ -98,7 +98,7 @@ static void nfs_do_call_unlink(struct inode *inode, struct nfs_unlinkdata *data) .callback_ops = &nfs_unlink_ops, .callback_data = data, .workqueue = nfsiod_workqueue, - .flags = RPC_TASK_ASYNC, + .flags = RPC_TASK_ASYNC | RPC_TASK_CRED_NOREF, }; struct rpc_task *task; struct inode *dir = d_inode(data->dentry->d_parent); @@ -341,7 +341,7 @@ nfs_async_rename(struct inode *old_dir, struct inode *new_dir, .callback_ops = &nfs_rename_ops, .workqueue = nfsiod_workqueue, .rpc_client = NFS_CLIENT(old_dir), - .flags = RPC_TASK_ASYNC, + .flags = RPC_TASK_ASYNC | RPC_TASK_CRED_NOREF, }; data = kzalloc(sizeof(*data), GFP_KERNEL); From patchwork Mon Feb 10 19:13:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 11373969 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 51B9A924 for ; Mon, 10 Feb 2020 19:16:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3358F20838 for ; Mon, 10 Feb 2020 19:16:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="muYkk6iD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727592AbgBJTQO (ORCPT ); Mon, 10 Feb 2020 14:16:14 -0500 Received: from mail-yw1-f68.google.com ([209.85.161.68]:38757 "EHLO mail-yw1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727572AbgBJTQO (ORCPT ); Mon, 10 Feb 2020 14:16:14 -0500 Received: by mail-yw1-f68.google.com with SMTP id 10so3953250ywv.5 for ; Mon, 10 Feb 2020 11:16:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=wP5YOVIjUJKkKgcFCczFDbdtOGhanuwuabMb8PE+9gM=; b=muYkk6iD0s63CwNio7un27SozL0/ereKoBI7rD1jiP1HQI2Euxg4aI8BM1teHumlrc tjmyNewXvffNl2aTlqxyH1ndKvhDHUQj5oQ0PqQ9JerbnxeD2YSbAdj9Jy2QfyoKz6TC gG4wP7sEqA4IkDp0YHEQ9DytWt73RFbxNjXCiaUTwOtbu/QeMovOUYvqYdqKO6X/sbbW o6Jxksm2Ysl2S0o65gjdhi4mwgpOcPNrxZvoQQYDzdbzc60VU4J7VWprGIvi34JQe3te 3ZYNFXWCWAfHU9hbIWrPVvo6qG9WBU4qfGq29LwfSGDzjiiaA1g8IFeU6gQDlTrpBKFA uDKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wP5YOVIjUJKkKgcFCczFDbdtOGhanuwuabMb8PE+9gM=; b=dAszKNEK/MIfp1uOvvl0p68IrlVWhXXzM3RbduJ7mfGPHZHfOBY+pMW+Qy8YXXTS2J qw/thKVF221zfhDLd10FRAK18wCxRpIwdMckqiClyn41ZFuWZ566W90afRUqBpfWGyUm EGXmBMsiHmu7j6xu8KheKewFcKG4Z4Cbevm2ekGWEUhT/IWUGlxIzkaOlu8yYiY5lffk fgZ7x7aq37tf5drBLNSRYlht0P0gUWaLNCObm40ehAUwl2a6ddHAN7nzIl4Sel+rEev0 t1P1xjHsWkDi/bQwbO1U3NON/iABXltdQ/nK/7Ch33wlHLWW2lXDIjbRq41vvL9bXBDp d7FQ== X-Gm-Message-State: APjAAAXrh606ij7DQU6usZVkuD46j8MJtSG9P1OKgTS2w8EWcT5iw/4F SwHs0jlsBJWxmz+pfqS4KwyX1x2O4Q== X-Google-Smtp-Source: APXvYqyLOt8lyvdi20M10OtL7xdHzDy/96z6xILqrnv1dNNSsEP0LpwFc6HX8P7x2/RRA00iyTWrFQ== X-Received: by 2002:a81:52d6:: with SMTP id g205mr2310010ywb.179.1581362171942; Mon, 10 Feb 2020 11:16:11 -0800 (PST) Received: from localhost.localdomain (c-68-40-189-247.hsd1.mi.comcast.net. [68.40.189.247]) by smtp.gmail.com with ESMTPSA id o4sm660222ywd.5.2020.02.10.11.16.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Feb 2020 11:16:11 -0800 (PST) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH 8/8] NFS: Limit the size of the access cache by default Date: Mon, 10 Feb 2020 14:13:45 -0500 Message-Id: <20200210191345.557460-9-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200210191345.557460-8-trond.myklebust@hammerspace.com> References: <20200210191345.557460-1-trond.myklebust@hammerspace.com> <20200210191345.557460-2-trond.myklebust@hammerspace.com> <20200210191345.557460-3-trond.myklebust@hammerspace.com> <20200210191345.557460-4-trond.myklebust@hammerspace.com> <20200210191345.557460-5-trond.myklebust@hammerspace.com> <20200210191345.557460-6-trond.myklebust@hammerspace.com> <20200210191345.557460-7-trond.myklebust@hammerspace.com> <20200210191345.557460-8-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 Currently, we have no real limit on the access cache size (we set it to ULONG_MAX). That can lead to credentials getting pinned for a very long time on lots of files if you have a system with a lot of memory. Signed-off-by: Trond Myklebust --- fs/nfs/dir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c index 09bcbdc67135..133bf23430e8 100644 --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -2307,7 +2307,7 @@ static DEFINE_SPINLOCK(nfs_access_lru_lock); static LIST_HEAD(nfs_access_lru_list); static atomic_long_t nfs_access_nr_entries; -static unsigned long nfs_access_max_cachesize = ULONG_MAX; +static unsigned long nfs_access_max_cachesize = 4*1024*1024; module_param(nfs_access_max_cachesize, ulong, 0644); MODULE_PARM_DESC(nfs_access_max_cachesize, "NFS access maximum total cache length");