NFS: Fix a readdir/lookup inefficiency.
authorTrond Myklebust <Trond.Myklebust@netapp.com>
Mon, 15 Jan 2007 18:56:29 +0000 (13:56 -0500)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Sat, 3 Feb 2007 23:35:04 +0000 (15:35 -0800)
Make sure that nfs_readdir_lookup() handles negative dentries correctly.
If d_lookup() returns a negative dentry, then we need to d_drop() that
since readdir shows that it should be positive.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
fs/nfs/dir.c

index bd269d2..db29c7f 100644 (file)
@@ -1123,8 +1123,14 @@ static struct dentry *nfs_readdir_lookup(nfs_readdir_descriptor_t *desc)
        }
        name.hash = full_name_hash(name.name, name.len);
        dentry = d_lookup(parent, &name);
-       if (dentry != NULL)
-               return dentry;
+       if (dentry != NULL) {
+               /* Is this a positive dentry? */
+               if (dentry->d_inode != NULL)
+                       return dentry;
+               /* No, so d_drop to allow one to be created */
+               d_drop(dentry);
+               dput(dentry);
+       }
        if (!desc->plus || !(entry->fattr->valid & NFS_ATTR_FATTR))
                return NULL;
        /* Note: caller is already holding the dir->i_mutex! */