Re: patch for fs/dcache race

Bill Hawes (whawes@star.net)
Sun, 10 Aug 1997 07:30:54 -0400


Linus Torvalds wrote:
> This shouldn't be a bug: when d_move() is called, the dentry count for the
> target must be non-zero, so shrink_dcache() will never look at the dentry
> any closer (certainly not the parent).
>
> So yes, there is a stale pointer, but it's never used, and it will be
> updated to the correct parent quickly.

I agree that the target dentry can't be freed, but the old parent may
have been released by the dput(). And since alloc_new_name may block,
the stale parent pointer may get used for the same reason parent
pointers ever get used -- an object linked to the target might want to
get a pathname, for instance.

> I guess I should rewrite d_move() to be more robust: there really isn't
> any reason for the stale parent pointer in the first place. (And while I
> don't think this is a bug, I certainly agree that it is very ugly).

I would like to see the new name allocation removed -- the new name
should be allocated by the client, so that the potential error can be
reported. Then if the new name is passed in as a reference to a dentry,
d_move can just steal the new name and swap the old name.

Regards,
Bill