Re: [PATCH] fs: pipe/sockets/anon dentries should have themselves as parent

From: Matthew Wilcox
Date: Fri Nov 21 2008 - 13:44:21 EST


On Fri, Nov 21, 2008 at 06:58:29PM +0100, Eric Dumazet wrote:
> +/**
> + * d_alloc_unhashed - allocate unhashed dentry
> + * @inode: inode to allocate the dentry for
> + * @name: dentry name

It's normal to list the parameters in the order they're passed to the
function. Not sure if we have a tool that checks for this or not --
Randy?

> + *
> + * Allocate an unhashed dentry for the inode given. The inode is
> + * instantiated and returned. %NULL is returned if there is insufficient
> + * memory. Unhashed dentries have themselves as a parent.
> + */
> +
> +struct dentry * d_alloc_unhashed(const char *name, struct inode *inode)
> +{
> + struct qstr q = { .name = name, .len = strlen(name) };
> + struct dentry *res;
> +
> + res = d_alloc(NULL, &q);
> + if (res) {
> + res->d_sb = inode->i_sb;
> + res->d_parent = res;
> + /*
> + * We dont want to push this dentry into global dentry hash table.
> + * We pretend dentry is already hashed, by unsetting DCACHE_UNHASHED
> + * This permits a working /proc/$pid/fd/XXX on sockets,pipes,anon
> + */

Line length ... as checkpatch would have warned you ;-)

And there are several other grammatical nitpicks with this comment. Try
this:

/*
* We don't want to put this dentry in the global dentry
* hash table, so we pretend the dentry is already hashed
* by unsetting DCACHE_UNHASHED. This permits
* /proc/$pid/fd/XXX t work for sockets, pipes and
* anonymous files (signalfd, timerfd, etc).
*/

> + res->d_flags &= ~DCACHE_UNHASHED;
> + res->d_flags |= DCACHE_DISCONNECTED;

Is this really better than:

res->d_flags = res->d_flags & ~DCACHE_UNHASHED |
DCACHE_DISCONNECTED;

Anyway, nice cleanup.

--
Matthew Wilcox Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours. We can't possibly take such
a retrograde step."
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/