linux/Documentation/filesystems/nfs
NeilBrown f1ee616214 VFS: don't keep disconnected dentries on d_anon
The original purpose of the per-superblock d_anon list was to
keep disconnected dentries in the cache between consecutive
requests to the NFS server.  Dentries can be disconnected if
a client holds a file open and repeatedly performs IO on it,
and if the server drops the dentry, whether due to memory
pressure, server restart, or "echo 3 > /proc/sys/vm/drop_caches".

This purpose was thwarted by commit 75a6f82a0d ("freeing unlinked
file indefinitely delayed") which caused disconnected dentries
to be freed as soon as their refcount reached zero.

This means that, when a dentry being used by nfsd gets disconnected, a
new one needs to be allocated for every request (unless requests
overlap).  As the dentry has no name, no parent, and no children,
there is little of value to cache.  As small memory allocations are
typically fast (from per-cpu free lists) this likely has little cost.

This means that the original purpose of s_anon is no longer relevant:
there is no longer any need to keep disconnected dentries on a list so
they appear to be hashed.

However, s_anon now has a new use.  When you mount an NFS filesystem,
the dentry stored in s_root is just a placebo.  The "real" root dentry
is allocated using d_obtain_root() and so it kept on the s_anon list.
I don't know the reason for this, but suspect it related to NFSv4
where a mount of "server:/some/path" require NFS to look up the root
filehandle on the server, then walk down "/some" and "/path" to get
the filehandle to mount.

Whatever the reason, NFS depends on the s_anon list and on
shrink_dcache_for_umount() pruning all dentries on this list.  So we
cannot simply remove s_anon.

We could just leave the code unchanged, but apart from that being
potentially confusing, the (unfair) bit-spin-lock which protects
s_anon can become a bottle neck when lots of disconnected dentries are
being created.

So this patch renames s_anon to s_roots, and stops storing
disconnected dentries on the list.  Only dentries obtained with
d_obtain_root() are now stored on this list.  There are many fewer of
these (only NFS and NILFS2 use the call, and only during filesystem
mount) so contention on the bit-lock will not be a problem.

Possibly an alternate solution should be found for NFS and NILFS2, but
that would require understanding their needs first.

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
2017-12-25 20:22:07 -05:00
..
00-INDEX Documentation/: update 00-INDEX files 2014-02-10 16:01:40 -08:00
Exporting VFS: don't keep disconnected dentries on d_anon 2017-12-25 20:22:07 -05:00
fault_injection.txt Doc: nfs: Fix typos in Documentation/filesystems/nfs 2016-03-09 16:13:04 -07:00
idmapper.txt doc: ReSTify keys-request-key.txt 2017-05-18 10:33:51 -06:00
knfsd-stats.txt Documentation: remove overloads-avoided counter from knfsd-stats.txt 2015-05-04 12:02:44 -04:00
nfs41-server.txt nfsd: update documentation for pNFS support 2015-02-02 18:09:43 +01:00
nfs-rdma.txt Documentation: Fix dead URLs to ftp.kernel.org 2017-03-29 15:46:06 -06:00
nfs.txt NFS: Add nfs4_unique_id boot parameter 2012-10-01 15:33:33 -07:00
nfsd-admin-interfaces.txt nfsd: document kernel interfaces for nfsd configuration 2012-08-21 17:42:03 -04:00
nfsroot.txt docs: fix locations of several documents that got moved 2016-10-24 08:12:35 -02:00
pnfs-block-server.txt nfsd: pNFS block layout driver 2015-02-05 14:35:18 +01:00
pnfs-scsi-server.txt nfsd: add SCSI layout support 2016-03-18 11:42:53 -04:00
pnfs.txt nfs: remove the objlayout driver 2017-04-20 15:51:23 -04:00
rpc-cache.txt
rpc-server-gss.txt Doc: nfs: Fix typos in Documentation/filesystems/nfs 2016-03-09 16:13:04 -07:00