From patchwork Wed Oct 25 16:27:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhuohao Bai X-Patchwork-Id: 13436462 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 1EF4EC0032E for ; Wed, 25 Oct 2023 16:29:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232262AbjJYQ3Y (ORCPT ); Wed, 25 Oct 2023 12:29:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234524AbjJYQ3W (ORCPT ); Wed, 25 Oct 2023 12:29:22 -0400 Received: from out203-205-221-202.mail.qq.com (out203-205-221-202.mail.qq.com [203.205.221.202]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FE3F9C for ; Wed, 25 Oct 2023 09:29:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1698251354; bh=fdURGibl0c7gXJtCTDzqXqgfXp0ppJMBARCaqiarhkY=; h=From:To:Cc:Subject:Date; b=ULVGRX5eIzOF3WaXBlmJVBt08PhRmRyGA1vM+6+w9pP/pKZkYHAAylfMDUNyvf2Bs rPus8NpvdqNVO2p42iZurJ+WmVEzkFeAmQ9xTGaeCDJ5PBw6iyoEnYHLWK+VBogaA5 51Jxpqc7BYP5I5fDI/bSVByVgi1L2NtSnjL87l0s= Received: from localhost.localdomain ([36.142.182.134]) by newxmesmtplogicsvrsza10-0.qq.com (NewEsmtp) with SMTP id 6EA22473; Thu, 26 Oct 2023 00:27:42 +0800 X-QQ-mid: xmsmtpt1698251262thnyghwih Message-ID: X-QQ-XMA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ahPvzwo+fwmHGK3mkjSb1yxRC0/BkDi+q9YZgpD6EiQ/ifuopv/pPZqO76K/jWiHj3lHOKiJ5 HZ5eW+EkmqUZ2TBUQIBC2cLIl6/i02QI0S04ZYUEGqahuPPLhqz8GkyrNAv89p/JjI5d6M X-QQ-XMRINFO: NS+P29fieYNw95Bth2bWPxk= 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, libtirpc-devel@lists.sourceforge.net, Zhuohao Bai Subject: [RFC PATCH] _rpc_dtablesize: Decrease the value of size. Date: Thu, 26 Oct 2023 00:27:16 +0800 X-OQ-MSGID: <20231025162716.1551-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); }