From patchwork Wed Oct 25 16:24:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhuohao Bai X-Patchwork-Id: 13436463 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8E89C0032E for ; Wed, 25 Oct 2023 16:31:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232579AbjJYQbj (ORCPT ); Wed, 25 Oct 2023 12:31:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbjJYQbi (ORCPT ); Wed, 25 Oct 2023 12:31:38 -0400 Received: from out162-62-58-211.mail.qq.com (out162-62-58-211.mail.qq.com [162.62.58.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D87991 for ; Wed, 25 Oct 2023 09:31:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1698251488; bh=fdURGibl0c7gXJtCTDzqXqgfXp0ppJMBARCaqiarhkY=; h=From:To:Cc:Subject:Date; b=s/gfuaAaMBj01v4xchWj2VH8lIRPEbl3XfLhRxI29ysksR7drrviKdvQ5I044pmGT gP3uEVz2IRlQASw6LFnlk5iiuD85AhIQqXSyNTu5YV92uYjHVk/6jTr2qa+CPoL5xn Dcbb6Ln2NlMMXVdClnanbdEe8E099nXi5c7MxAhM= Received: from localhost.localdomain ([36.142.182.134]) by newxmesmtplogicsvrszc2-1.qq.com (NewEsmtp) with SMTP id 64939A66; Thu, 26 Oct 2023 00:25:09 +0800 X-QQ-mid: xmsmtpt1698251109tmx76kybs Message-ID: X-QQ-XMAILINFO: MiPTq5wGoKO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KXKweUpcgTFAZJjv6i/Vwe+Tffi X-QQ-XMRINFO: MSVp+SPm3vtS1Vd6Y4Mggwc= From: Zhuohao Bai To: steved@redhat.com Cc: falcon@tinylab.org, forrestniu@foxmail.com, baizhh21@lzu.edu.cn, tanyuan@tinylab.org, linux-nfs@vger.kernel.org, Zhuohao Bai Subject: [RFC PATCH] _rpc_dtablesize: Decrease the value of size. Date: Thu, 26 Oct 2023 00:24:42 +0800 X-OQ-MSGID: <20231025162442.1501-1-zhuohao_bai@foxmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org In the client code, the function _rpc_dtablesize() is used to determine the memory allocation for the __svc_xports array. However, some operating systems (including the recent Manjaro OS) can have _SC_OPEN_MAX values as high as 1073741816, which can cause the __svc_xports array to become too large. This results in the process being killed. There is a limit to the maximum number of files. To avoid this problem, a possible solution is to set the size to the lesser of 1024 and this value to ensure that the array space for open files is not too large, thus preventing the process from terminating. Signed-off-by: Zhuohao Bai --- src/rpc_dtablesize.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpc_dtablesize.c b/src/rpc_dtablesize.c index bce97e8..2027af4 100644 --- a/src/rpc_dtablesize.c +++ b/src/rpc_dtablesize.c @@ -41,7 +41,7 @@ _rpc_dtablesize(void) static int size; if (size == 0) { - size = sysconf(_SC_OPEN_MAX); + size = min(1024, sysconf(_SC_OPEN_MAX)); } return (size); }