From: J. Bruce Fields Date: Tue, 19 Sep 2017 23:25:41 +0000 (-0400) Subject: nfsd: give out fewer session slots as limit approaches X-Git-Tag: v4.1.12-124.31.3~565 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=99bb82031aac875304c0eec051cdab722b87ea55;p=users%2Fjedix%2Flinux-maple.git nfsd: give out fewer session slots as limit approaches 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 (cherry picked from commit de766e570413bd0484af0b580299b495ada625c3) Orabug: 28023821 Signed-off-by: Manjunath Patil Reviewed-by: Calum Mackay Signed-off-by: Brian Maly --- diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index bb6c324f1f3d..66e87ac4051c 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -1399,6 +1399,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);