Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1167295ybi; Fri, 2 Aug 2019 10:24:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqyMJ5YG9iE0V5k2ooaiwmR3aJslYtyUVmLnxzS8f93ytV3QG5l68D2XEBoZg9gYxEsnZE7f X-Received: by 2002:a62:187:: with SMTP id 129mr61298007pfb.128.1564766671356; Fri, 02 Aug 2019 10:24:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564766671; cv=none; d=google.com; s=arc-20160816; b=nsdzK2NjEGyswDyj3q9dlVqf392QncEaUetO2ziJWlKGo0Cvd96Me1q1slW8E47tep hJaxG5gpY95c5HpRxdZYqO0PQsi5SL7Fws4ezl0/q574udftAIC7ZRsnIYAWYsEj0jPM 9L/H6Vug4RfeCcgohpV0G0zscW+kUayinj/KzhK3aPPkbBFldi+He9T3nPrWC0s46WEX a0Riv+uTxS0siucNv6DXwugzvBPmOF2/2Q6J43Kf0nP1KWv8E6nLpBYXw2V3UMdLm0Nx QREsjdy3l0PZ5nPR8eE4vjill0hKNWsVrYYKHOJZiw30HdJbaqpDiBAdmI0A+tdaQ0kK E4VA== 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=ucP4LDKujoP6Wrkd5b1p5Gep8McUbFE0FvV1Uv5lvZc=; b=y+fBM5EG0G5o6ci1blOkOc1DRhUK+BjDKzmMLcxRg36eWb7IG6oeIeYdcWU/xYJI8P iAR7oPo23xQ8oegzMTjdBaEXpPOJ8DrgbmHv4R6DAPXccRm9cDKDhbStuR+20gGJkNFF HGFotlcmfIOTU51d3GKfss0uuFFqaAIZO8B6uQibYIDBg6tuVOsJW7ndWv/canM3ZgNw CPo4CQTwaQIgrtRjtL7WTLCF18JI3Im74c5EocAA3eq2ZhyJbx7FdUMTCQV7NZfWlF5K Qo5HEO/HGPK8aOnlXQ1AVuVLKBsi0171pROyP6jM7bTU3PzhcBBd2wV5o0Y2mWhEkyAb uASw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=h4LxkJfl; 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 r17si38013908pgr.277.2019.08.02.10.24.16; Fri, 02 Aug 2019 10:24:31 -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=h4LxkJfl; 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 S2405625AbfHBJq4 (ORCPT + 99 others); Fri, 2 Aug 2019 05:46:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:51452 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405590AbfHBJqv (ORCPT ); Fri, 2 Aug 2019 05:46:51 -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 8D39320B7C; Fri, 2 Aug 2019 09:46:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564739211; bh=hysyGQx4S7k2O9c18/c3vaD6tUW6VXFs/jIOKvpRrUc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h4LxkJflpYq7TP1VOYHxD7FK+sz3sfCVWJ/gb3Pu0Zr3ptfU4/yLvWhJG34neWSJc qk89HpzpbZbLSqvuKNhfJBEDGTH4a95JUiQ0CsRy3OOZAmsjUZsbqNaOWOZZBEA4xY 4d7XR26FfcsRJiGCxhdI0W3/3lP1qie6mdxnkAUs= 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.9 156/223] nfsd: give out fewer session slots as limit approaches Date: Fri, 2 Aug 2019 11:36:21 +0200 Message-Id: <20190802092248.438219254@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802092238.692035242@linuxfoundation.org> References: <20190802092238.692035242@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 3656f87d11e3..0aacd1c850c3 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