J. Bruce Fields d891eedbc3 fs/dcache: allow d_obtain_alias() to return unhashed dentries
Without this patch, inodes are not promptly freed on last close of an
unlinked file by an nfs client:

	client$ mount -tnfs4 server:/export/ /mnt/
	client$ tail -f /mnt/FOO
	...
	server$ df -i /export
	server$ rm /export/FOO
	(^C the tail -f)
	server$ df -i /export
	server$ echo 2 >/proc/sys/vm/drop_caches
	server$ df -i /export

the df's will show that the inode is not freed on the filesystem until
the last step, when it could have been freed after killing the client's
tail -f. On-disk data won't be deallocated either, leading to possible
spurious ENOSPC.

This occurs because when the client does the close, it arrives in a
compound with a putfh and a close, processed like:

	- putfh: look up the filehandle.  The only alias found for the
	  inode will be DCACHE_UNHASHED alias referenced by the filp
	  this, so it creates a new DCACHE_DISCONECTED dentry and
	  returns that instead.
	- close: closes the existing filp, which is destroyed
	  immediately by dput() since it's DCACHE_UNHASHED.
	- end of the compound: release the reference
	  to the current filehandle, and dput() the new
	  DCACHE_DISCONECTED dentry, which gets put on the
	  unused list instead of being destroyed immediately.

Nick Piggin suggested fixing this by allowing d_obtain_alias to return
the unhashed dentry that is referenced by the filp, instead of making it
create a new dentry.

Leave __d_find_alias() alone to avoid changing behavior of other
callers.

Also nfsd doesn't need all the checks of __d_find_alias(); any dentry,
hashed or unhashed, disconnected or not, should work.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2011-03-10 05:18:54 -05:00
..
2011-01-12 20:03:43 -05:00
2011-01-12 20:02:45 -05:00
2011-01-12 20:03:42 -05:00
2011-02-25 11:12:37 -08:00
2011-01-07 17:50:26 +11:00
2011-02-21 22:31:47 +00:00
2010-10-29 04:16:28 -04:00
2010-10-29 04:16:28 -04:00
2011-02-11 16:50:47 -06:00
2011-01-07 17:50:26 +11:00
2011-03-03 01:28:17 -05:00
2011-01-07 17:50:26 +11:00
2011-01-14 09:23:36 -08:00
2011-01-12 20:03:42 -05:00
2011-01-07 17:50:26 +11:00
2011-01-07 17:50:26 +11:00
2011-01-12 20:02:43 -05:00
2011-03-03 01:28:16 -05:00
2011-03-08 19:46:10 -05:00
2010-10-29 04:16:13 -04:00
2011-01-07 17:50:26 +11:00
2011-01-07 17:50:26 +11:00
2010-10-29 04:16:31 -04:00
2011-01-07 17:50:26 +11:00
2011-03-03 01:28:16 -05:00
2011-01-07 17:50:26 +11:00
2011-03-03 01:28:40 -05:00
2011-03-03 01:28:16 -05:00
2011-01-13 08:03:12 -08:00
2010-10-29 04:16:28 -04:00
2011-02-02 16:03:19 -08:00
2011-02-02 16:03:19 -08:00
2010-10-15 15:53:27 +02:00
2011-01-07 17:50:27 +11:00
2010-10-28 09:44:56 -07:00
2011-01-13 17:32:32 -08:00
2011-02-24 02:10:57 -05:00
2011-01-07 17:50:33 +11:00
2010-08-09 16:48:44 -04:00
2010-08-09 16:47:43 -04:00