From patchwork Tue Oct 31 13:13:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhuohao Bai X-Patchwork-Id: 13441513 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 5D142C4332F for ; Tue, 31 Oct 2023 13:13:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344458AbjJaNN4 (ORCPT ); Tue, 31 Oct 2023 09:13:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344452AbjJaNNz (ORCPT ); Tue, 31 Oct 2023 09:13:55 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66BC8DE for ; Tue, 31 Oct 2023 06:13:53 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6b20577ef7bso4933897b3a.3 for ; Tue, 31 Oct 2023 06:13:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698758033; x=1699362833; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BD8VWPASmmhS2IhXP01B8qSPpw2IJI2K/JZ8p09kfNo=; b=QIUAG4GbBjE0ZxOMR7+IuEaV0jAzfuv9JB4Y5cdXnDxsyigJG0oWrZscPm1AgpkbdW DC/G4UwKvMlgc8tf3PI9Emzx/ZyjTveRfKL0M2FmsIwcOBLzfgCVOONh80DuwfTtXfSf NSjb2RefmdYcYhmpdC9p9pjZYJh5XLyC6ADeD97zsN8syR1OijAiGcD8RiQP7E/jva87 k+NNbTAEAckupKCJ/A/9jaUq53zvgWGyUBpgJhX8VMnkj1UvcwNoKxpawqpP+7klXxPc gwJHWsaW40oz2s67+oUpR1FXrQyuy5NDTYtNpE/TfbLZwzoU4SQHi2GkKBxLojQT7M+C Yi9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698758033; x=1699362833; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BD8VWPASmmhS2IhXP01B8qSPpw2IJI2K/JZ8p09kfNo=; b=ZCfEOc5hM7x2lTFkZdY4yQEAfIui3zy7QBuM3Dyl8A9V53133XO0Py5WFSY6RGSTaM c1mMKxFy6qqX6HERc3/xl9HU9YMXv5loT5TRMGyt770r9FG2xmSvK+TaDAeRy3NEmGiD kQX5zqSGqZI3gxhQ1hizDQec288/naoBU0KzOD0ldTGiu4buq2Pt0ZMd8iRn41Kd4utM 6Sszr3L0XRp4LiSvVXjiCQfw6t1T+fAjmACr0YGamjJszzRmiMHJj/zO8M/JZ6cRZ3WL Jt+t21noVtSkEcwwSGSoN3BSzdM9K0W0qjGOHIFne5PmNcDvODyERf8SL/Qt8R0Zuj3K V3mQ== X-Gm-Message-State: AOJu0YzgTtIaNO7wCNzdznm9zmyO+dF86hQ2vVh6UjOhm5EX6+ec1nM2 naX8QD69awMUmpk687rfc94= X-Google-Smtp-Source: AGHT+IGsY8dmV4/7tg+ScTj8Rvz9OYv+dBfUsAday/opVNolVKLDCJT+bjp+/SnbDUDHhnNNBiK8qQ== X-Received: by 2002:a05:6a00:2d94:b0:6be:4228:698b with SMTP id fb20-20020a056a002d9400b006be4228698bmr11020883pfb.20.1698758032731; Tue, 31 Oct 2023 06:13:52 -0700 (PDT) Received: from localhost.localdomain ([36.142.182.171]) by smtp.gmail.com with ESMTPSA id h18-20020aa786d2000000b006c031c6c200sm1223746pfo.88.2023.10.31.06.13.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 06:13:52 -0700 (PDT) From: Zhuohao Bai X-Google-Original-From: Zhuohao Bai To: steved@redhat.com Cc: libtirpc-devel@lists.sourceforge.net, linux-nfs@vger.kernel.org, tanyuan@tinylab.org, forrestniu@foxmail.com, falcon@tinylab.org, zhuohao_bai@foxmail.com Subject: [PATCH v1 1/2] _rpc_dtablesize: Decrease the value of size. Date: Tue, 31 Oct 2023 21:13:09 +0800 Message-Id: <724549cc2342aaa4b3832967e086252134528d3f.1698751763.git.zhuohao_bai@foxmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org To fix the bug caused by a Size value that is too large and leads to an array that requires excessive memory, which subsequently results in the failure of rpcbind to start properly. 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..12f80c1 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); } From patchwork Tue Oct 31 13:13:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhuohao Bai X-Patchwork-Id: 13441514 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 DED96C4167D for ; Tue, 31 Oct 2023 13:14:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344471AbjJaNOC (ORCPT ); Tue, 31 Oct 2023 09:14:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344472AbjJaNOB (ORCPT ); Tue, 31 Oct 2023 09:14:01 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC1EEDA for ; Tue, 31 Oct 2023 06:13:58 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-6bd73395bceso4171189b3a.0 for ; Tue, 31 Oct 2023 06:13:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698758038; x=1699362838; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gB566YCHTASYF1Q8UTMkal48ruGoIhbv/qQQAAKy4z8=; b=QZheh4jbi9TEla0loQJkFRy/al0NRSqmG3sCj//HnM3JStl3xUH/agYc3qN09VLMVV wFyDctgnu31n3SWaaXeG9QweLOrLTWcV51gLFmZsQmzFSz15WdePXfBLdz/7gw08y7aw bnxEwihn1Y//hCdTnUcuhcR/Kq91qfCy/ca7RN79Ku3vfMfwxlXRgbScjaL/f6XPwqmQ LinDPvT9AsOaWpX3n3NT7ZfIH1c2q/M0Cdxtibokq+ZDGX8RBOC1YixnXetoQaT4AqTl JsEoBvJyYLMB2qtIKuk7qT+yHRLmc7PSjwCW7PDWH7wvnS3eJkSTCs6OY4izsx91xZsb CVBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698758038; x=1699362838; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gB566YCHTASYF1Q8UTMkal48ruGoIhbv/qQQAAKy4z8=; b=FGaW83uUb6F7AsTc/9mx3DA8YZZxsG9Tcrl255tJbuE6OW01gEbIfJPXFRchNFO3Ca ThmVFDwWd6mfY2SwfjeQODaooYM5DZkb3Pno80ndwpCPrN73w6vlUcwDewalqi+y72EB LH87HDgGSGt3T4VMHD05DlorDjnd+EU/EfkZSFMc/dRO8kqJ9hMQVJVaCHS0MrH+D0Wi fdFLuq+0XeAxhi87/B/1ChhIiDHgzoZXk2X0DFdx6qEhwJ1Q+ZkA0FgU0r/0Ovm5iOLQ U8/XMjHh1tdUDEpuo2k6iWAUrYnw0tC+L92TfcWlMREpGTcH3v2PhSQ5I/S9myuSDjdI wmQw== X-Gm-Message-State: AOJu0YzHDKGbJaS8cH0RbiDgMLa6/q+XfKIvMoh93x0X0FJEGpW2AzYn 6dDyJ43h5Nk2qokQ3Cr2oFc= X-Google-Smtp-Source: AGHT+IEZ+WTx/HPv7va0ONwDf5mg8VP1Hq3vlf/3E2OBuZ+ppR/R+H4bXkwTDvHFIzf6FgNJk1xhpw== X-Received: by 2002:a05:6a00:38d0:b0:6be:c6f7:f9fd with SMTP id ey16-20020a056a0038d000b006bec6f7f9fdmr3015192pfb.11.1698758038080; Tue, 31 Oct 2023 06:13:58 -0700 (PDT) Received: from localhost.localdomain ([36.142.182.171]) by smtp.gmail.com with ESMTPSA id h18-20020aa786d2000000b006c031c6c200sm1223746pfo.88.2023.10.31.06.13.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 06:13:57 -0700 (PDT) From: Zhuohao Bai X-Google-Original-From: Zhuohao Bai To: steved@redhat.com Cc: libtirpc-devel@lists.sourceforge.net, linux-nfs@vger.kernel.org, tanyuan@tinylab.org, forrestniu@foxmail.com, falcon@tinylab.org, zhuohao_bai@foxmail.com Subject: [PATCH v1 2/2] _rpc_dtablesize: Cleaning up the existing code Date: Tue, 31 Oct 2023 21:13:10 +0800 Message-Id: <61483752fe0b46729ae223e928d811924f053a7c.1698751763.git.zhuohao_bai@foxmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Some users have already taken steps to address this issue. To prevent duplication, we need to remove the modified code and modify the rpc_dtablesize function. Signed-off-by: Zhuohao Bai --- src/rpc_dtablesize.c | 4 +++- src/svc.c | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rpc_dtablesize.c b/src/rpc_dtablesize.c index 12f80c1..e88698f 100644 --- a/src/rpc_dtablesize.c +++ b/src/rpc_dtablesize.c @@ -41,7 +41,9 @@ _rpc_dtablesize(void) static int size; if (size == 0) { - size = min(1024, sysconf(_SC_OPEN_MAX)); + size = sysconf(_SC_OPEN_MAX); + if (size > FD_SETSIZE) + size = FD_SETSIZE; } return (size); } diff --git a/src/svc.c b/src/svc.c index 3a8709f..9b932a5 100644 --- a/src/svc.c +++ b/src/svc.c @@ -657,8 +657,6 @@ svc_getreqset (readfds) assert (readfds != NULL); setsize = _rpc_dtablesize (); - if (setsize > FD_SETSIZE) - setsize = FD_SETSIZE; maskp = readfds->fds_bits; for (sock = 0; sock < setsize; sock += NFDBITS) {