]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-5.15/nfsd-clean-up-nfsd_file_put.patch
Fixes for 5.15
[thirdparty/kernel/stable-queue.git] / queue-5.15 / nfsd-clean-up-nfsd_file_put.patch
1 From cbe3d42fb4d7e2683b1fbb63c228ae322ffbfa04 Mon Sep 17 00:00:00 2001
2 From: Sasha Levin <sashal@kernel.org>
3 Date: Thu, 31 Mar 2022 09:54:02 -0400
4 Subject: nfsd: Clean up nfsd_file_put()
5
6 From: Trond Myklebust <trond.myklebust@hammerspace.com>
7
8 [ Upstream commit 999397926ab3f78c7d1235cc4ca6e3c89d2769bf ]
9
10 Make it a little less racy, by removing the refcount_read() test. Then
11 remove the redundant 'is_hashed' variable.
12
13 Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
14 Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
15 ---
16 fs/nfsd/filecache.c | 13 +++----------
17 1 file changed, 3 insertions(+), 10 deletions(-)
18
19 diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c
20 index 6cde6ef68996e..429ae485ebbbe 100644
21 --- a/fs/nfsd/filecache.c
22 +++ b/fs/nfsd/filecache.c
23 @@ -295,21 +295,14 @@ nfsd_file_put_noref(struct nfsd_file *nf)
24 void
25 nfsd_file_put(struct nfsd_file *nf)
26 {
27 - bool is_hashed;
28 -
29 set_bit(NFSD_FILE_REFERENCED, &nf->nf_flags);
30 - if (refcount_read(&nf->nf_ref) > 2 || !nf->nf_file) {
31 - nfsd_file_put_noref(nf);
32 - return;
33 - }
34 -
35 - is_hashed = test_bit(NFSD_FILE_HASHED, &nf->nf_flags) != 0;
36 - if (!is_hashed) {
37 + if (test_bit(NFSD_FILE_HASHED, &nf->nf_flags) == 0) {
38 nfsd_file_flush(nf);
39 nfsd_file_put_noref(nf);
40 } else {
41 nfsd_file_put_noref(nf);
42 - nfsd_file_schedule_laundrette();
43 + if (nf->nf_file)
44 + nfsd_file_schedule_laundrette();
45 }
46 if (atomic_long_read(&nfsd_filecache_count) >= NFSD_FILE_LRU_LIMIT)
47 nfsd_file_gc();
48 --
49 2.43.0
50