public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: Steve Dickson <steved@redhat.com>,
	 Lorenzo Bianconi <lorenzo@kernel.org>,
	Chuck Lever <chuck.lever@oracle.com>,  Neil Brown <neilb@suse.de>
Cc: linux-nfs@vger.kernel.org, Jeff Layton <jlayton@kernel.org>
Subject: [PATCH 1/2] nfsdctl: make "autostart" default to 16 threads
Date: Mon, 15 Jul 2024 07:43:01 -0400	[thread overview]
Message-ID: <20240715-nfsdctl-v1-1-c09c314f540d@kernel.org> (raw)
In-Reply-To: <20240715-nfsdctl-v1-0-c09c314f540d@kernel.org>

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 <jlayton@kernel.org>
---
 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);

-- 
2.45.2


  reply	other threads:[~2024-07-15 11:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-15 11:43 [PATCH 0/2] nfsdctl: fix default threads and clean up compiler warnings Jeff Layton
2024-07-15 11:43 ` Jeff Layton [this message]
2024-07-15 11:43 ` [PATCH 2/2] nfsdctl: fix " Jeff Layton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240715-nfsdctl-v1-1-c09c314f540d@kernel.org \
    --to=jlayton@kernel.org \
    --cc=chuck.lever@oracle.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=lorenzo@kernel.org \
    --cc=neilb@suse.de \
    --cc=steved@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox