Re: [PATCH] dcache: separate slab for directory dentries

Dave Kleikamp
2005-10-06T12:27:09Z

On Thu, 2005-10-06 at 16:27 +1000, David Chinner wrote:
> +/*
> + * If the given dentry is not suitable for the inode, reallocate
> + * it, copy across the dentry's data and return the new one. Only
> + * useful when the dentry has not yet been attached to inode or
> + * hashed, which is why it's a lot simpler than d_move(). Returns
> + * NULL if the dentry is suitable, Called with dcache_lock, drops
> + * and regains.
> + */
> +static struct dentry * d_realloc_for_inode(struct dentry * dentry,
> + struct inode *inode)
> +{
> + int flags = 0;
> + struct dentry *new;
> + struct dentry *parent;
> +
> + BUG_ON(dentry == NULL);
> + BUG_ON(dentry->d_inode != NULL);
> + BUG_ON(inode == NULL);
> + BUG_ON(dentry->d_parent == NULL || dentry->d_parent == dentry);
> +
> + if (S_ISDIR(inode->i_mode))
> + flags |= DCACHE_DIRSLAB;
> + if ((flags & DCACHE_DIRSLAB) == (dentry->d_flags & DCACHE_DIRSLAB))
> + return NULL; /* dentry is suitable */
> +
> + parent = dentry->d_parent;
> + list_del_init(&dentry->d_child);
> +
> + spin_unlock(&dcache_lock);
> +
> + new = __d_alloc(parent, &dentry->d_name, dentry->d_flags | flags);
> +
> + spin_lock(&dcache_lock);
> +
> + BUG_ON(new == NULL); /* TODO */
> + if (new) {
> +// new->d_op = dentry->d_op;
> +// new->d_fsdata = dentry->d_fsdata;
> + }
> +
> + return new;
> +}

Isn't this leaking the original dentry? Shouldn't it be doing a dput or
at least a d_free here?
--
David Kleikamp
IBM Linux Technology Center