All of lore.kernel.org
 help / color / mirror / Atom feed
* Question: When NFS client check dir's permission, it does not check the cache data
@ 2007-06-25  8:52 Wei Yongjun
  2007-06-25 18:09 ` Muntz, Daniel
  2007-06-25 20:08 ` Trond Myklebust
  0 siblings, 2 replies; 10+ messages in thread
From: Wei Yongjun @ 2007-06-25  8:52 UTC (permalink / raw)
  To: nfs

Hello, everyone
 When I test NFS client, I found a poblem that, if a dir we do not have 
permission to write, it will let the server to check permissions when we 
perform the write op.
This is comment by source code:
  * Optimize away all write operations, since the server
  * will check permissions when we perform the op.
In my test, the process is like following:
#touch dir/file
NFS Server                         NFS Client
                       <----------      lookup (dir)
lookup ok      ------------->
                       <----------      access (dir)   (*1)
access(read only)   -----------> 
                       <----------      lookup (file)
lookup(NOENT)     ------------->
                       <----------      create (file)  (*2)
create(NOPERM)     ------------->

(*1)
First to check the permissions of that dir ,and will be add to cache data.
(*2)
Since the Client had known the permission of the dir, why no used it? 
Does this effect to NFS client's performance?
Maybe we can check the cache first, if it not exists, then let the 
server to check permissions when we perform the write op.
Is this better? Maybe code looks like following(not an useable patch):

--- fs/nfs/dir.c.orig	2007-06-12 02:37:06.000000000 +0800
+++ fs/nfs/dir.c	2007-06-25 16:26:03.000000000 +0800
@@ -1936,6 +1936,14 @@ static int nfs_do_access(struct inode *i
        ...
	status = nfs_access_get_cached(inode, cred, &cache);
 	if (status == 0)
 		goto out;
 
+	/*
+	 * Optimize away all write operations, since the server
+	 * will check permissions when we perform the op.
+	 */
+	if(((inode->i_mode & S_IFMT) == S_IFDIR) 
+		&& (mask & MAY_WRITE) && !(mask & MAY_READ))
+		return 0;
+
 	/* Be clever: ask server to check for all possible rights */
 	cache.mask = MAY_EXEC | MAY_WRITE | MAY_READ;
 	cache.cred = cred;
@@ -1973,13 +1981,6 @@ int nfs_permission(struct inode *inode, 
 					&& (nd->flags & LOOKUP_OPEN))
 				goto out;
 			break;
-		case S_IFDIR:
-			/*
-			 * Optimize away all write operations, since the server
-			 * will check permissions when we perform the op.
-			 */
-			if ((mask & MAY_WRITE) && !(mask & MAY_READ))
-				goto out;
 	}
 
 force_lookup:






-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
NFS maillist  -  NFS@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nfs

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2007-07-26 16:26 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-25  8:52 Question: When NFS client check dir's permission, it does not check the cache data Wei Yongjun
2007-06-25 18:09 ` Muntz, Daniel
2007-06-25 20:08 ` Trond Myklebust
2007-06-27  1:24   ` Wei Yongjun
2007-06-27  3:09     ` Trond Myklebust
2007-06-27  5:22       ` Wei Yongjun
2007-06-27 14:25         ` Trond Myklebust
2007-06-28  3:06           ` Wei Yongjun
2007-07-26  5:12             ` Wei Yongjun
2007-07-26 16:26               ` Trond Myklebust

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.