nfsd: give out fewer session slots as limit approaches
authorJ. Bruce Fields <bfields@redhat.com>
Tue, 19 Sep 2017 23:25:41 +0000 (19:25 -0400)
committerJ. Bruce Fields <bfields@redhat.com>
Wed, 4 Oct 2017 20:25:01 +0000 (16:25 -0400)
Instead of granting client's full requests until we hit our DRC size
limit and then failing CREATE_SESSIONs (and hence mounts) completely,
start granting clients smaller slot tables as we approach the limit.

The factor chosen here is pretty much arbitrary.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
fs/nfsd/nfs4state.c

index 0c04f81aa63b225b2207b226b1113e1973ec1e1b..9db8a19cceaa2eb3aea18b21c1d123e7ee5b87fb 100644 (file)
@@ -1472,6 +1472,11 @@ static u32 nfsd4_get_drc_mem(struct nfsd4_channel_attrs *ca)
        spin_lock(&nfsd_drc_lock);
        avail = min((unsigned long)NFSD_MAX_MEM_PER_SESSION,
                    nfsd_drc_max_mem - nfsd_drc_mem_used);
+       /*
+        * Never use more than a third of the remaining memory,
+        * unless it's the only way to give this client a slot:
+        */
+       avail = clamp_t(int, avail, slotsize, avail/3);
        num = min_t(int, num, avail / slotsize);
        nfsd_drc_mem_used += num * slotsize;
        spin_unlock(&nfsd_drc_lock);