Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1193206ybb; Fri, 10 Apr 2020 20:10:45 -0700 (PDT) X-Google-Smtp-Source: APiQypKcSYtB7Yu7vkEeVg+VlCshBYVfr4Gs/JvvLTJEJi8nkYvPrLYrWA0Jh6cBZbTgaJcUGLz0 X-Received: by 2002:aed:29c4:: with SMTP id o62mr2086403qtd.225.1586574645621; Fri, 10 Apr 2020 20:10:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586574645; cv=none; d=google.com; s=arc-20160816; b=s0usAn4lx4w20o4GYxfKeybWXC1rem41+5yTvIvgoKPVTQA6h1RGMdXTEI3EnNU/Z2 EuwaH2jMzSdBCmOnWRPsI4nF9AdzEbYvw+DouwAaH6meKZGhZJNOn8QnqPAcDT/JmXzK zBy5KbBcpamfbgUTo5tDCedXdHq98d8VuRPamNtNdAdh5XzaNPfa9+aSGWf1IoVVLKaU gOLqdGA3bllRialEf8EzXwAU28sGCuCKmpytaqHAePgnJ0lxATV1ODpa0r3EL4Fjmdlj nefVVhnakYmy6k/6GteHj9vV3Wm0tsjxaJt2EX7V7/pwY6wTh8AdMZsz7BtH4K3NCQlG rHtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :mime-version:dkim-signature; bh=LBgDv84I3ckmgTu3ivHx5w10eRA7knmGI/Q+O2z8ngw=; b=mlbWxxDAvoakIAcFpvPU91TKN1xEpRKA7iPpLPla5KToRmm/1B+rMzrJjCJQFBtrtl O+jEqnt/rnix+gGBnsgCIhSckAfJvMGaXSZZkG+H7yyPQclZcoAkEuMMN5Ys/axjJWF0 r6nxdeM0ggAysEfYsdz0b9pI+Y0Xmo4MO8zq3K7Oa69VEfeaMxne7cMXJ3l9k/mlbuZr tyQseJjTRbqkER/iG9fWEuk7l7FYt9tDLZ5wPCN5dez66C4pJ47lKu//s/AMr+C8z+yZ OG4/hiyvv13kKv7HKDq5Qn2qGySTTKpF9ezJEteddOXAvXSqd4MQiO1hmq6MrQIFlHGs 7Jmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="R/IbJQOT"; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q7si2200293qtj.82.2020.04.10.20.10.08; Fri, 10 Apr 2020 20:10:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="R/IbJQOT"; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726669AbgDKDKB (ORCPT + 99 others); Fri, 10 Apr 2020 23:10:01 -0400 Received: from mail-vs1-f68.google.com ([209.85.217.68]:43135 "EHLO mail-vs1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726663AbgDKDKB (ORCPT ); Fri, 10 Apr 2020 23:10:01 -0400 Received: by mail-vs1-f68.google.com with SMTP id u11so2399157vsu.10; Fri, 10 Apr 2020 20:10:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to:cc; bh=LBgDv84I3ckmgTu3ivHx5w10eRA7knmGI/Q+O2z8ngw=; b=R/IbJQOTjiM4hal2cRECDmtHgGQCG+By9rF/T6UR+EWbEnbVZi6QgZz1rb380ObGRj pTRu1oqdrJKECunBHG6RkZv1qxum38kTlRAbxEn6O9v6VqvEC5ek8kVhtSjv7hoaORTo UGsu9IrJYxE71aHtX1XI4BnV23r4IC1kvVTw9xiQIvGBsUMzGbsFFZF/s3zxIup7iiz+ /xe9LeYUsZHxEnSpCj5ngYAXQ54j+sNmb/qnKKpRYnCjTbtq4h3R/ZQDhdUefwwot5p9 /wibG1I8Yp8+FBUj0/yriAQgjR9ZoviHZ2OWlKpr5EVYYJe+4Zt1Vn7yz7nosp172E+K 3Ajg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=LBgDv84I3ckmgTu3ivHx5w10eRA7knmGI/Q+O2z8ngw=; b=Ep3NqGeVQfjNnDQKsJEV+8rgkikPGTUGXFJ4/YWMj9zKG1fkWhB0Fp3dCvpZx4RLFr w6/EwljxUZtEcFaiGbrU5kwJqy4rxCUqLQmkns7+AgTfqs+H6nLP3Cmp5buA9AiWpii+ TSV4eOU6retL1qfwfHkiVJ0894sFC/utD0d6cUMt3lYgjx5NhvJnfxMZHgRX1lPUzwY0 iySqiKkspxLO1RMqou7rHl+lpSNjxE8fWVJz/qgKwtM+3Yac1HVkrJs8fbxAKfR8KqmB LeIyoIUn6NtpYOVgscNrwcphVXlLpdsKX5d5beqHraEgtZLYPIBf5AK5FdOBC7c70g4l 3FCg== X-Gm-Message-State: AGi0Pubof7MfM0o0RwiWuc7ADxZCSLB6XdfATwYWW2P4ptpprctzqvo9 ppJ0LlL57lf+S0Ja1EHBSWQxhHjuMp+kE+HUd1o= X-Received: by 2002:a05:6102:107:: with SMTP id z7mr6073849vsq.235.1586574600188; Fri, 10 Apr 2020 20:10:00 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a67:f985:0:0:0:0:0 with HTTP; Fri, 10 Apr 2020 20:09:59 -0700 (PDT) From: Zhouyi Zhou Date: Sat, 11 Apr 2020 11:09:59 +0800 Message-ID: Subject: ping: [PATCH v3] NFS:remove redundant call to nfs_do_access To: trond.myklebust@hammerspace.com, anna.schumaker@netapp.com, linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, paulmck@linux.ibm.com, paulmck@linux.vnet.ibm.com, neilb@suse.com Cc: Zhouyi Zhou , 340442286 <340442286@qq.com> Content-Type: text/plain; charset="UTF-8" Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org ping On 3/6/20, Zhouyi Zhou wrote: > In function nfs_permission: > 1. the rcu_read_lock and rcu_read_unlock around nfs_do_access > is unnecessary because the rcu critical data structure is already > protected in subsidiary function nfs_access_get_cached_rcu. No other > data structure needs rcu_read_lock in nfs_do_access. > > 2. call nfs_do_access once is enough, because: > 2-1. when mask has MAY_NOT_BLOCK bit > The second call to nfs_do_access will not happen. > > 2-2. when mask has no MAY_NOT_BLOCK bit > The second call to nfs_do_access will happen if res == -ECHILD, which > means the first nfs_do_access goes out after statement if (!may_block). > The second call to nfs_do_access will go through this procedure once > again except continue the work after if (!may_block). > But above work can be performed by only one call to nfs_do_access > without mangling the mask flag. > > Tested in x86_64 > Signed-off-by: Zhouyi Zhou > --- > fs/nfs/dir.c | 9 +-------- > 1 files changed, 1 insertions(+), 8 deletions(-) > > diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c > index 193d6fb..37b0c10 100644 > --- a/fs/nfs/dir.c > +++ b/fs/nfs/dir.c > @@ -2732,14 +2732,7 @@ int nfs_permission(struct inode *inode, int mask) > if (!NFS_PROTO(inode)->access) > goto out_notsup; > > - /* Always try fast lookups first */ > - rcu_read_lock(); > - res = nfs_do_access(inode, cred, mask|MAY_NOT_BLOCK); > - rcu_read_unlock(); > - if (res == -ECHILD && !(mask & MAY_NOT_BLOCK)) { > - /* Fast lookup failed, try the slow way */ > - res = nfs_do_access(inode, cred, mask); > - } > + res = nfs_do_access(inode, cred, mask); > out: > if (!res && (mask & MAY_EXEC)) > res = nfs_execute_ok(inode, mask); > -- > 1.7.1 > >