[PATCH] Fix disconnected dentries on NFS exports
A disconnected dentry can hold an inode active after the last link has
been removed. The file will not then be truncated and removed until
memory pressure flushes the disconnected dentry from the dcache.
This problem can be resolved by making sure that an inode never has
both a connected and a disconnected dentry.
This is already the case for directories (as they must only have one
dentry), but it is not the case for non-directories.
This addresses it by:
- changes d_alloc_anon to make sure that a new disconnected dentry is
only allocated if there is currently no (hashed) dentry for the
inode. (Previously this would noramlly be true, but a race was
possible).
- changes d_splice_alias to re-use a disconnected dentry on
non-directories as well as directories.
- splits most of d_find_alias out into a separate function to make
the above easier.
Problem originally reported by Nikita Danilov.
Acked by Al Viro ("It looks sane"), and Jakob Oestergaard reports this
fixes his problems. Further pushed by Christoph Hellwig.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Showing
Please register or sign in to comment