Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp508282ybf; Fri, 28 Feb 2020 02:18:28 -0800 (PST) X-Google-Smtp-Source: APXvYqycmC8Hfm752YrFj/h7UmxXjOTbGIHGxIABnM12hIPmaarMx/+mWFae/nLhqctU48eu1urg X-Received: by 2002:aca:b284:: with SMTP id b126mr2583284oif.79.1582885108277; Fri, 28 Feb 2020 02:18:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582885108; cv=none; d=google.com; s=arc-20160816; b=G61eliGm0d/KXGCZWyth/j5uMT4IB3yV96cd/8gG6a2eB7Aq9YFpCRn5/0lDMkKSZp qkdOOiOyiiko1UF//QjTB5J0r4XMGenAAL2WMS2vUmiOCxOEZSaGXDcrGpHWYd8ImrVk q5kIKvpmy4wvuPcibMwydymLhYcxMa87ZsadAAa3OMzTf9lqZROxcFMO5jWDFtL0uA2Y zgTxCmSj1S2/Tpb2Y3EhzDoOJn0oyQ5zTVW4elWXkGvjrCKqbSi0FmETNHmEYvLay93l qpTKR4ysrK/P9/Uue23l3RGcWhWBH+zroKq5B061RzPbtG+F3bArbJe27q6phGHwr/p4 /CIw== 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=Zca5QT4St3KZ5ZG6XZtY4fdQBROyOfaj3q5el9kJMhI=; b=HIhhvuYKffFsEvtbLqCQIA99/j47f1MUCH6oKtRqNCzUoI61J8Xao8mI67LjjIMuGc ns7a6Citp/mznPvB0AtJMWCh6B7aAl050hbqeMdVziu2qAxiZvwjGU02R5pRsTvZah/j FYk05pUBKBrRev1HLxYbEXGiq3R3yMYPsqDv9FqRnZOAVH9GmkVWnNI0cskWOhsU1Dik +ZNR/dwCaU9uGRSLFiDzE20FXEWyZaS7wHBVILRkI0bS/s73YisX+1sj1z44KYsBKQ4b 3tuCzRc0sdTixFonZxNPfzrznAas/nnGFL+O3wJDT0PSo/Ou3rc4CvNBdaxhMJWRy5Io t7mA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=XNj6JUVt; 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 i6si1298665otp.5.2020.02.28.02.18.16; Fri, 28 Feb 2020 02:18:28 -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=XNj6JUVt; 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 S1726673AbgB1KSE (ORCPT + 99 others); Fri, 28 Feb 2020 05:18:04 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:42457 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726714AbgB1KSD (ORCPT ); Fri, 28 Feb 2020 05:18:03 -0500 Received: by mail-pf1-f193.google.com with SMTP id 15so1483606pfo.9; Fri, 28 Feb 2020 02:18:03 -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=Zca5QT4St3KZ5ZG6XZtY4fdQBROyOfaj3q5el9kJMhI=; b=XNj6JUVtWIDfEPtD95xJxP/F0R3ayQmNhX2yyNOeTdMNFIwnSgGzWlFGddtMoQemyo kpFhWkZz2hPk19/Jiam/3ci1bNC2V2Mv8J4JN2UcKQE0EkNlh+rn4BS+Uv1JqwNfYl3F zrbNhTQTvx++vs91e2e6hiRgcGXFHDlowWVdWOeJ04TRmHvuKxvIaG0q38DGkwWkMds6 UgKAFIL9EJhyGcj/PFKOWP+scHGKV7WtCS0mwfSzTbLQMabzEausr2tldR+icbQcSXFB A2Qfxc8ctU0RXtJrTdgl5M4JmDeOGq8dYNTq3kvvLGloZc8fTen9S/lBMSn2Yj/Z80WE NnSw== 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=Zca5QT4St3KZ5ZG6XZtY4fdQBROyOfaj3q5el9kJMhI=; b=OWo194IezsPu1YKRts691fkdQxVBmbpTonwqmslCMr2j6xL4mdq+P6Kh3EEdWoCMQh SoX0JAcsYrXGyviRIrWDnNeqhIA7FZ22qY/7A49GeHT1pKQ9C1H5Y8+ydUtE422LIseD TJXgOpFyKo833ARO6D66c6lekHv9pASy5H04M6SVqS1OCucS5hoR+KMdIazXjKtSM+H/ 0KKkoYeiS4yiyVh58I3M2d7BItVpHe51Hx1ZcEi8xSwzwXd3UuswJp3yQrnRxr6+1pz/ pRhMbs6zmNnFvCH2g21vNSlwCw8CxBJwkEn9IjLCCZmmUkNVsBTfDOVA4HEbnShok4Lw zamQ== X-Gm-Message-State: APjAAAUcXupCo3SawSsPq9ju75fbCpDiEnQ7MX9ONov36Cl5um80cZY8 cOBD8fwKk+9yXBwqX9yaWqU= X-Received: by 2002:a63:1e06:: with SMTP id e6mr3994363pge.134.1582885082791; Fri, 28 Feb 2020 02:18:02 -0800 (PST) Received: from localhost.localdomain ([154.223.142.197]) by smtp.gmail.com with ESMTPSA id x65sm11190066pfb.171.2020.02.28.02.18.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 28 Feb 2020 02:18:02 -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 v2] NFS:remove redundant call to nfs_do_access Date: Fri, 28 Feb 2020 10:17:51 +0000 Message-Id: <1582885071-20641-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 The fast lookup in nfs_permission is done by calling nfs_do_access with or mask argument with MAY_NOT_BLOCK. However above predure is redundant: 1) when variable mask didn't have MAY_NOT_BLOCK bit, the fast-path part of nfs_do_access will be performed twice when missing the cache. 2) when variable mask have MAY_NOT_BLOCK bit, the second nfs_do_access will not be invoked at all. Also the rcu_read_lock and rcu_read_unlock is unnessarry because rcu critical data structure is already protected in nfs_access_get_cached_rcu. 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