nfsdctl: add support for min-threads parameter
Subsystems (2)
Jeff Layton
maintainerPATCH 1/1 nfsdctl: add support for min-threads parameter
This patch adds proper support to nfsdctl to manage nfsd's new dynamic threading when NFSD_A_SERVER_MIN_THREADS is defined in the header:
If the user sets min-threads, and has a new enough kernel, the traditional threads parameters will represent the max number of threads. The min-threads value represents the minimum number of threads to run in each pool. The kernel will start the minimum number of threads at startup time, and the thread count will dynamically fluctuate between the min and max based on load.
Allow the "autostart" subcommand to find the "min-threads" parameter in nfs.conf and set it in the netlink call appropriately. If it's not set, then assume that it's 0, which will disable dynamic threading.
For the "threads" subcommand, add a new command-line option. If it's not set, then don't send it in the netlink command at all. That allows the kernel's existing setting to remain as-is, unless explicitly changed.
Also, update the documentation with info about min-threads.
---
Consider this a starting point for discussion. The userland interface can be different from the kernel's min-threads interface.
One alternative idea:
We could just expose dynamic threading in the config file and command-line interface as a bool. If enabled, we'd set min-threads to 1. If disabled, set it to 0.
I guess we could also do both as well...
--- configure.ac | 3 ++- systemd/nfs.conf.man | 3 ++- utils/nfsdctl/nfsdctl.8 | 20 ++++++++++++++++++-- utils/nfsdctl/nfsdctl.adoc | 13 +++++++++++++ utils/nfsdctl/nfsdctl.c | 43 +++++++++++++++++++++++++++++++++++++------ 5 files changed, 72 insertions(+), 10 deletions(-)
configure.ac +2 -1
@@ -262,6 +262,8 @@ 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 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <linux/nfsd_netlink.h>]],
@@ -620,7 +622,6 @@ AC_CHECK_SIZEOF(socklen_t,, [AC_INCLUDES_DEFAULT # include <sys/socket.h> #endif]) - dnl ************************************************************* dnl Export some path names to config.h dnl *************************************************************
systemd/nfs.conf.man +2 -1
@@ -162,6 +162,7 @@ option. .B nfsd Recognized values: .BR threads , +.BR min-threads , .BR host , .BR scope , .BR port ,
@@ -179,7 +180,7 @@ Recognized values: Version and protocol values are Boolean values as described above, and are also used by .BR rpc.mountd . -Threads and the two times are integers. +Threads, min-threads and the two times are integers. .B port and .B rdma
utils/nfsdctl/nfsdctl.8 +18 -2
@@ -2,12 +2,12 @@ .\" Title: nfsdctl .\" Author: Jeff Layton .\" Generator: Asciidoctor 2.0.20 -.\" Date: 2025-01-09 +.\" Date: 2026-01-12 .\" Manual: \ \& .\" Source: \ \& .\" Language: English .\" -.TH "NFSDCTL" "8" "2025-01-09" "\ \&" "\ \&" +.TH "NFSDCTL" "8" "2026-01-12" "\ \&" "\ \&" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0
@@ -147,6 +147,22 @@ value of 0 will shut down the NFS server. Run this without arguments to get the current number of running threads in each pool. .RE .sp +.if n .RS 4 +.nf +.fam C +These options are specific to the "threads" subcommand: + +\-m, \-\-min\-threads= + If set to a positive, non\-zero value, then dynamic threading is enabled for + nfsd. In this mode, the traditional "threads" values are treated as a maximum + number of threads. This specifies the minimum number of threads per pool. The + kernel will start the minimum number and dynamically start and stop threads as + needed. If the minimum is larger than the maximum, then dynamic threadis is + disabled, and the maximum number is started. +.fam +.fi +.if n .RE +.sp \fBversion\fP .RS 4 Get/set the enabled NFS versions for the server. Run without arguments to
utils/nfsdctl/nfsdctl.adoc +13 -0
@@ -84,6 +84,19 @@ Each subcommand can also accept its own set of options and arguments. The value of 0 will shut down the NFS server. Run this without arguments to get the current number of running threads in each pool. +[source,bash] +---- +These options are specific to the "threads" subcommand: + +-m, --min-threads= + If set to a positive, non-zero value, then dynamic threading is enabled for + nfsd. In this mode, the traditional "threads" values are treated as a maximum + number of threads. This specifies the minimum number of threads per pool. The + kernel will start the minimum number and dynamically start and stop threads as + needed. If the minimum is larger than the maximum, then dynamic threadis is + disabled, and the maximum number is started. +---- + *version*:: Get/set the enabled NFS versions for the server. Run without arguments to
utils/nfsdctl/nfsdctl.c +37 -6
108 lines not on this page · raw message
---
base-commit: 0e71be58cdead21b7bc0285fa6afbf1d0eca3049
change-id: 20260109-minthreads-7906eecedf99
Best regards,
Signature · 1 line
Jeff Layton <[email protected]>