diff mbox

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

Message ID 20140305030028.27421.27775.stgit@notabene.brown (mailing list archive)
State New, archived
Headers show

Commit Message

NeilBrown March 5, 2014, 3 a.m. UTC
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@suse.de>
---
 fs/nfs/dir.c |    9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)



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

Patch

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: