From: Scott Mayhew <smayhew@redhat.com>
To: steved@redhat.com
Cc: jlayton@kernel.org, yoyang@redhat.com, linux-nfs@vger.kernel.org
Subject: [nfs-utils PATCH v3 2/3] nfsdctl: tweak the nfs.conf version handling
Date: Mon, 13 Jan 2025 18:13:18 -0500 [thread overview]
Message-ID: <20250113231319.951885-3-smayhew@redhat.com> (raw)
In-Reply-To: <20250113231319.951885-1-smayhew@redhat.com>
I noticed I was getting different results when comparing nfsdctl's
config file handling versus rpc.nfsd's.
First, the vers4 config option was being treated as a mask, e.g. if
vers4=n and vers4.2=y then end result was still that all minorversions
were disabled. Change it so that vers4=n would initially toggle off all
minorversions, but individual v4.x=y would turn that minorversion back
on.
Second, don't make assumptions about what default should be passed to
conf_get_bool. Instead, test both possible values and only update the
nfsd_versions array if an option was explicitly specified.
Finally, add a check so that 'nfsdctl autostart' will error out if no
versions or minorversions are enabled.
Signed-off-by: Scott Mayhew <smayhew@redhat.com>
---
utils/nfsdctl/nfsdctl.c | 50 ++++++++++++++++++++++++++++++++++-------
1 file changed, 42 insertions(+), 8 deletions(-)
diff --git a/utils/nfsdctl/nfsdctl.c b/utils/nfsdctl/nfsdctl.c
index 88b728e0..78200624 100644
--- a/utils/nfsdctl/nfsdctl.c
+++ b/utils/nfsdctl/nfsdctl.c
@@ -1457,15 +1457,47 @@ read_nfsd_conf(void)
xlog_set_debug("nfsd");
}
-static void configure_versions(void)
+static int configure_versions(void)
{
- bool v4 = conf_get_bool("nfsd", "vers4", true);
+ int i, j, max_minor = get_max_minorversion();
+ bool found_one = false;
+ char tag[20];
+
+ for (i = 2; i <= 4; ++i) {
+ sprintf(tag, "vers%d", i);
+ if (!conf_get_bool("nfsd", tag, true)) {
+ update_nfsd_version(i, 0, false);
+ if (i == 4)
+ for (j = 0; j <= max_minor; ++j)
+ update_nfsd_version(4, j, false);
+ }
+ if (conf_get_bool("nfsd", tag, false)) {
+ update_nfsd_version(i, 0, true);
+ if (i == 4)
+ for (j = 0; j <= max_minor; ++j)
+ update_nfsd_version(4, j, true);
+ }
+ }
- update_nfsd_version(2, 0, conf_get_bool("nfsd", "vers2", false));
- update_nfsd_version(3, 0, conf_get_bool("nfsd", "vers3", true));
- update_nfsd_version(4, 0, v4 && conf_get_bool("nfsd", "vers4.0", true));
- update_nfsd_version(4, 1, v4 && conf_get_bool("nfsd", "vers4.1", true));
- update_nfsd_version(4, 2, v4 && conf_get_bool("nfsd", "vers4.2", true));
+ for (i = 0; i <= max_minor; ++i) {
+ sprintf(tag, "vers4.%d", i);
+ if (!conf_get_bool("nfsd", tag, true))
+ update_nfsd_version(4, i, false);
+ if (conf_get_bool("nfsd", tag, false))
+ update_nfsd_version(4, i, true);
+ }
+
+ for (i = 0; i < MAX_NFS_VERSIONS; ++i) {
+ if (nfsd_versions[i].enabled) {
+ found_one = true;
+ break;
+ }
+ }
+ if (!found_one) {
+ xlog(L_ERROR, "no version specified");
+ return 1;
+ }
+ return 0;
}
static void configure_listeners(void)
@@ -1556,7 +1588,9 @@ static int autostart_func(struct nl_sock *sock, int argc, char ** argv)
ret = fetch_nfsd_versions(sock);
if (ret)
return ret;
- configure_versions();
+ ret = configure_versions();
+ if (ret)
+ return ret;
ret = set_nfsd_versions(sock);
if (ret)
return ret;
--
2.45.2
next prev parent reply other threads:[~2025-01-13 23:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-13 23:13 [nfs-utils PATCH v3 0/3] version handling fixes for nfsdctl and rpc.nfsd Scott Mayhew
2025-01-13 23:13 ` [nfs-utils PATCH v3 1/3] nfsdctl: tweak the version subcommand behavior Scott Mayhew
2025-01-13 23:13 ` Scott Mayhew [this message]
2025-01-13 23:13 ` [nfs-utils PATCH v3 3/3] nfsd: fix version sanity check Scott Mayhew
2025-01-13 23:20 ` [nfs-utils PATCH v3 0/3] version handling fixes for nfsdctl and rpc.nfsd Scott Mayhew
2025-01-18 12:12 ` Steve Dickson
2025-01-18 12:08 ` Steve Dickson
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=20250113231319.951885-3-smayhew@redhat.com \
--to=smayhew@redhat.com \
--cc=jlayton@kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=steved@redhat.com \
--cc=yoyang@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