Skip to contentSkip to conversation

nfsdctl: properly handle older kernels that don't support min-threads

PATCH In review Jeff Layton 3 participants 9 messages Feb 4 – Feb 23

Subsystems (2)
lore
Share & tools
lore

Jeff Layton

author maintainer
#0 lore raw

v2 cover nfsdctl: properly handle older kernels that don't support min-threads

Ben reported a problem with using new userland with old kernel. If he tried to send down a setting that the kernel doesn't support, it returns -EINVAL to the call.

This patch series adds a mechanism for nfsdctl to tell what attributes are supported by the "threads" command. If can then use that to determine whether to pass down the min-threads attribute or report an error or warning.

This also removes the dependency on the UAPI headers by properly maintaining the private nfsd_netlink.h file.

---
Changes in v2:
- Add patch to unconditionally compile in min-threads support
- Make getpolicy_handler() return NL_SKIP
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Jeff Layton (4):
nfsdctl: unconditionally enable support for min-threads
nfsdctl: only resolve netlink family names once
nfsdctl: query netlink policy before sending the minthreads attribute to kernel
nfsdctl: remove unneeded newlines from xlog() format strings

 configure.ac                 |   6 +-
 utils/nfsdctl/nfsd_netlink.h |   2 +
 utils/nfsdctl/nfsdctl.c      | 204 ++++++++++++++++++++++++++++++++++---------
 3 files changed, 168 insertions(+), 44 deletions(-)

---
base-commit: 8f54511aefe1455161a6c4406ed8c770139f61e3
change-id: 20260203-minthreads-402ce87096e0

Best regards,

Signature · 1 line
Jeff Layton <[email protected]>
author maintainer
#1 lore raw

PATCH v2 1/4 nfsdctl: unconditionally enable support for min-threads

I originally had this depend on the system header, but if we maintain our copy of nfsd_netlink.h in tree, then we can unconditionally compile in support for the MIN_THREADS option.

---
 configure.ac                 |  6 ++----
 utils/nfsdctl/nfsd_netlink.h |  2 ++
 utils/nfsdctl/nfsdctl.c      | 16 +---------------
 3 files changed, 5 insertions(+), 19 deletions(-)
configure.ac +2 -4
index 5cc1e9186542c975abf200edbef30bc8f6ecb8ee..a65c7837b8cb72eaa2f3dbb89069599c074be4ec 100644
@@ -262,12 +262,10 @@ AC_ARG_ENABLE(nfsdctl,
 		PKG_CHECK_MODULES(LIBNLGENL3, libnl-genl-3.0 >= 3.1)
 		PKG_CHECK_MODULES(LIBREADLINE, readline)
 		AC_CHECK_HEADERS(linux/nfsd_netlink.h)
-		AC_CHECK_DECLS([NFSD_A_SERVER_MIN_THREADS], , ,
-			       [#include <linux/nfsd_netlink.h>])
 
-		# ensure we have the pool-mode commands
+		# ensure we have the MIN_THREADS attribute
 		AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <linux/nfsd_netlink.h>]],
-				                   [[int foo = NFSD_CMD_POOL_MODE_GET;]])],
+				                   [[int foo = NFSD_A_SERVER_MIN_THREADS;]])],
 				   [AC_DEFINE([USE_SYSTEM_NFSD_NETLINK_H], 1,
 					      ["Use system's linux/nfsd_netlink.h"])])
 		AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <linux/lockd_netlink.h>]],
utils/nfsdctl/nfsd_netlink.h +2 -0
index 887cbd12b695f2398c96976ba2d70e68ee0d93c0..e9efbc9e63d83ed25fcd790b7a877c0023638f15 100644
@@ -2,6 +2,7 @@
 /* Do not edit directly, auto-generated from: */
 /*	Documentation/netlink/specs/nfsd.yaml */
 /* YNL-GEN uapi header */
+/* To regenerate run: tools/net/ynl/ynl-regen.sh */
 
 #ifndef _UAPI_LINUX_NFSD_NETLINK_H
 #define _UAPI_LINUX_NFSD_NETLINK_H
