]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.19/nfsd-fix-performance-limiting-session-calculation.patch
Linux 4.14.108
[thirdparty/kernel/stable-queue.git] / queue-4.19 / nfsd-fix-performance-limiting-session-calculation.patch
1 From c54f24e338ed2a35218f117a4a1afb5f9e2b4e64 Mon Sep 17 00:00:00 2001
2 From: "J. Bruce Fields" <bfields@redhat.com>
3 Date: Thu, 21 Feb 2019 10:47:00 -0500
4 Subject: nfsd: fix performance-limiting session calculation
5
6 From: J. Bruce Fields <bfields@redhat.com>
7
8 commit c54f24e338ed2a35218f117a4a1afb5f9e2b4e64 upstream.
9
10 We're unintentionally limiting the number of slots per nfsv4.1 session
11 to 10. Often more than 10 simultaneous RPCs are needed for the best
12 performance.
13
14 This calculation was meant to prevent any one client from using up more
15 than a third of the limit we set for total memory use across all clients
16 and sessions. Instead, it's limiting the client to a third of the
17 maximum for a single session.
18
19 Fix this.
20
21 Reported-by: Chris Tracy <ctracy@engr.scu.edu>
22 Cc: stable@vger.kernel.org
23 Fixes: de766e570413 "nfsd: give out fewer session slots as limit approaches"
24 Signed-off-by: J. Bruce Fields <bfields@redhat.com>
25 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
26
27 ---
28 fs/nfsd/nfs4state.c | 8 ++++----
29 1 file changed, 4 insertions(+), 4 deletions(-)
30
31 --- a/fs/nfsd/nfs4state.c
32 +++ b/fs/nfsd/nfs4state.c
33 @@ -1514,16 +1514,16 @@ static u32 nfsd4_get_drc_mem(struct nfsd
34 {
35 u32 slotsize = slot_bytes(ca);
36 u32 num = ca->maxreqs;
37 - int avail;
38 + unsigned long avail, total_avail;
39
40 spin_lock(&nfsd_drc_lock);
41 - avail = min((unsigned long)NFSD_MAX_MEM_PER_SESSION,
42 - nfsd_drc_max_mem - nfsd_drc_mem_used);
43 + total_avail = nfsd_drc_max_mem - nfsd_drc_mem_used;
44 + avail = min((unsigned long)NFSD_MAX_MEM_PER_SESSION, total_avail);
45 /*
46 * Never use more than a third of the remaining memory,
47 * unless it's the only way to give this client a slot:
48 */
49 - avail = clamp_t(int, avail, slotsize, avail/3);
50 + avail = clamp_t(int, avail, slotsize, total_avail/3);
51 num = min_t(int, num, avail / slotsize);
52 nfsd_drc_mem_used += num * slotsize;
53 spin_unlock(&nfsd_drc_lock);