From patchwork Mon Jul 15 11:43:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13733352 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A40B818A92F for ; Mon, 15 Jul 2024 11:43:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721043789; cv=none; b=ReMxx4K6/yOONx6qwUdBLc/SoWGzrTVlSZTAQV9om64QWF5RbWtK5yp68ik3/JtCF43eXXaYGwy8NHvDbFYAwtc4ouPcRY9/HMctjkiqRj4EZ6bdhqDa0ZPLk9MnpJb12QEIKI7v9krulBlDeCVKxRqgcy29RF7hs8pCVZHl3Ic= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721043789; c=relaxed/simple; bh=9ndgA6SeamOVqIvnSLALNTaJ/1qk+hDAUaUia2oMyWo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=huf+t/KgxPLqp15n/LaO/Ve/vi8GDWzOWMLoP4Rc57yB+yTgHbXVfba1UUnJJmcjM2ysVgbF5ZBv7Qg+2yE8pSMvpF8W3vYau2+yLZkkM653e1RkONy97kj7cimEBqwDGOMxma2N21RGAPTwrh5rsTQJwcmbIDSQkeyqxvAE0MI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pbCJDr4n; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pbCJDr4n" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CB7C9C4AF0B; Mon, 15 Jul 2024 11:43:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721043789; bh=9ndgA6SeamOVqIvnSLALNTaJ/1qk+hDAUaUia2oMyWo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=pbCJDr4nQCvvBYAfuj3504REOUmnbGuIMehXo7MD2qcE2Yiwrpd1cb2V7pa1xAbpk mU7Q9l2QC4yDoFq0gIIx6Kfvb58bdTnou1hdlQuSRZDSvjxXN+oCyotJAk/JkZ/Yx1 9ztJb4EHC6vR83XalMTQaZGKcYSBr07iY6ZIxzsRbCk1PqMtTv4D48Xl6ucWVa8QoT SXEtHl1KXE00ULj1d8p4qWE/RjSR/r1bQSSgg+smteP7O2JGKZBur+3ucd2Ni34/+P 29EKiEa5HGSjIaFNDRQEi/4c2oMY/TlKimue8koDvUR7uRR7R+vLtsofrNKgYj0FTa +gENtvEeaH5xA== From: Jeff Layton Date: Mon, 15 Jul 2024 07:43:01 -0400 Subject: [PATCH 1/2] nfsdctl: make "autostart" default to 16 threads Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240715-nfsdctl-v1-1-c09c314f540d@kernel.org> References: <20240715-nfsdctl-v1-0-c09c314f540d@kernel.org> In-Reply-To: <20240715-nfsdctl-v1-0-c09c314f540d@kernel.org> To: Steve Dickson , Lorenzo Bianconi , Chuck Lever , Neil Brown Cc: linux-nfs@vger.kernel.org, Jeff Layton X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2425; i=jlayton@kernel.org; h=from:subject:message-id; bh=9ndgA6SeamOVqIvnSLALNTaJ/1qk+hDAUaUia2oMyWo=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmlQtLnK6pKUWJCjyXPMYVOsL65XCYTP5NhcSpY eOukxtor6qJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZpULSwAKCRAADmhBGVaC FV2TD/9zZtI/vedDrTy96AC8cI7i2jC9LY1OAN0NoAgel/BeFn6k9RjMTxIQWQbiH2o6gV/3MnP AxZTCYCKkdAx8JoJ/LxOofGJkV9as2F6pRvEdCbEKqpM0oN2BCSHx+y8wEnDbhreyaJ15S6BK7G WGK1oTeFp5bepzFbdrBqFIPOJa+H9uBcBVBKJI87kGmsDlwhH+m6Pg0sTS1vul5x5rCPZj9juq0 R7c4hi26Ps6IrOd4hYTLRqd2675pVV3O2rz8TX9X+Oed+0MoT2jLfselRBPqe6d120MaGE+n2UF VzrHalOrwXSfEMxcVUSiLmZ1bV7InDyBh5dntAjDTIV3nq7Z/4kzMJRHxiwkLMDKZ45Izs1vGr+ wb9AaLd8iDzQA+qIqo9/TSlvXPHQHOwRBPp6SBGklmMXcn36ivp65/TLsjGYEX3l5Ak5n0tlEC1 Cycz+tnTyixMwAk8MwRtWrEHHc6J2SyHtMj3Qzfl6zuj7mviD6vXwQpeVxujMEI36Djk69bGbpE wJSxDmFj4/wQH47TExYxkvURiJcKKHxVAS7QD2emnR3oLdNtraDPpNpsPzHeKxnGLrv4T28+rIH 345rkK8BZMa67b2y/u9adtoyIo33qET3VA3LIYCtZZ4mwKMEPc87RGGF/n56oy18gB4CK4IHJs9 ytfYBJZtVhVEaDA== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 The original nfsdctl posting required the user to set a threads= value in nfs.conf, or autostart wouldn't work properly. rpc.nfsd has a default of 8 threads, which is pitifully low in the modern age. For nfsdctl, double that value to default to 16 threads. Signed-off-by: Jeff Layton --- utils/nfsdctl/nfsdctl.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/utils/nfsdctl/nfsdctl.c b/utils/nfsdctl/nfsdctl.c index 55bf5cd21783..eb2c8cca4f42 100644 --- a/utils/nfsdctl/nfsdctl.c +++ b/utils/nfsdctl/nfsdctl.c @@ -1356,9 +1356,12 @@ static void autostart_usage(void) printf(" Start the server with the settings in /etc/nfs.conf.\n"); } +/* default number of nfsd threads when not specified in nfs.conf */ +#define DEFAULT_AUTOSTART_THREADS 16 + static int autostart_func(struct nl_sock *sock, int argc, char ** argv) { - int *threads, grace, lease, idx, ret, opt; + int *threads, grace, lease, idx, ret, opt, pools; struct conf_list *thread_str; struct conf_list_node *n; char *scope, *pool_mode; @@ -1399,26 +1402,29 @@ static int autostart_func(struct nl_sock *sock, int argc, char ** argv) scope = conf_get_str("nfsd", "scope"); thread_str = conf_get_list("nfsd", "threads"); - if (!thread_str || thread_str->cnt == 0) - return 0; + pools = thread_str ? thread_str->cnt : 1; - threads = calloc(thread_str->cnt, sizeof(int)); + threads = calloc(pools, sizeof(int)); if (!threads) return -ENOMEM; - idx = 0; - TAILQ_FOREACH(n, &(thread_str->fields), link) { - char *endptr = NULL; + if (thread_str) { + idx = 0; + TAILQ_FOREACH(n, &(thread_str->fields), link) { + char *endptr = NULL; - threads[idx++] = strtol(n->field, &endptr, 0); - if (!endptr || *endptr != '\0') { - fprintf(stderr, "Invalid threads value %s.\n", n->field); - ret = -EINVAL; - goto out; + threads[idx++] = strtol(n->field, &endptr, 0); + if (!endptr || *endptr != '\0') { + fprintf(stderr, "Invalid threads value %s.\n", n->field); + ret = -EINVAL; + goto out; + } } + } else { + threads[0] = DEFAULT_AUTOSTART_THREADS; } - ret = threads_doit(sock, NFSD_CMD_THREADS_SET, grace, lease, thread_str->cnt, + ret = threads_doit(sock, NFSD_CMD_THREADS_SET, grace, lease, pools, threads, scope); out: free(threads); From patchwork Mon Jul 15 11:43:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 13733353 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 38CD418A93C for ; Mon, 15 Jul 2024 11:43:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721043790; cv=none; b=sBk2F6vRrsPja4Va3ea2IgsUTyC8d+jWIoPPLPLR7uKxV82ibYab7hHoN3GA4pni66Oc27m8nig5uKRKDzjetjda67I+MmqDcp6mGtTzv5v8v5PcfzcY0S4QgfURs+DJXntxjritQxWC28p0e6R5pLdD6rFWfPrqP5mSUEInb7s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721043790; c=relaxed/simple; bh=lPkUo+qEJMOSNPoeEMKotjaCvLtf2qS4ZsO3ZdXOcy8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ColuTu911beNMpXIh8Q1BjDtr3uLuG4aqmnQ+cghQmjlYBzuW/1qeYRLu6OKErMULySs6Ql0MYadEvXv5hEppusBmh+AKPBAeFGBqN1NFVx8DwqY9YWTNq8MmotKvD8NCvGJGKHpVlGxNhubMFscoieU04gfecUjEl5ygVzJVJE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=r1FFE2h8; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="r1FFE2h8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8DD4DC32782; Mon, 15 Jul 2024 11:43:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1721043790; bh=lPkUo+qEJMOSNPoeEMKotjaCvLtf2qS4ZsO3ZdXOcy8=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=r1FFE2h80XfRFy88wGnI/DfxMmy8CPjrhBSDZK8UjofhuMGdyoAgVxFgLndnyFEQ5 z0Viwo6GVJAB6yuuxKlK7voJ6ku+odImK8I+njiTep8e0m/+qd7YBAAOuzLx9JH9mT y1t8HMi2dlnbFc2jD3dkQ/6YFKaaeK6CYtpaVD7hGEw4OZoEqpwFHzjfUx+BXtLCUE wow4whPuJoEMae2ACHFe9YlZxJp17SOWx/D9AxboZyOPHiHkuKzchU5XwOvxNbD93L owv2AWTAKk8QF1M+6uiUGJE6q1CIoivjPbZxgjSaQ0NhK7TNjSHHXhonx63PPduPRz kSWpqjRpV1qPA== From: Jeff Layton Date: Mon, 15 Jul 2024 07:43:02 -0400 Subject: [PATCH 2/2] nfsdctl: fix compiler warnings Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240715-nfsdctl-v1-2-c09c314f540d@kernel.org> References: <20240715-nfsdctl-v1-0-c09c314f540d@kernel.org> In-Reply-To: <20240715-nfsdctl-v1-0-c09c314f540d@kernel.org> To: Steve Dickson , Lorenzo Bianconi , Chuck Lever , Neil Brown Cc: linux-nfs@vger.kernel.org, Jeff Layton X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4999; i=jlayton@kernel.org; h=from:subject:message-id; bh=lPkUo+qEJMOSNPoeEMKotjaCvLtf2qS4ZsO3ZdXOcy8=; b=owEBbQKS/ZANAwAIAQAOaEEZVoIVAcsmYgBmlQtL1D4O72BEdJ/ElwYMoKIJgN9XEkyCJ1938 u479xHJMQSJAjMEAAEIAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCZpULSwAKCRAADmhBGVaC FeUoD/4mmQM5V7GAMUuLzgafSgpWMeGyNdhnPUw0Ds9nUfrU68Cxm8QqniWd6HbNYNtL4vXhOGk D1IUWe1fD1jxNBINL0df9m5MfKkC7ViDbBgI3Lz/jg2gGvD90aBXf41LGyEPUhwFXfy8k24qD/N Rid6Uo+iktIX8iYRC1Hhwo9k7iABDeq5I0MCx/FoNROZfPWBB3P+3IqLl77KJMYc15aLggN9C/X f7oKoSz+X+R+BeWU3dyZ/OQbS6lKMQd6/T8VLXq4A4MZKKLO8B4MgFu4KTUDxbNdcMcgfM9h/w7 fPjya7s2VDeZohS5Tfhvg/DKMMzgKfFDMt+olA+uVpAaCM4+wF2+D0QNnlf4gD14bXNsc6vWoRn Ru6LV9Pu+VtH7f+Btb5uVo9Cbey4jVhA+YHYlrcqPMzFut0ChWs1cFJWn5sDxT1rCpkCRhduFXi ZRwETBNt95WIM2YvXprvv0Xg/Y+DRofXkq7y3aoUWOFSJAUH2Pqizo8S5y4B6s+6rRVEC4GXF+T DqMFWp6osMU4lMsGIg77peXEhfKeOE9ffgJL4iUa2OeqTpIuo06uqnrGG5/Sn2wh8JavoOZ5JBc 62CNRL5Ym49baGVJlyoLUOHViMeQB8HlhkvfcsyY94l7et/gr52lYvCxmSVoyFHxIpo8Qyb8tK5 PP96+YDNblIAFkQ== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 Fix a pile of compiler warnings. Signed-off-by: Jeff Layton --- utils/nfsdctl/nfsdctl.c | 48 ++++++++++++++---------------------------------- 1 file changed, 14 insertions(+), 34 deletions(-) diff --git a/utils/nfsdctl/nfsdctl.c b/utils/nfsdctl/nfsdctl.c index eb2c8cca4f42..f7c276320085 100644 --- a/utils/nfsdctl/nfsdctl.c +++ b/utils/nfsdctl/nfsdctl.c @@ -44,7 +44,6 @@ */ static int debug_level; -static int nl_family_id; struct nfs_version { uint8_t major; @@ -84,16 +83,6 @@ static const struct option help_only_options[] = { { }, }; -static void debug(int level, const char *fmt, ...) -{ - va_list args; - - va_start(args, fmt); - if (level <= debug_level) - vprintf(fmt, args); - va_end(args); -} - #define NFSD4_OPS_MAX_LEN sizeof(nfsd4_ops) / sizeof(nfsd4_ops[0]) static const char *nfsd4_ops[] = { [OP_ACCESS] = "OP_ACCESS", @@ -317,8 +306,6 @@ static void parse_threads_get(struct genlmsghdr *gnlh) nla_for_each_attr(attr, genlmsg_attrdata(gnlh, 0), genlmsg_attrlen(gnlh, 0), rem) { - struct nlattr *a; - switch (nla_type(attr)) { case NFSD_A_SERVER_GRACETIME: printf("gracetime: %u\n", nla_get_u32(attr)); @@ -327,7 +314,7 @@ static void parse_threads_get(struct genlmsghdr *gnlh) printf("leasetime: %u\n", nla_get_u32(attr)); break; case NFSD_A_SERVER_SCOPE: - printf("scope: %s\n", nla_data(attr)); + printf("scope: %s\n", (const char *)nla_data(attr)); break; case NFSD_A_SERVER_THREADS: pool_threads[i++] = nla_get_u32(attr); @@ -352,7 +339,7 @@ static void parse_pool_mode_get(struct genlmsghdr *gnlh) genlmsg_attrlen(gnlh, 0), rem) { switch (nla_type(attr)) { case NFSD_A_POOL_MODE_MODE: - printf("pool-mode: %s\n", nla_data(attr)); + printf("pool-mode: %s\n", (const char *)nla_data(attr)); break; case NFSD_A_POOL_MODE_NPOOLS: printf("npools: %u\n", nla_get_u32(attr)); @@ -366,7 +353,6 @@ static void parse_pool_mode_get(struct genlmsghdr *gnlh) static int recv_handler(struct nl_msg *msg, void *arg) { struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg)); - const struct nlattr *attr = genlmsg_attrdata(gnlh, 0); switch (gnlh->cmd) { case NFSD_CMD_RPC_STATUS_GET: @@ -573,7 +559,7 @@ static void threads_usage(void) static int threads_func(struct nl_sock *sock, int argc, char **argv) { uint8_t cmd = NFSD_CMD_THREADS_GET; - uint32_t *pool_threads = NULL; + int *pool_threads = NULL; int opt, pools = 0; optind = 1; @@ -589,7 +575,7 @@ static int threads_func(struct nl_sock *sock, int argc, char **argv) char **targv = &argv[optind]; int i; - pools = argc - optind, i; + pools = argc - optind; pool_threads = alloca(pools * sizeof(*pool_threads)); cmd = NFSD_CMD_THREADS_SET; @@ -785,8 +771,7 @@ static void version_usage(void) static int version_func(struct nl_sock *sock, int argc, char ** argv) { - char *endptr = NULL; - int opt, ret, threads, i; + int ret, i; /* help is only valid as first argument after command */ if (argc > 1 && @@ -940,7 +925,7 @@ static int update_listeners(const char *str) char buf[INET6_ADDRSTRLEN + 16]; char sign = *str; char *netid, *addr, *port, *end; - struct addrinfo *res, *ai; + struct addrinfo *res; int i, ret; struct addrinfo hints = { .ai_flags = AI_PASSIVE, .ai_family = AF_INET, @@ -1156,9 +1141,7 @@ static void listener_usage(void) static int listener_func(struct nl_sock *sock, int argc, char ** argv) { - char *endptr = NULL; - int ret, opt, threads, i; - int argidx; + int ret, i; /* help is only valid as first argument after command */ if (argc > 1 && @@ -1255,16 +1238,14 @@ static int pool_mode_func(struct nl_sock *sock, int argc, char **argv) if (optind < argc) { char **targv = &argv[optind]; - int i; cmd = NFSD_CMD_POOL_MODE_SET; /* empty string? */ - if (targv[i][0] == '\0') { - fprintf(stderr, "Invalid threads value %s.\n", targv[i]); + if (*targv[0] == '\0') { + fprintf(stderr, "Invalid threads value %s.\n", targv[0]); return 1; } - pool_mode = targv[0]; } return pool_mode_doit(sock, cmd, pool_mode); @@ -1272,18 +1253,17 @@ static int pool_mode_func(struct nl_sock *sock, int argc, char **argv) #define MAX_LISTENER_LEN (64 * 2 + 16) -static int +static void add_listener(const char *netid, const char *addr, const char *port) { char buf[MAX_LISTENER_LEN]; - int ret; if (strchr(addr, ':')) - ret = snprintf(buf, MAX_LISTENER_LEN, "+%s:[%s]:%s", - netid, addr, port); + snprintf(buf, MAX_LISTENER_LEN, "+%s:[%s]:%s", + netid, addr, port); else - ret = snprintf(buf, MAX_LISTENER_LEN, "+%s:%s:%s", - netid, addr, port); + snprintf(buf, MAX_LISTENER_LEN, "+%s:%s:%s", + netid, addr, port); buf[MAX_LISTENER_LEN - 1] = '\0'; update_listeners(buf); }