@@ -34,6 +35,7 @@ enum {
 	NFSD_A_SERVER_GRACETIME,
 	NFSD_A_SERVER_LEASETIME,
 	NFSD_A_SERVER_SCOPE,
+	NFSD_A_SERVER_MIN_THREADS,
 
 	__NFSD_A_SERVER_MAX,
 	NFSD_A_SERVER_MAX = (__NFSD_A_SERVER_MAX - 1)
utils/nfsdctl/nfsdctl.c +1 -15
index c906a2c8ba6d357e182d341a30610e367e74c093..6b3c98009488d1687e7e751eaed6c4f1d9613d39 100644
@@ -324,11 +324,9 @@ static void parse_threads_get(struct genlmsghdr *gnlh)
 		case NFSD_A_SERVER_THREADS:
 			pool_threads[i++] = nla_get_u32(attr);
 			break;
-#if HAVE_DECL_NFSD_A_SERVER_MIN_THREADS
 		case NFSD_A_SERVER_MIN_THREADS:
 			printf("min-threads: %u\n", nla_get_u32(attr));
 			break;
-#endif
 		default:
 			break;
 		}
@@ -546,10 +544,8 @@ static int threads_doit(struct nl_sock *sock, int cmd, int grace, int lease,
 			nla_put_u32(msg, NFSD_A_SERVER_LEASETIME, lease);
 		if (scope)
 			nla_put_string(msg, NFSD_A_SERVER_SCOPE, scope);
-#if HAVE_DECL_NFSD_A_SERVER_MIN_THREADS
 		if (minthreads >= 0)
 			nla_put_u32(msg, NFSD_A_SERVER_MIN_THREADS, minthreads);
-#endif
 		for (i = 0; i < pool_count; ++i)
 			nla_put_u32(msg, NFSD_A_SERVER_THREADS, pool_threads[i]);
 	}
@@ -591,24 +587,16 @@ out:
 static void threads_usage(void)
 {
 	printf("Usage: %s threads { --min-threads=X } [ pool0_count ] [ pool1_count ] ...\n", taskname);
-#if HAVE_DECL_NFSD_A_SERVER_MIN_THREADS
 	printf("    --min-threads= set the minimum thread count per pool to value\n");
-#endif
 	printf("    pool0_count: thread count for pool0, etc...\n");
 	printf("Omit any arguments to show current thread counts.\n");
 }
 
-#if HAVE_DECL_NFSD_A_SERVER_MIN_THREADS
 static const struct option threads_options[] = {
 	{ "help", no_argument, NULL, 'h' },
 	{ "min-threads", required_argument, NULL, 'm' },
 	{ },
 };
-#define THREADS_OPTSTRING "hm:"
-#else
-#define threads_options help_only_options
-#define THREADS_OPTSTRING "h"
-#endif
 
 static int threads_func(struct nl_sock *sock, int argc, char **argv)
 {
@@ -618,12 +606,11 @@ static int threads_func(struct nl_sock *sock, int argc, char **argv)
 	int opt, pools = 0;
 
 	optind = 1;
-	while ((opt = getopt_long(argc, argv, THREADS_OPTSTRING, threads_options, NULL)) != -1) {
+	while ((opt = getopt_long(argc, argv, "hm:", threads_options, NULL)) != -1) {
 		switch (opt) {
 		case 'h':
 			threads_usage();
 			return 0;
-#if HAVE_DECL_NFSD_A_SERVER_MIN_THREADS
 		case 'm':
 			errno = 0;
 			minthreads = strtoul(optarg, NULL, 0);
@@ -632,7 +619,6 @@ static int threads_func(struct nl_sock *sock, int argc, char **argv)
 				return 1;
 			}
 			break;
-#endif
 		}
 	}
 
Signature · 1 line
2.52.0
author maintainer
#2 lore raw

PATCH v2 2/4 nfsdctl: only resolve netlink family names once

In reply to Jeff Layton

The current code resolves the string name to an id for every netlink call. Just resolve the family names once and keep them.

---
 utils/nfsdctl/nfsdctl.c | 83 ++++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 64 insertions(+), 19 deletions(-)
utils/nfsdctl/nfsdctl.c +64 -19
index 6b3c98009488d1687e7e751eaed6c4f1d9613d39..86a4a944d4e131f1114ca358d81779de0a034872 100644
@@ -46,9 +46,11 @@
 #include "conffile.h"
 #include "xlog.h"
 
-/* compile note:
- * gcc -I/usr/include/libnl3/ -o <prog-name> <prog-name>.c -lnl-3 -lnl-genl-3
- */
+/* The index of the "lockd" netlink family */
+static int lockd_nl_family;
+
+/* The index of the "nfsd" netlink family */
+static int nfsd_nl_family;
 
 struct nfs_version {
 	uint8_t	major;
@@ -433,24 +435,18 @@ static struct nl_sock *netlink_sock_alloc(void)
 	return sock;
 }
 
-static struct nl_msg *netlink_msg_alloc(struct nl_sock *sock, const char *family)
+static struct nl_msg *netlink_msg_alloc(struct nl_sock *sock, int family)
 {
 	struct nl_msg *msg;
 	int id;
 
-	id = genl_ctrl_resolve(sock, family);
-	if (id < 0) {
-		xlog(L_ERROR, "failed to resolve %s generic netlink family", family);
-		return NULL;
-	}
-
 	msg = nlmsg_alloc();
 	if (!msg) {
 		xlog(L_ERROR, "failed to allocate netlink message");
 		return NULL;
 	}
 
-	if (!genlmsg_put(msg, 0, 0, id, 0, 0, 0, 0)) {
+	if (!genlmsg_put(msg, 0, 0, family, 0, 0, 0, 0)) {
 		xlog(L_ERROR, "failed to add generic netlink headers to netlink message");
 		nlmsg_free(msg);
 		return NULL;
@@ -459,6 +455,31 @@ static struct nl_msg *netlink_msg_alloc(struct nl_sock *sock, const char *family
 	return msg;
 }
 
+static int resolve_family(struct nl_sock *sock, const char *name)
+{
+	int family = genl_ctrl_resolve(sock, name);
+
+	if (family < 0) {
+		xlog(L_ERROR, "failed to resolve %s generic netlink family: %d", name, family);
+		family = 0;
+	}
+	return family;
+}
+
+static int lockd_nl_family_setup(struct nl_sock *sock)
+{
+	if (!lockd_nl_family)
+		lockd_nl_family = resolve_family(sock, LOCKD_FAMILY_NAME);
+	return lockd_nl_family;
+}
+
+static int nfsd_nl_family_setup(struct nl_sock *sock)
+{
+	if (!nfsd_nl_family)
+		nfsd_nl_family = resolve_family(sock, NFSD_FAMILY_NAME);
+	return nfsd_nl_family;
+}
+
 static void status_usage(void)
 {
 	printf("Usage: %s status\n", taskname);
@@ -482,7 +503,10 @@ static int status_func(struct nl_sock *sock, int argc, char ** argv)
 		}
 	}
 
-	msg = netlink_msg_alloc(sock, NFSD_FAMILY_NAME);
+	if (!nfsd_nl_family_setup(sock))
+		return 1;
+
+	msg = netlink_msg_alloc(sock, nfsd_nl_family);
 	if (!msg)
 		return 1;
 
@@ -530,7 +554,10 @@ static int threads_doit(struct nl_sock *sock, int cmd, int grace, int lease,
 	struct nl_cb *cb;
 	int ret;
 
-	msg = netlink_msg_alloc(sock, NFSD_FAMILY_NAME);
+	if (!nfsd_nl_family_setup(sock))
+		return 1;
+
+	msg = netlink_msg_alloc(sock, nfsd_nl_family);
 	if (!msg)
 		return 1;
 
@@ -660,7 +687,10 @@ static int fetch_nfsd_versions(struct nl_sock *sock)
 	struct nl_cb *cb;
 	int ret;
 
-	msg = netlink_msg_alloc(sock, NFSD_FAMILY_NAME);
+	if (!nfsd_nl_family_setup(sock))
+		return 1;
+
+	msg = netlink_msg_alloc(sock, nfsd_nl_family);
 	if (!msg)
 		return 1;
 
@@ -725,7 +755,10 @@ static int set_nfsd_versions(struct nl_sock *sock)
 	struct nl_cb *cb;
 	int i, ret;
 
-	msg = netlink_msg_alloc(sock, NFSD_FAMILY_NAME);
+	if (!nfsd_nl_family_setup(sock))
+		return 1;
+
+	msg = netlink_msg_alloc(sock, nfsd_nl_family);
 	if (!msg)
 		return 1;
 
@@ -906,7 +939,10 @@ static int fetch_current_listeners(struct nl_sock *sock)
 	struct nl_cb *cb;
 	int ret;
 
-	msg = netlink_msg_alloc(sock, NFSD_FAMILY_NAME);
+	if (!nfsd_nl_family_setup(sock))
+		return 1;
+
+	msg = netlink_msg_alloc(sock, nfsd_nl_family);
 	if (!msg)
 		return 1;
 
@@ -1151,7 +1187,10 @@ static int set_listeners(struct nl_sock *sock)
 	struct nl_cb *cb;
 	int i, ret;
 
-	msg = netlink_msg_alloc(sock, NFSD_FAMILY_NAME);
+	if (!nfsd_nl_family_setup(sock))
+		return 1;
+
+	msg = netlink_msg_alloc(sock, nfsd_nl_family);
 	if (!msg)
 		return 1;
 
@@ -1272,7 +1311,10 @@ static int pool_mode_doit(struct nl_sock *sock, int cmd, const char *pool_mode)
 	struct nl_cb *cb;
 	int ret;
 
-	msg = netlink_msg_alloc(sock, NFSD_FAMILY_NAME);
+	if (!nfsd_nl_family_setup(sock))
+		return 1;
+
+	msg = netlink_msg_alloc(sock, nfsd_nl_family);
 	if (!msg)
 		return 1;
 
@@ -1365,7 +1407,10 @@ static int lockd_config_doit(struct nl_sock *sock, int cmd, int grace, int tcppo
 			return 0;
 	}
 
-	msg = netlink_msg_alloc(sock, LOCKD_FAMILY_NAME);
+	if (!lockd_nl_family_setup(sock))
+		return 1;
+
+	msg = netlink_msg_alloc(sock, lockd_nl_family);
 	if (!msg)
 		return 1;
 
Signature · 1 line
2.52.0
author maintainer
#3 lore raw

PATCH v2 3/4 nfsdctl: query netlink policy before sending the minthreads attribute to kernel

In reply to Jeff Layton

Ben reported a problem when using new nfs-utils with an old kernel that doesn't support the min-threads setting. While netlink is an extensible format, genetlink (which we are using) will reject unknown attributes by default with -EINVAL.

We could fix this in the kernel by having it ignore unknown attributes, but there is no way to fix old kernels and silently ignoring it is less than ideal. By handling this in userland, we can properly error out when the kernel doesn't support this attribute.

When starting, have nfsdctl query the kernel for the "policy" of the threads operation, and determine the highest attribute index it supports. For the "threads" command, have it fail if the --min-threads option is passed and the kernel doesn't support it. For "autostart", log a warning and ignore the setting.

Fixes 00e2e62b8998 ("nfsdctl: add support for min-threads parameter")
---
 utils/nfsdctl/nfsdctl.c | 95 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 94 insertions(+), 1 deletion(-)
utils/nfsdctl/nfsdctl.c +94 -1
index 86a4a944d4e131f1114ca358d81779de0a034872..4a3744a1c22e6beac7c039bded05fc087a121200 100644
@@ -52,6 +52,9 @@ static int lockd_nl_family;
 /* The index of the "nfsd" netlink family */
 static int nfsd_nl_family;
 
+/* The highest attribute index supported by NFSD_CMD_THREADS_SET on this kernel */
+int nfsd_threads_max_nlattr;
+
 struct nfs_version {
 	uint8_t	major;
 	uint8_t	minor;
@@ -480,6 +483,83 @@ static int nfsd_nl_family_setup(struct nl_sock *sock)
 	return nfsd_nl_family;
 }
 
+static int getpolicy_handler(struct nl_msg *msg, void *arg)
+{
+	struct genlmsghdr *gnlh = nlmsg_data(nlmsg_hdr(msg));
+	struct nlattr *attr;
+	int rem;
+
+	nla_for_each_attr(attr, genlmsg_attrdata(gnlh, 0), genlmsg_attrlen(gnlh, 0), rem) {
+		struct nlattr *a, *b;
+		int i, j, index;
+
+		if (nla_type(attr) == CTRL_ATTR_POLICY) {
+			nla_for_each_nested(a, attr, i) {
+				nla_for_each_nested(b, a, j) {
+					int idx = nla_type(b);
+
+					if (nfsd_threads_max_nlattr < idx)
+						nfsd_threads_max_nlattr = idx;
+				}
+			}
+		}
+	}
+	return NL_SKIP;
+}
+
+static int query_nfsd_nl_policy(struct nl_sock *sock)
+{
+	struct genlmsghdr *ghdr;
+	struct nlmsghdr *nlh;
+	struct nl_msg *msg;
+	struct nl_cb *cb;
+	int opt, ret, id;
+
+	if (!nfsd_nl_family_setup(sock))
+		return 1;
+
+	msg = netlink_msg_alloc(sock, GENL_ID_CTRL);
+	if (!msg)
+		return 1;
+
+	nlh = nlmsg_hdr(msg);
+	nlh->nlmsg_flags |= NLM_F_DUMP;
+	ghdr = nlmsg_data(nlh);
+	ghdr->cmd = CTRL_CMD_GETPOLICY;
+
+	cb = nl_cb_alloc(NL_CB_CUSTOM);
+	if (!cb) {
+		xlog(L_ERROR, "failed to allocate netlink callbacks");
+		ret = 1;
+		goto out;
+	}
+
+	nla_put_u16(msg, CTRL_ATTR_FAMILY_ID, nfsd_nl_family);
+	nla_put_u32(msg, CTRL_ATTR_OP, NFSD_CMD_THREADS_SET);
+
+	ret = nl_send_auto(sock, msg);
+	if (ret < 0)
+		goto out_cb;
+
+	ret = 1;
+	nl_cb_err(cb, NL_CB_CUSTOM, error_handler, &ret);
+	nl_cb_set(cb, NL_CB_FINISH, NL_CB_CUSTOM, finish_handler, &ret);
+	nl_cb_set(cb, NL_CB_ACK, NL_CB_CUSTOM, ack_handler, &ret);
+	nl_cb_set(cb, NL_CB_VALID, NL_CB_CUSTOM, getpolicy_handler, NULL);
+
+	while (ret > 0)
+		nl_recvmsgs(sock, cb);
+	if (ret < 0) {
+		xlog(L_ERROR, "Error: %s", strerror(-ret));
+		ret = 1;
+	}
+out_cb:
+	nl_cb_put(cb);
+out:
+	nlmsg_free(msg);
+	return ret;
+}
+
 static void status_usage(void)
 {
 	printf("Usage: %s status\n", taskname);
@@ -639,6 +719,11 @@ static int threads_func(struct nl_sock *sock, int argc, char **argv)
 			threads_usage();
 			return 0;
 		case 'm':
+			if (nfsd_threads_max_nlattr < NFSD_A_SERVER_MIN_THREADS) {
+				xlog(L_ERROR, "This kernel does not support dynamic threading.");
+				return 1;
+			}
+
 			errno = 0;
 			minthreads = strtoul(optarg, NULL, 0);
 			if (minthreads == ULONG_MAX && errno != 0) {
@@ -1743,7 +1828,12 @@ static int autostart_func(struct nl_sock *sock, int argc, char ** argv)
 
 	lease = conf_get_num("nfsd", "lease-time", 0);
 	scope = conf_get_str("nfsd", "scope");
-	minthreads = conf_get_num("nfsd", "min-threads", 0);
+	minthreads = conf_get_num("nfsd", "min-threads", -1);
+
+	if (minthreads >= 0 && nfsd_threads_max_nlattr < NFSD_A_SERVER_MIN_THREADS) {
+		xlog(L_WARNING, "This kernel does not support dynamic threading. min-threads setting ignored.");
+		minthreads = -1;
+	}
 
 	ret = threads_doit(sock, NFSD_CMD_THREADS_SET, grace, lease, pools,
 			   threads, scope, minthreads);
@@ -1936,6 +2026,9 @@ int main(int argc, char **argv)
 		return 1;
 	}
 
+	if (query_nfsd_nl_policy(sock))
+		return 1;
+
 	if (optind > argc) {
 		usage();
 		return 1;
Signature · 1 line
2.52.0
author maintainer
#4 lore raw

PATCH v2 4/4 nfsdctl: remove unneeded newlines from xlog() format strings

In reply to Jeff Layton
---
 utils/nfsdctl/nfsdctl.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
utils/nfsdctl/nfsdctl.c +5 -5
index 4a3744a1c22e6beac7c039bded05fc087a121200..2b01f705874a4a3cad04042f6dfad22a66a7536f 100644
@@ -1514,14 +1514,14 @@ static int lockd_config_doit(struct nl_sock *sock, int cmd, int grace, int tcppo
 
 	cb = nl_cb_alloc(NL_CB_CUSTOM);
 	if (!cb) {
-		xlog(L_ERROR, "failed to allocate netlink callbacks\n");
+		xlog(L_ERROR, "failed to allocate netlink callbacks");
 		ret = 1;
 		goto out;
 	}
 
 	ret = nl_send_auto(sock, msg);
 	if (ret < 0) {
-		xlog(L_ERROR, "send failed (%d)!\n", ret);
+		xlog(L_ERROR, "send failed (%d)!", ret);
 		goto out_cb;
 	}
 
@@ -1534,7 +1534,7 @@ static int lockd_config_doit(struct nl_sock *sock, int cmd, int grace, int tcppo
 	while (ret > 0)
 		nl_recvmsgs(sock, cb);
 	if (ret < 0) {
-		xlog(L_ERROR, "Error: %s\n", strerror(-ret));
+		xlog(L_ERROR, "Error: %s", strerror(-ret));
 		ret = 1;
 	}
 out_cb:
@@ -1554,7 +1554,7 @@ static int get_service(const char *svc)
 
 	ret = getaddrinfo(NULL, svc, &hints, &res);
 	if (ret) {
-		xlog(L_ERROR, "getaddrinfo of \"%s\" failed: %s\n",
+		xlog(L_ERROR, "getaddrinfo of \"%s\" failed: %s",
 			svc, gai_strerror(ret));
 		return -1;
 	}
@@ -1575,7 +1575,7 @@ static int get_service(const char *svc)
 		}
 		break;
 	default:
-		xlog(L_ERROR, "Bad address family: %d\n", res->ai_family);
+		xlog(L_ERROR, "Bad address family: %d", res->ai_family);
 		port = -1;
 	}
 	freeaddrinfo(res);
Signature · 1 line
2.52.0
author maintainer
#5 lore raw
In reply to Jeff Layton
Quoted 30 lines · Jeff Layton

Ben reported a problem with using new userland with old kernel. If he tried to send down a setting that the kernel doesn't support, it returns -EINVAL to the call.

This patch series adds a mechanism for nfsdctl to tell what attributes are supported by the "threads" command. If can then use that to determine whether to pass down the min-threads attribute or report an error or warning.

This also removes the dependency on the UAPI headers by properly maintaining the private nfsd_netlink.h file.

---
Changes in v2:
- Add patch to unconditionally compile in min-threads support
- Make getpolicy_handler() return NL_SKIP
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Jeff Layton (4):
nfsdctl: unconditionally enable support for min-threads
nfsdctl: only resolve netlink family names once
nfsdctl: query netlink policy before sending the minthreads attribute to kernel
nfsdctl: remove unneeded newlines from xlog() format strings

 configure.ac                 |   6 +-
 utils/nfsdctl/nfsd_netlink.h |   2 +
 utils/nfsdctl/nfsdctl.c      | 204 ++++++++++++++++++++++++++++++++++---------
 3 files changed, 168 insertions(+), 44 deletions(-)
Quoted 5 lines

---
base-commit: 8f54511aefe1455161a6c4406ed8c770139f61e3
change-id: 20260203-minthreads-402ce87096e0

Best regards,

Steve, ping? Can we get this merged?

Thanks,

Signature · 1 line
Jeff Layton <[email protected]>
#6 lore raw
Quoted 35 lines · Jeff Layton
Quoted 34 lines · Jeff Layton

Ben reported a problem with using new userland with old kernel. If he tried to send down a setting that the kernel doesn't support, it returns -EINVAL to the call.

This patch series adds a mechanism for nfsdctl to tell what attributes are supported by the "threads" command. If can then use that to determine whether to pass down the min-threads attribute or report an error or warning.

This also removes the dependency on the UAPI headers by properly maintaining the private nfsd_netlink.h file.

---
Changes in v2:
- Add patch to unconditionally compile in min-threads support
- Make getpolicy_handler() return NL_SKIP
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Jeff Layton (4):
nfsdctl: unconditionally enable support for min-threads
nfsdctl: only resolve netlink family names once
nfsdctl: query netlink policy before sending the minthreads attribute to kernel
nfsdctl: remove unneeded newlines from xlog() format strings

  configure.ac                 |   6 +-
  utils/nfsdctl/nfsd_netlink.h |   2 +
  utils/nfsdctl/nfsdctl.c      | 204 ++++++++++++++++++++++++++++++++++---------
  3 files changed, 168 insertions(+), 44 deletions(-)

---
base-commit: 8f54511aefe1455161a6c4406ed8c770139f61e3
change-id: 20260203-minthreads-402ce87096e0

Quoted 3 lines
Quoted 1 line

Best regards,

Steve, ping? Can we get this merged?

I'm on it... thanks for the ping!

steved.

Quoted 2 lines

Thanks,

Reviewed-by Tested-by on the v2 series
#7 lore raw
In reply to Jeff Layton
Quoted 9 lines · Jeff Layton

Ben reported a problem with using new userland with old kernel. If he tried to send down a setting that the kernel doesn't support, it returns -EINVAL to the call.

This patch series adds a mechanism for nfsdctl to tell what attributes are supported by the "threads" command. If can then use that to determine whether to pass down the min-threads attribute or report an error or warning.

Quoted 4 lines

This also removes the dependency on the UAPI headers by properly maintaining the private nfsd_netlink.h file.

I mean to send R-b and T-b on these - because yes, both were done!

Ben

#8 lore raw
In reply to Jeff Layton
Quoted 9 lines · Jeff Layton

Ben reported a problem with using new userland with old kernel. If he tried to send down a setting that the kernel doesn't support, it returns -EINVAL to the call.

This patch series adds a mechanism for nfsdctl to tell what attributes are supported by the "threads" command. If can then use that to determine whether to pass down the min-threads attribute or report an error or warning.

Quoted 4 lines

This also removes the dependency on the UAPI headers by properly maintaining the private nfsd_netlink.h file.

Committed... (tag: nfs-utils-2-8-6-rc1)

steved.

Quoted 22 lines

---
Changes in v2:
- Add patch to unconditionally compile in min-threads support
- Make getpolicy_handler() return NL_SKIP
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Jeff Layton (4):
nfsdctl: unconditionally enable support for min-threads
nfsdctl: only resolve netlink family names once
nfsdctl: query netlink policy before sending the minthreads attribute to kernel
nfsdctl: remove unneeded newlines from xlog() format strings

  configure.ac                 |   6 +-
  utils/nfsdctl/nfsd_netlink.h |   2 +
  utils/nfsdctl/nfsdctl.c      | 204 ++++++++++++++++++++++++++++++++++---------
  3 files changed, 168 insertions(+), 44 deletions(-)

---
base-commit: 8f54511aefe1455161a6c4406ed8c770139f61e3
change-id: 20260203-minthreads-402ce87096e0

Best regards,