linux/fs/nfsd
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
..
acl.h nfsd: eliminate an unnecessary acl size limit 2019-08-28 21:13:45 -04:00
auth.c nfsd: auth: Fix gid sorting when rootsquash enabled 2018-01-22 20:13:07 -08:00
auth.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
blocklayout.c block: add a bdev_is_partition helper 2020-09-25 08:18:57 -06:00
blocklayoutxdr.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
blocklayoutxdr.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
cache.h nfsd4: make drc_slab global, not per-net 2020-06-01 17:44:45 -04:00
current_stateid.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
export.c nfsd: allow filesystems to opt out of subtree checking 2020-12-09 09:39:38 -05:00
export.h knfsd: Allow lockless lookups of the exports 2018-10-29 16:58:04 -04:00
fault_inject.c nfsd: no need to check return value of debugfs_create functions 2019-07-03 16:57:17 +02:00
filecache.c nfsd: Fix error return code in nfsd_file_cache_init() 2020-11-30 14:45:56 -05:00
filecache.h nfsd: convert file cache to use over/underflow safe refcount 2020-02-06 11:22:55 -05:00
flexfilelayout.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
flexfilelayoutxdr.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
flexfilelayoutxdr.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
idmap.h nfsd: Remove duplicate define of IDMAP_NAMESZ/IDMAP_TYPE_xx 2015-07-20 14:58:46 -04:00
Kconfig NFSv4.2: Fix NFS4ERR_STALE error when doing inter server copy 2020-10-21 10:31:20 -04:00
lockd.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
Makefile nfsd: remove fault injection code 2020-09-25 18:01:26 -04:00
netns.h nfsd: netns.h: delete a duplicated word 2020-07-24 17:25:13 -04:00
nfs2acl.c NFSD: Add common helpers to decode void args and encode void results 2020-11-30 14:46:35 -05:00
nfs3acl.c NFSD: Add common helpers to decode void args and encode void results 2020-11-30 14:46:35 -05:00
nfs3proc.c NFSD: Add common helpers to decode void args and encode void results 2020-11-30 14:46:35 -05:00
nfs3xdr.c nfsd: add a new EXPORT_OP_NOWCC flag to struct export_operations 2020-12-09 09:39:38 -05:00
nfs4acl.c nfsd: check permissions when setting ACLs 2016-06-24 12:11:52 -04:00
nfs4callback.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
nfs4idmap.c nfsd: Use seq_putc() in two functions 2020-07-13 17:28:46 -04:00
nfs4layouts.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
nfs4proc.c NFSD: Fix sparse warning in nfs4proc.c 2020-12-09 09:38:34 -05:00
nfs4recover.c nfsd: avoid a NULL dereference in __cld_pipe_upcall() 2020-07-13 17:28:46 -04:00
nfs4state.c NFSD: Fix 5 seconds delay when doing inter server copy 2020-12-09 09:38:34 -05:00
nfs4xdr.c Revert "nfsd4: support change_attr_type attribute" 2020-12-09 09:39:38 -05:00
nfscache.c silence nfscache allocation warnings with kvzalloc 2020-09-25 18:01:28 -04:00
nfsctl.c nfsd: remove fault injection code 2020-09-25 18:01:26 -04:00
nfsd.h Revert "nfsd4: support change_attr_type attribute" 2020-12-09 09:39:38 -05:00
nfsfh.c nfsd: add a new EXPORT_OP_NOWCC flag to struct export_operations 2020-12-09 09:39:38 -05:00
nfsfh.h nfsd: add a new EXPORT_OP_NOWCC flag to struct export_operations 2020-12-09 09:39:38 -05:00
nfsproc.c NFSD: Add common helpers to decode void args and encode void results 2020-11-30 14:46:35 -05:00
nfssvc.c nfsd: Fix message level for normal termination 2020-12-09 09:38:33 -05:00
nfsxdr.c NFSD: Add common helpers to decode void args and encode void results 2020-11-30 14:46:35 -05:00
pnfs.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
state.h nfsd: remove fault injection code 2020-09-25 18:01:26 -04:00
stats.c proc: convert everything to "struct proc_ops" 2020-02-04 03:05:26 +00:00
stats.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
trace.c NFSD: Add SPDX header for fs/nfsd/trace.c 2020-11-30 13:00:24 -05:00
trace.h NFSD: Add tracepoints in nfsd4_decode/encode_compound() 2020-11-30 14:46:35 -05:00
vfs.c nfsd: close cached files prior to a REMOVE or RENAME that would replace target 2020-12-09 09:39:38 -05:00
vfs.h nfsd: define xattr functions to call into their vfs counterparts 2020-07-13 17:27:03 -04:00
xdr.h NFSD: Add common helpers to decode void args and encode void results 2020-11-30 14:46:35 -05:00
xdr3.h NFSD: Add common helpers to decode void args and encode void results 2020-11-30 14:46:35 -05:00
xdr4.h nfsd: simplify nfsd4_change_info 2020-12-09 09:39:37 -05:00
xdr4cb.h NFSD CB_OFFLOAD xdr 2018-09-25 20:34:54 -04:00