diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2022-07-08 20:27:02 +0200 |
---|---|---|
committer | Chuck Lever <chuck.lever@oracle.com> | 2022-07-30 02:16:42 +0200 |
commit | 5e138c4a750dc140d881dab4a8804b094bbc08d2 (patch) | |
tree | 4b89786166f7ac18e87566cd6526cd97e6a0d193 /fs/nfsd/filecache.c | |
parent | NFSD: Move nfsd_file_trace_alloc() tracepoint (diff) | |
download | linux-5e138c4a750dc140d881dab4a8804b094bbc08d2.tar.xz linux-5e138c4a750dc140d881dab4a8804b094bbc08d2.zip |
NFSD: NFSv4 CLOSE should release an nfsd_file immediately
The last close of a file should enable other accessors to open and
use that file immediately. Leaving the file open in the filecache
prevents other users from accessing that file until the filecache
garbage-collects the file -- sometimes that takes several seconds.
Reported-by: Wang Yugui <wangyugui@e16-tech.com>
Link: https://bugzilla.linux-nfs.org/show_bug.cgi?387
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Diffstat (limited to 'fs/nfsd/filecache.c')
-rw-r--r-- | fs/nfsd/filecache.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c index ac38b41c89c6..58721fced7f3 100644 --- a/fs/nfsd/filecache.c +++ b/fs/nfsd/filecache.c @@ -452,6 +452,24 @@ nfsd_file_put(struct nfsd_file *nf) nfsd_file_put_noref(nf); } +/** + * nfsd_file_close - Close an nfsd_file + * @nf: nfsd_file to close + * + * If this is the final reference for @nf, free it immediately. + * This reflects an on-the-wire CLOSE or DELEGRETURN into the + * VFS and exported filesystem. + */ +void nfsd_file_close(struct nfsd_file *nf) +{ + nfsd_file_put(nf); + if (refcount_dec_if_one(&nf->nf_ref)) { + nfsd_file_unhash(nf); + nfsd_file_lru_remove(nf); + nfsd_file_free(nf); + } +} + struct nfsd_file * nfsd_file_get(struct nfsd_file *nf) { |