[linux-cifs-client] [CIFS] One more posix open patch on the way

Steve French smfrench at gmail.com
Sat May 23 02:28:50 GMT 2009


One small additional fix to posix open is being reviewed to address
something Jeff and JRA noticed this morning.

After discussion today on samba-technical about the posix lookup open
regression,  and looking at a problem with cifs posix open to one
particular Samba version, Jeff and JRA realized that Samba server's
behavior changed in this area (posix open behavior on files vs.
directories) too.   To make this behavior consistent, JRA just made a
fix to Samba server to alter how it handles open of directories (now
returning the equivalent of EISDIR instead of success). Since we don't
know at lookup time whether the inode is a directory or file (and thus
whether posix open will succeed with most current Samba server), I am
testing a change which avoids the posix open code on lookup open (just
issues posix open on creates).    This gets the semantic benefits we
want (posix byte range locks, improved write semantics etc. on newly
created files) and file create still is fast, and we avoid the problem
that Jeff noticed this morning with "openat" (and some open directory
calls) of non-cached directories to one version of Samba server, and
will work with future Samba versions (which include the fix jra just
pushed into Samba server).

The small fix attached (or something like it), is a mustfix before
2.6.30 goes out, but want to give Shirish, and Jeff time to look at
it.  The main part (other than a trivial rc mapping change) is this
change to cifs_lookup

diff --git a/fs/cifs/dir.c b/fs/cifs/dir.c
index f49d684..c306d3f 100644
--- a/fs/cifs/dir.c
+++ b/fs/cifs/dir.c
@@ -660,8 +660,16 @@ cifs_lookup(struct inode *parent_dir_inode,
struct dentry *direntry,
 	if (pTcon->unix_ext) {
 		if (!(nd->flags & (LOOKUP_PARENT | LOOKUP_DIRECTORY)) &&
 		     (nd->flags & LOOKUP_OPEN) && !pTcon->broken_posix_open) {
-			if (!((nd->intent.open.flags & O_CREAT) &&
-					(nd->intent.open.flags & O_EXCL))) {
+			if (nd->intent.open.flags & O_CREAT) {
+				/* POSIX open here is only called for file
+				   create. It does not help much for file opens
+				   because we do not know if it is a file
+				   or directory, and current Samba no
+				   longer allows us to do posix open on dirs,
+				   so we could end up wasting an open
+				   call on what turns out to be a dir.
+				   For file opens, we call posix open
+				   in cifs_open */
 				rc = cifs_posix_open(full_path, &newInode,
 					parent_dir_inode->i_sb,
 					nd->intent.open.create_mode,
-- 
Thanks,

Steve
-------------- next part --------------
A non-text attachment was scrubbed...
Name: posix-open-only-on-create-and-fix-isdir-error-mapping.patch
Type: text/x-diff
Size: 2232 bytes
Desc: not available
Url : http://lists.samba.org/archive/linux-cifs-client/attachments/20090522/8f42fec1/posix-open-only-on-create-and-fix-isdir-error-mapping-0001.bin


More information about the linux-cifs-client mailing list