Is it valid to call d_add on a negative dentry?
(or on a dentry that is already linked in d_hash, but all negative
dentries are, right?)
I'm guessing it isn't because I think that is how I can get my machine to
hang in d_lookup, looping on a corrupt d_hash list.
The problem can be reproduced like this. /mnt/smb is a smbfs mount of
/mnt/samba/export from a samba server on localhost.
/mnt/smb% ls
aa
/mnt/smb% rm aa
/mnt/smb% touch /mnt/samba/export/aa
/mnt/smb% ls
ls: aa: No such file or directory
And shortly after it will lock up completely.
My printk's tell me that a negative dentry is still hashed since d_hash is
non-empty. d_add calls d_instantiate and d_rehash, the later adds it to a
d_hash list without first removing it. But it was already linked so now 2
extra dentries are also pointing to this dentry. And it is then no longer
a list ...
The attached patch fixes things for me. Comments?
Oh, and I *think* ncpfs has the same problem. But that's just from reading
the code.
/Urban
On Tue, 6 Mar 2001, Urban Widmark wrote:
>
> Is it valid to call d_add on a negative dentry?
> (or on a dentry that is already linked in d_hash, but all negative
> dentries are, right?)
Not all of them. It _is_ legal to do d_add() on a negative dentry.
Doing that for hashed dentries is a bug. Use d_instantiate() instead.
Cheers,
Al
PS: as for the patch, better make it
d_instantiate(...);
if (!hashed)
d_rehash(...);
On 5 Mar 01 at 18:08, Alexander Viro wrote:
> On Tue, 6 Mar 2001, Urban Widmark wrote:
>
> >
> > Is it valid to call d_add on a negative dentry?
> > (or on a dentry that is already linked in d_hash, but all negative
> > dentries are, right?)
>
> Not all of them. It _is_ legal to do d_add() on a negative dentry.
> Doing that for hashed dentries is a bug. Use d_instantiate() instead.
> Cheers,
> Al
>
> PS: as for the patch, better make it
> d_instantiate(...);
> if (!hashed)
> d_rehash(...);
It could explain why I'm getting once a month CPU spinning in d_lookup()
because of some circular list is no more one circle...
Many thanks, I'll apply it to ncpfs ASAP.
Best regards,
Petr Vandrovec
[email protected]