diff mbox series

[v2] NFS:remove redundant call to nfs_do_access

Message ID 1582885071-20641-1-git-send-email-zhouzhouyi@gmail.com (mailing list archive)
State New, archived
Headers show
Series [v2] NFS:remove redundant call to nfs_do_access | expand

Commit Message

Zhouyi Zhou Feb. 28, 2020, 10:17 a.m. UTC
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 

Tested in x86_64 
Signed-off-by: Zhouyi Zhou <zhouzhouyi@gmail.com>
 fs/nfs/dir.c |    9 +--------
 1 files changed, 1 insertions(+), 8 deletions(-)
diff mbox series


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);
 	if (!res && (mask & MAY_EXEC))
 		res = nfs_execute_ok(inode, mask);