Re: processes hung after sys_renameat, and 'missing' processes

From: Linus Torvalds
Date: Thu Jun 07 2012 - 11:44:25 EST


On Thu, Jun 7, 2012 at 12:07 AM, Miklos Szeredi <miklos@xxxxxxxxxx> wrote:
>
> Yeah, see the comment in below patch for how it's supposed to work.  I
> *think* it's correct.

Ok, yes, that makes me happier.

What would make me happier still is to get rid of the "save_parent"
thing entirely, though.

And I think you should be able to.

Why?

You already have the rule that:
- save_parent.mnt is always same as "path->mnt" (or NULL, if not saved)
- save_parent.dentry is the same as "dir" when you use it (you have a
BUG_ON() for it not being the same)
- you currently use "save_parent.dentry != NULL" as a flag to say "do
we have the valid state"

So as far as I can tell, you should get rid of all the refcount games
and the "struct path save_parent", and just replace the
"save_parent.dentry != NULL" thing with a flag of whether you have a
valid state.

That would get rid of the whole

if ((nd->flags & LOOKUP_RCU) || nd->path.mnt != path->mnt) {
path_to_nameidata(path, nd);
} else {
save_parent.dentry = nd->path.dentry;
save_parent.mnt = mntget(path->mnt);
nd->path.dentry = path->dentry;

}

thing, and we could just have the old simple unconditional

path_to_nameidata(path, nd);

back.

And then you'd have

if (filp == ERR_PTR(-EOPENSTALE) && save_parent_flag && !retried) {
dput(nd->path.dentry);
nd->path.dentry = dget(dir);
nd->inode = dir->d_inode;
save_parent_flag = false;
if (want_write) {
mnt_drop_write(nd->path.mnt);
want_write = 0;
}
retried = true;
goto retry_lookup;

or something for the EOPENSTALE thing. That would get all the
save_parent refcount games out of the normal path.

Am I missing some reason why that wouldn't work?

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/