[PATCH 5/8] NFS: teach nfs_do_access to understand MAY_NOT_BLOCK

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If MAY_NOT_BLOCK is set we return -ECHILD in preference to making a
network call.
This allows nfs_permission to call it in RCU-walk mode.

Now nfs_permission() can often complete in RCU-walk mode with no error.

Signed-off-by: NeilBrown <neilb@xxxxxxx>
---
 fs/nfs/dir.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 36e12f545fd7..f3895325ac6a 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -2232,6 +2232,10 @@ static int nfs_do_access(struct inode *inode, struct rpc_cred *cred, int mask)
 	if (status == 0)
 		goto out_cached;
 
+	status = -ECHILD;
+	if (mask & MAY_NOT_BLOCK)
+		goto out;
+
 	/* Be clever: ask server to check for all possible rights */
 	cache.mask = MAY_EXEC | MAY_WRITE | MAY_READ;
 	cache.cred = cred;
@@ -2311,10 +2315,9 @@ force_lookup:
 
 	cred = rpc_lookup_cred(mask & MAY_NOT_BLOCK);
 	if (!IS_ERR(cred)) {
-		if (mask & MAY_NOT_BLOCK)
-			return -ECHILD;
 		res = nfs_do_access(inode, cred, mask);
-		put_rpccred(cred);
+		if (!(mask & MAY_NOT_BLOCK))
+			put_rpccred(cred);
 	} else
 		res = PTR_ERR(cred);
 out:


--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux