Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp6389156ybf; Thu, 5 Mar 2020 19:46:16 -0800 (PST) X-Google-Smtp-Source: ADFU+vtVfY2uux9EwAzUUycqsuo4L954Gmfnw/P3Y9d6EcE/QL7X5fVNBYSTU1pr38PIDdWN+sbz X-Received: by 2002:aca:c597:: with SMTP id v145mr1193617oif.152.1583466376465; Thu, 05 Mar 2020 19:46:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583466376; cv=none; d=google.com; s=arc-20160816; b=tU9Sthyy4MmK7xNUYv6CF8hPKkMRRKDhBxN1nrlxE/khoXegREj28iioACai6z5oRx DG2UJsVqSv0YSfhyj1dmSHEzGKJuAQnGJ857YXbd+YagPbnvOA0eVnv7mphBSgQingkn AtO36EAXaQzTrLsKHilQVIu7Z++VRl//n8ZjOy5B74UcGnC6xBrXkeFr7ejo7OZr97eM atH4vlHmOm8uYfI/2zW0k3K0bYC1AzQxicmzJoExxczodmRP33HiWl3hQG4dWQl0aZH5 cspXecItV57p+o7MAP0G0SsYvou2xdmPFTCjXPNyxzmsyk+8CX2vdxZ7Du9ybRRMQYvA nMfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=Q76dSZ3ZtuScz35mg68rmoCwQeQHMDiWbwk4IP4yBWo=; b=hudRdXUTpPg5CPjgK+ybiN6nT9KoR69YQtRWEt+CFoEISRVeGjeCIcSCBVxUa9R/JO j32XEdeF04MH2LGbVaMK1n7MxkgpPiu4wmW/6FisnldY8RbaR1umI/VXWZK86LbC8u87 JT0t7JFYwzbOUlhmTmPrywJMx2PQDcHgYwhAE1SxcgC2coy0vFuSdE2N85dXKT34Aogs IlDuJaFRnR2E2lufwXo9OEWk4kIRJUdU2YAjVr/sIs8bnvghoPuTKA9Ybtv+AXhhwIfb sjpohoi2CU/UBES9EPPSJtWZiuGiLwcr6jgcpASguWxTY5HzvPrTJUh+QYfQdMpDQBBU bT5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=PSoMuNUt; 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 c23si139192oto.22.2020.03.05.19.45.51; Thu, 05 Mar 2020 19:46:16 -0800 (PST) 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=PSoMuNUt; 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 S1726358AbgCFDpm (ORCPT + 99 others); Thu, 5 Mar 2020 22:45:42 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:42447 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726243AbgCFDpm (ORCPT ); Thu, 5 Mar 2020 22:45:42 -0500 Received: by mail-pg1-f195.google.com with SMTP id h8so424127pgs.9; Thu, 05 Mar 2020 19:45:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Q76dSZ3ZtuScz35mg68rmoCwQeQHMDiWbwk4IP4yBWo=; b=PSoMuNUtJKVsYBN5/r8TgSqlSmgkyVrGqlUL8o+xIjRqfVUDa0KHioRwCAwr5fEQP4 +5ePUPJ79WTQbhH2IhfDJ8/U9NrWjXOifzrznR8DK68YFNKzKWf0xUkbdPGxVH2SaLl5 kX0PQMeRrdLBZ1lzpi8Q+6BKILLKpnOKBIsPpS+JeaS7qNlFStMfYE7fCC8NSNhoHwW9 9rcCB0BiJwqP0r07Ejmp8XXu9/px2SimZpuvlPFe3gW9y7lRvKwZpIYVZptj9i9ZboYE upxTaA5P0xj2uzsRqrSHJThAN9Ee5/k64BXlJvIKjPLk0FbcYme4NMU6w7OeRTl5zbm5 6qxg== 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; bh=Q76dSZ3ZtuScz35mg68rmoCwQeQHMDiWbwk4IP4yBWo=; b=TDa6WXuEn02qzzEznlikErnofDdQkoQ8oGnluP/TWqcQaq94bYHJqWHX3V3PbJ3ZIe TfM5Xc4jeyC+X2Tk3zvPHQKw0OAeEhTKvBW4YFEnHfIrI9jBUizcHEMIyGuKlVwNcTTb J9aRugsOyk01plE+l4fvTjT5o5hTfw2NKTnu5kdG1IcRQDyFxgn6Cg/r/8QNIdRrdkVv lJSE/eJTy2AmEeFOgFmTB/4ab5JQr1CoKtW8plf7UDn8ETQJhRY3ArwXSLK8tDt6F/l+ 2sR/xW3vp35xtNtMpPe8RHPlHwPhrXiSc09ZZsIDMOx7LOIC+jcpv2BKsu5z+mHwrL9r NGbQ== X-Gm-Message-State: ANhLgQ0b6E97AJAT3qnwmknObJBSFXNwSOYKhc0aQbOGeqAwdc/Q6zjY o6dy2/1WWfpu8a7k4oyIQEs= X-Received: by 2002:a63:c550:: with SMTP id g16mr1392916pgd.9.1583466339459; Thu, 05 Mar 2020 19:45:39 -0800 (PST) Received: from localhost.localdomain ([154.223.142.197]) by smtp.gmail.com with ESMTPSA id d1sm25931353pfc.3.2020.03.05.19.45.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Mar 2020 19:45:38 -0800 (PST) From: Zhouyi Zhou 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 Subject: [PATCH v3] NFS:remove redundant call to nfs_do_access Date: Fri, 6 Mar 2020 03:45:26 +0000 Message-Id: <1583466326-27867-1-git-send-email-zhouzhouyi@gmail.com> X-Mailer: git-send-email 1.7.1 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org 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