Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3788110ybi; Mon, 29 Jul 2019 12:37:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqzjbDa6ah3So4iT+JRxh1mMdz2QdKbBAJrn9Pix2xzWuOAjCgmw51cYsFvmVZ+bmmYM6bfq X-Received: by 2002:a63:211c:: with SMTP id h28mr105306997pgh.438.1564429074738; Mon, 29 Jul 2019 12:37:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564429074; cv=none; d=google.com; s=arc-20160816; b=P/yyNSELJ+TkJpiThp+oDKmdrNaQ4kgXkh4p1w+G798b1bQxhBNIJZNNpUaztJGtu2 VFpADcEoulROzply+3EMpBaxhnkokSC+WF7ZLv7NeD1rsZXoHsqB7IvGlyLLtqNNGGdW KTS2Bh6VKENuRog+gYs8S1FTOT9gB6Z2n8/wPelax1+M/1Gr8qi+y7LzWS7d6isbOVW/ PRkgGjraYdlGVbgqIehn9J6yoBnxj6DBzpDO/2PVrs21ih10mYkuH6Sl9URCs4ZMruYG /8nfc7mNsES5AAyCDbTVsFJWIwMlu0dPaEvuVSlh7z2uTYgQPGapaj59CmgEA5VslGTl /Kog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=QxDUligHlqH2rs46pTldSEpTTWHHqKkrDxMi7OR+mbo=; b=SIqBa7GpLgRqXNmhip14ihwuY/kvqBnqE0AXm8IBWwpviZ5L2Hd46mDPAFNB2Ha+S4 9ku2AaLhR3jtXB03GBmkwvkOdzA0HfcZwylIF4JQ8R/K6BZaWGLaA0ffgO/KyaWBZRno knXuVRtE1K2A1KUJKj6/FKJ3mK1r/7Rc/p953JuRILGw5RvtqhWBmKcFrd3nBB08WgpJ sKT8ut5+sZd1J7OLgFO0ySIP00ClVoPLdIHbWwDwK+YZNyqACXKlTKrIRssiA9TP7lWc VjB7cPu4jXEjWOOK3jOTBq66dcgqmKmRdCj83HdDhqR9q7+exPwRFWKKaf+lnPm9XWSX z+wA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pxaIWDGv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e18si5252038pgv.139.2019.07.29.12.37.39; Mon, 29 Jul 2019 12:37:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pxaIWDGv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388501AbfG2Te7 (ORCPT + 99 others); Mon, 29 Jul 2019 15:34:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:49236 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388368AbfG2Tex (ORCPT ); Mon, 29 Jul 2019 15:34:53 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2A1252070B; Mon, 29 Jul 2019 19:34:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428892; bh=FuE/bac3E4Wb0YAwTYorxq2zJYmikUC5EUvOJqBOYac=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pxaIWDGvNdxzAJHkqgAn/YNJoMmxODg8vGV47v+f3MLEFMDF+a6cW7+zDRHU+0iEW 5dM9h18X9J1tn4NjORPLKQWh6996bUf7Xpw+dGpgYfqth52p/YRoWYh2aiapc/lqKG 9aW3XBIq8c85UHoMbvBynCQg6oPCogk+Kq1ZGnl0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "J. Bruce Fields" , Sasha Levin Subject: [PATCH 4.14 218/293] nfsd: give out fewer session slots as limit approaches Date: Mon, 29 Jul 2019 21:21:49 +0200 Message-Id: <20190729190841.214221951@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit de766e570413bd0484af0b580299b495ada625c3 ] 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 Signed-off-by: Sasha Levin --- fs/nfsd/nfs4state.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 94128643ec1a..dd48353357d7 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -1507,6 +1507,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); -- 2.20.1