Re: [PATCH] NFS: Replace null dentries that appear in readdir's list

Ian Kent
2006-08-18T01:00:16Z

On Wed, 2006-08-16 at 17:15 +0100, David Howells wrote:

> fs/nfs/dir.c | 9 +++++++--
> 1 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
> index e746ed1..bb8b5f0 100644
> --- a/fs/nfs/dir.c
> +++ b/fs/nfs/dir.c
> @@ -1105,8 +1105,13 @@ static struct dentry *nfs_readdir_lookup
> }
> name.hash = full_name_hash(name.name, name.len);
> dentry = d_lookup(parent, &name);

And there's no dput for this gotten dentry.

> - if (dentry != NULL)
> - return dentry;
> + if (dentry != NULL) {
> + /* negative dentries must be reconsidered */
> + if (!IS_ERR(dentry) && !dentry->d_inode)
> + d_drop(dentry);
> + else
> + return dentry;
> + }
> if (!desc->plus || !(entry->fattr->valid & NFS_ATTR_FATTR))
> return NULL;
> /* Note: caller is already holding the dir->i_mutex! */

Sorry I didn't look at this more closely earlier.

Just looking at this function alone it looks to me like it is
essentially part of a dentry instantiation which would mean a negative
dentry is perfectly valid at the point above.

Ian