diff options
author | Jeff Layton <jeff.layton@primarydata.com> | 2020-11-30 17:03:16 -0500 |
---|---|---|
committer | Chuck Lever <chuck.lever@oracle.com> | 2020-12-09 09:39:38 -0500 |
commit | 7f84b488f9add1d5cca3e6197c95914c7bd3c1cf (patch) | |
tree | fe4616aeb70a824182f6fecd22a8ef6c38786ad7 /fs/nfs/export.c | |
parent | ba5e8187c55555519ae0b63c0fb681391bc42af9 (diff) | |
download | linux-rpi-7f84b488f9add1d5cca3e6197c95914c7bd3c1cf.tar.gz linux-rpi-7f84b488f9add1d5cca3e6197c95914c7bd3c1cf.tar.bz2 linux-rpi-7f84b488f9add1d5cca3e6197c95914c7bd3c1cf.zip |
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>
Diffstat (limited to 'fs/nfs/export.c')
-rw-r--r-- | fs/nfs/export.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/nfs/export.c b/fs/nfs/export.c index b9ba306bf912..5428713af5fe 100644 --- a/fs/nfs/export.c +++ b/fs/nfs/export.c @@ -171,5 +171,5 @@ const struct export_operations nfs_export_ops = { .encode_fh = nfs_encode_fh, .fh_to_dentry = nfs_fh_to_dentry, .get_parent = nfs_get_parent, - .flags = EXPORT_OP_NOWCC|EXPORT_OP_NOSUBTREECHK, + .flags = EXPORT_OP_NOWCC|EXPORT_OP_NOSUBTREECHK|EXPORT_OP_CLOSE_BEFORE_UNLINK, }; |