Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp432256imw; Fri, 15 Jul 2022 06:09:28 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vUUNTPHTFEbsaMIEw8AAjnjUUEbXVH2saoPXRYBmOiq9+qmQjs/Y0LpiRf0Ere6ayJ+7/9 X-Received: by 2002:a17:906:84e8:b0:72b:6d91:a0d1 with SMTP id zp8-20020a17090684e800b0072b6d91a0d1mr13687312ejb.60.1657890567830; Fri, 15 Jul 2022 06:09:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657890567; cv=none; d=google.com; s=arc-20160816; b=cGeauoqyjKjsDQ65SElUzTsenRN/E77EMxPuRXzbzyJyFTr2zpFk4sekey7dYKyadk hA1Q+3XrT2GdPDLzca9rLAgPZlFoQA1D3p7T2hHORbS1Il5Vts2cLGA2R9YMZpm8pVmp +tqAcIicsL5pIw6My0NXMU54lX24ang5V8YG7SiMsbReBQp32btg7WJgPBTlHHDoUbyw vht4BeUA8eFxjTXi3gEXHZsaH/HKfW9S3OlZms7c3asGKbpHn1rYhxEpx4tKan84jCy+ OIsf9Pf3mjwn95kDs+7yUx+cUnML1XYnAKvmk4UoczNT4xAlpvMJ3Bju0dCF1xxcZTmu Pycw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date; bh=ucWKaT7vlXiiRmzGz+OalLmlHgVUSfKdGTHLuz0qiks=; b=u1RfaJqQKHZ7dFf34AIWZzYMGWZN9wMbUWDQ6HGrLZxTJFIRwhTYVWrQRo4rq67iBo uUd8+7OsOxO4Ssl2zlwSfEMAjSrZnG19qtmMEVu0NoFO8NdoJ4My328QAmq+dnApnfH1 +O+tVwNvEKItXMtofxAuzZWpMIIbhMY/itad2zQ2/Gco8y26KGm6gv5fsGZ664fyWSAE akUTXGLJkVWZNoeSaDzgbM5l1uL1aQGk0Br56GVPDgrMe6KYlpz2x/elK0RKabccmwMh WTT8ksd6XYnptFIthPD4VeN1btJnRqFwjxgOLMfxQi8Z/Tp8zMOeV67gZA1cbtQwlqlK LZNA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hs27-20020a1709073e9b00b007108d0c71fasi5815637ejc.465.2022.07.15.06.09.02; Fri, 15 Jul 2022 06:09:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233284AbiGONFx (ORCPT + 99 others); Fri, 15 Jul 2022 09:05:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229908AbiGONFx (ORCPT ); Fri, 15 Jul 2022 09:05:53 -0400 Received: from albert.telenet-ops.be (albert.telenet-ops.be [IPv6:2a02:1800:110:4::f00:1a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E222A4A806 for ; Fri, 15 Jul 2022 06:05:51 -0700 (PDT) Received: from ramsan.of.borg ([84.195.186.194]) by albert.telenet-ops.be with bizsmtp id vR5o2700b4C55Sk06R5oDe; Fri, 15 Jul 2022 15:05:48 +0200 Received: from geert (helo=localhost) by ramsan.of.borg with local-esmtp (Exim 4.93) (envelope-from ) id 1oCL0u-003gTx-Br; Fri, 15 Jul 2022 15:05:48 +0200 Date: Fri, 15 Jul 2022 15:05:48 +0200 (CEST) From: Geert Uytterhoeven X-X-Sender: geert@ramsan.of.borg To: Dai Ngo cc: chuck.lever@oracle.com, linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, linux-next@vger.kernel.org Subject: Re: [PATCH v2 2/2] NFSD: limit the number of v4 clients to 1024 per 1GB of system memory In-Reply-To: <1657815462-14069-3-git-send-email-dai.ngo@oracle.com> Message-ID: References: <1657815462-14069-1-git-send-email-dai.ngo@oracle.com> <1657815462-14069-3-git-send-email-dai.ngo@oracle.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Hi Dai, On Thu, 14 Jul 2022, Dai Ngo wrote: > Currently there is no limit on how many v4 clients are supported > by the system. This can be a problem in systems with small memory > configuration to function properly when a very large number of > clients exist that creates memory shortage conditions. > > This patch enforces a limit of 1024 NFSv4 clients, including courtesy > clients, per 1GB of system memory. When the number of the clients > reaches the limit, requests that create new clients are returned > with NFS4ERR_DELAY and the laundromat is kicked start to trim old > clients. Due to the overhead of the upcall to remove the client > record, the maximun number of clients the laundromat removes on > each run is limited to 128. This is done to ensure the laundromat > can still process the other tasks in a timely manner. > > Since there is now a limit of the number of clients, the 24-hr > idle time limit of courtesy client is no longer needed and was > removed. > > Signed-off-by: Dai Ngo Thanks for your patch, which is now commit 05eaba9bd8c06580 ("NFSD: limit the number of v4 clients to 1024 per 1GB of system memory") in next-20220715. noreply@ellerman.id.au reports: fs/nfsd/nfsctl.c:1504:24: error: 'NFS4_CLIENTS_PER_GB' undeclared (first use in this function) > --- a/fs/nfsd/nfsctl.c > +++ b/fs/nfsd/nfsctl.c > @@ -1463,6 +1463,8 @@ static __net_init int nfsd_init_net(struct net *net) > { > int retval; > struct nfsd_net *nn = net_generic(net, nfsd_net_id); > + u64 max_clients; > + struct sysinfo si; > > retval = nfsd_export_init(net); > if (retval) > @@ -1488,6 +1490,10 @@ static __net_init int nfsd_init_net(struct net *net) Not protected by #ifdef CONFIG_NFSD_V4: > seqlock_init(&nn->writeverf_lock); > > atomic_set(&nn->nfs4_client_count, 0); > + si_meminfo(&si); > + max_clients = (u64)si.totalram * si.mem_unit / (1024 * 1024 * 1024); > + max_clients *= NFS4_CLIENTS_PER_GB; > + nn->nfs4_max_clients = max_t(int, max_clients, NFS4_CLIENTS_PER_GB); > > return 0; > > diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h > index 847b482155ae..bbada18225b1 100644 > --- a/fs/nfsd/nfsd.h > +++ b/fs/nfsd/nfsd.h > @@ -341,6 +341,8 @@ void nfsd_lockd_shutdown(void); Protected by #ifdef CONFIG_NFSD_V4: > > #define NFSD_LAUNDROMAT_MINTIMEOUT 1 /* seconds */ > #define NFSD_COURTESY_CLIENT_TIMEOUT (24 * 60 * 60) /* seconds */ > +#define NFSD_CLIENT_MAX_TRIM_PER_RUN 128 > +#define NFS4_CLIENTS_PER_GB 1024 > > /* > * The following attributes are currently not supported by the NFSv4 server: > -- > 2.9.5 Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds