WSL2-Linux-Kernel/Documentation/filesystems/nfs
Jeff Layton 7f84b488f9 nfsd: close cached files prior to a REMOVE or RENAME that would replace target
It's not uncommon for some workloads to do a bunch of I/O to a file and
delete it just afterward. If knfsd has a cached open file however, then
the file may still be open when the dentry is unlinked. If the
underlying filesystem is nfs, then that could trigger it to do a
sillyrename.

On a REMOVE or RENAME scan the nfsd_file cache for open files that
correspond to the inode, and proactively unhash and put their
references. This should prevent any delete-on-last-close activity from
occurring, solely due to knfsd's open file cache.

This must be done synchronously though so we use the variants that call
flush_delayed_fput. There are deadlock possibilities if you call
flush_delayed_fput while holding locks, however. In the case of
nfsd_rename, we don't even do the lookups of the dentries to be renamed
until we've locked for rename.

Once we've figured out what the target dentry is for a rename, check to
see whether there are cached open files associated with it. If there
are, then unwind all of the locking, close them all, and then reattempt
the rename.

None of this is really necessary for "typical" filesystems though. It's
mostly of use for NFS, so declare a new export op flag and use that to
determine whether to close the files beforehand.

Signed-off-by: Jeff Layton <jeff.layton@primarydata.com>
Signed-off-by: Lance Shelton <lance.shelton@hammerspace.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
2020-12-09 09:39:38 -05:00
..
exporting.rst nfsd: close cached files prior to a REMOVE or RENAME that would replace target 2020-12-09 09:39:38 -05:00
index.rst Documentation: nfs: knfsd-stats: convert to ReST 2020-02-13 11:21:35 -07:00
knfsd-stats.rst Documentation: nfs: knfsd-stats: convert to ReST 2020-02-13 11:21:35 -07:00
nfs41-server.rst Documentation: nfs: nfs41-server: convert to ReST 2020-02-13 11:21:31 -07:00
pnfs.rst Documentation: nfs: convert pnfs.txt to ReST 2020-02-13 11:21:08 -07:00
rpc-cache.rst Documentation: nfs: rpc-cache: convert to ReST 2020-02-13 11:21:23 -07:00
rpc-server-gss.rst Documentation: update RPCSEC_GSSv3 RFC link 2020-09-25 18:01:27 -04:00