]> git.hungrycats.org Git - linux/commitdiff
NFSv4: Optimizing away the case of negative dentries in
authorTrond Myklebust <trond.myklebust@fys.uio.no>
Mon, 23 Aug 2004 14:06:32 +0000 (10:06 -0400)
committerTrond Myklebust <trond.myklebust@fys.uio.no>
Mon, 23 Aug 2004 14:06:32 +0000 (10:06 -0400)
   nfs_open_revalidate() avoids several atomicity problems.

Signed-off-by: Trond Myklebust <trond.myklebust@fys.uio.no>
fs/nfs/dir.c

index ba5171f147c560ce5c6e089be732184c2b3eb19d..b8f4be07de641983a23836e41575d61dfdf7742b 100644 (file)
@@ -850,22 +850,22 @@ static int nfs_open_revalidate(struct dentry *dentry, struct nameidata *nd)
        unsigned long verifier;
        int openflags, ret = 0;
 
-       /* NFS only supports OPEN for regular files */
-       if (inode && !S_ISREG(inode->i_mode))
-               goto no_open;
        parent = dget_parent(dentry);
        dir = parent->d_inode;
        if (!is_atomic_open(dir, nd))
                goto no_open;
+       /* We can't create new files in nfs_open_revalidate(), so we
+        * optimize away revalidation of negative dentries.
+        */
+       if (inode == NULL)
+               goto out;
+       /* NFS only supports OPEN on regular files */
+       if (!S_ISREG(inode->i_mode))
+               goto no_open;
        openflags = nd->intent.open.flags;
-       if (openflags & O_CREAT) {
-               /* If this is a negative dentry, just drop it */
-               if (!inode)
-                       goto out;
-               /* If this is exclusive open, just revalidate */
-               if (openflags & O_EXCL)
-                       goto no_open;
-       }
+       /* We cannot do exclusive creation on a positive dentry */
+       if ((openflags & (O_CREAT|O_EXCL)) == (O_CREAT|O_EXCL))
+               goto no_open;
        /* We can't create new files, or truncate existing ones here */
        openflags &= ~(O_CREAT|O_TRUNC);