Re: BUG_ON(nd->inode != parent->d_inode);

From: Linus Torvalds
Date: Fri Mar 08 2013 - 14:48:01 EST


On Fri, Mar 8, 2013 at 11:36 AM, Dave Jones <davej@xxxxxxxxxx> wrote:
>
> I changed it to do this..
>
> diff --git a/fs/namei.c b/fs/namei.c
> index 961bc12..c1ca29e 100644
> --- a/fs/namei.c
> +++ b/fs/namei.c
> @@ -689,8 +689,6 @@ void nd_jump_link(struct nameidata *nd, struct path *path)
> nd->path = *path;
> nd->inode = nd->path.dentry->d_inode;
> nd->flags |= LOOKUP_JUMPED;
> -
> - BUG_ON(nd->inode->i_op->follow_link);
> }
>
> static inline void put_link(struct nameidata *nd, struct path *link, void *cookie)
> @@ -1438,7 +1436,13 @@ static int lookup_slow(struct nameidata *nd, struct path *path)
> int err;
>
> parent = nd->path.dentry;
> - BUG_ON(nd->inode != parent->d_inode);
> +
> + if (WARN_ON(nd->inode != parent->d_inode)) {
> + printk("%s -> %p (%s)\n", parent->d_name.name, path->dentry, nd->last.name);
> + return -EINVAL;
> + }

Ok, it might be nice to print out the path dentry name if it has one,
but it may well be that this only happens with negative dentries in
proc or sysfs, since you said that you just added testing of that..

> And now I'm getting a different BUG_ON

Heh. It's the same BUG_ON(), it's just replicated (and "parent" is
called "dir" here).

Maybe you can make the WARN_ON_ONCE() version be a macro, because that
test exists in multiple places: unlazy_walk, complete_walk,
lookup_slow and do_last (and walk_component in a different guise).

Linus
--
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/