nfsdctl: new nfs-utils tool for managing the kernel NFS server
Subsystems (2)
Jeff Layton
maintainerv2 cover nfsdctl: new nfs-utils tool for managing the kernel NFS server
Lorenzo posted an updated version of his netlink interface patches yesterday [1]. This is an update to adapt to those changes, and to bring the tool closer to feature completion for release.
This series first adds Lorenzo's original userland nfsdctl tool to the nfs-utils tree, and then converts it to a subcommand-based interface, in the spirit of tools like nmcli or virsh.
This version should be at feature parity with rpc.nfsd. This posting also includes a manpage and an update to the nfs-server.service to start using the new interface when possible.
I've also included a patch that adds the manpage source. It's much nicer to edit that and regenerate it if we have to update it later. We can drop that patch if you just want to keep the result though.
Assuming we're good with the new kernel interfaces, this should be pretty close to ready for merge.
[1]: https://lore.kernel.org/linux-nfs/[email protected]/
---
Changes in v2:
- Adapt to latest kernel netlink interface changes (in particular, send the leastime and gracetime when they are set in the config).
- More help text for different subcommands
- New nfsdctl(8) manpage
- Patch to make systemd preferentially use nfsdctl instead of rpc.nfsd
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Jeff Layton (3):
nfsdctl: convert it to a command-line based interface
nfsdctl: asciidoc source for the manpage
systemd: use nfsdctl to start and stop the nfs server
Lorenzo Bianconi (1):
nfsdctl: add the nfsdctl utility to nfs-utils
configure.ac | 13 + systemd/nfs-server.service | 4 +- utils/Makefile.am | 4 + utils/nfsdctl/Makefile.am | 13 + utils/nfsdctl/nfsdctl.8 | 274 +++++++++ utils/nfsdctl/nfsdctl.adoc | 140 +++++ utils/nfsdctl/nfsdctl.c | 1401 ++++++++++++++++++++++++++++++++++++++++++++ utils/nfsdctl/nfsdctl.h | 186 ++++++ 8 files changed, 2033 insertions(+), 2 deletions(-)
---
base-commit: 117102ee541f38fd7d9274feb8b5586f88d4f655
change-id: 20240412-nfsdctl-fa8bd8430cfd
Best regards,
Signature · 1 line
Jeff Layton <[email protected]>
Jeff Layton
maintainerPATCH v2 1/4 nfsdctl: add the nfsdctl utility to nfs-utils
From: Lorenzo Bianconi <[email protected]>
This is a snapshot of Lorenzo Bianconi's nfsdctl tool[1], integrated into the nfs-utils tree.
This tool is intended as an eventual replacement for rpc.nfsd that will use netlink to control and query the kernel nfs server. Add it to the tree with all of the autoconf stuff necessary for it to build.
[1]: https://github.com/LorenzoBianconi/nfsdctl
--- configure.ac | 12 ++ utils/Makefile.am | 4 + utils/nfsdctl/Makefile.am | 10 + utils/nfsdctl/nfsdctl.c | 531 ++++++++++++++++++++++++++++++++++++++++++++++ utils/nfsdctl/nfsdctl.h | 183 ++++++++++++++++ 5 files changed, 740 insertions(+)
configure.ac +12 -0
@@ -252,6 +252,17 @@ AC_ARG_ENABLE(nfsdcltrack, enable_nfsdcltrack=$enableval, enable_nfsdcltrack="yes") +AC_ARG_ENABLE(nfsdctl, + [AS_HELP_STRING([--disable-nfsdctl],[disable nfsdctl program for controlling nfsd@<:@default=no@:>@])], + enable_nfsdctl=$enableval, + enable_nfsdctl="yes") + AM_CONDITIONAL(CONFIG_NFSDCTL, [test "$enable_nfsdctl" = "yes" ]) + if test "$enable_nfsdctl" = yes; then + dnl Check for libnl3 + PKG_CHECK_MODULES(LIBNL3, libnl-3.0 >= 3.1) + PKG_CHECK_MODULES(LIBNLGENL3, libnl-genl-3.0 >= 3.1) + fi + AC_ARG_ENABLE(nfsv4server, [AS_HELP_STRING([--enable-nfsv4server],[enable support for NFSv4 only server @<:@default=no@:>@])], enable_nfsv4server=$enableval,
@@ -739,6 +750,7 @@ AC_CONFIG_FILES([ utils/mountd/Makefile utils/exportd/Makefile utils/nfsd/Makefile + utils/nfsdctl/Makefile utils/nfsref/Makefile utils/nfsstat/Makefile utils/nfsidmap/Makefile
utils/Makefile.am +4 -0
@@ -35,6 +35,10 @@ if CONFIG_JUNCTION OPTDIRS += nfsref endif +if CONFIG_NFSDCTL +OPTDIRS += nfsdctl +endif + SUBDIRS = \ exportfs \ mountd \
utils/nfsdctl/Makefile.am new file +10 -0
@@ -0,0 +1,10 @@ +## Process this file with automake to produce Makefile.in + +sbin_PROGRAMS = nfsdctl + +noinst_HEADERS = nfsdctl.h +nfsdctl_SOURCES = nfsdctl.c +nfsdctl_CFLAGS = $(LIBNL3_CFLAGS) $(LIBNLGENL3_CFLAGS) +nfsdctl_LDADD = ../../support/nfs/libnfs.la $(LIBNL3_LIBS) $(LIBNLGENL3_LIBS) + +MAINTAINERCLEANFILES = Makefile.in
utils/nfsdctl/nfsdctl.c new file +531 -0
531 lines not on this page · raw message
utils/nfsdctl/nfsdctl.h new file +183 -0
183 lines not on this page · raw message
Signature · 1 line
2.44.0
Jeff Layton
maintainerPATCH v2 2/4 nfsdctl: convert it to a command-line based interface
In reply to Jeff LaytonLorenzo's original tool used getopt_long to indicate the command, but that's somewhat limiting. This switches it to a subcommand-based interface, where each subcommand can take its own getopt options, in the spirit of commands like nmcli or virsh.
There are currently 5 different subcommands:
listener get/set listener info
version get/set supported NFS versions
threads get/set nfsd thread settings
status get current RPC processing info
autostart start server with settings from /etc/nfs.confEach can take different options, and we can expand this interface later with more commands as necessary.
--- configure.ac | 1 + utils/nfsdctl/Makefile.am | 7 +- utils/nfsdctl/nfsdctl.8 | 274 ++++++++++ utils/nfsdctl/nfsdctl.c | 1278 +++++++++++++++++++++++++++++++++++++-------- utils/nfsdctl/nfsdctl.h | 3 + 5 files changed, 1357 insertions(+), 206 deletions(-)
configure.ac +1 -0
@@ -261,6 +261,7 @@ AC_ARG_ENABLE(nfsdctl, dnl Check for libnl3 PKG_CHECK_MODULES(LIBNL3, libnl-3.0 >= 3.1) PKG_CHECK_MODULES(LIBNLGENL3, libnl-genl-3.0 >= 3.1) + PKG_CHECK_MODULES(LIBREADLINE, readline) fi AC_ARG_ENABLE(nfsv4server,
utils/nfsdctl/Makefile.am +5 -2
@@ -1,10 +1,13 @@ ## Process this file with automake to produce Makefile.in +man8_MANS = nfsdctl.8 +EXTRA_DIST = $(man8_MANS) + sbin_PROGRAMS = nfsdctl noinst_HEADERS = nfsdctl.h nfsdctl_SOURCES = nfsdctl.c -nfsdctl_CFLAGS = $(LIBNL3_CFLAGS) $(LIBNLGENL3_CFLAGS) -nfsdctl_LDADD = ../../support/nfs/libnfs.la $(LIBNL3_LIBS) $(LIBNLGENL3_LIBS) +nfsdctl_CFLAGS = $(LIBNL3_CFLAGS) $(LIBNLGENL3_CFLAGS) $(LIBREADLINE_CFLAGS) +nfsdctl_LDADD = ../../support/nfs/libnfs.la $(LIBNL3_LIBS) $(LIBNLGENL3_LIBS) $(LIBREADLINE_LIBS) MAINTAINERCLEANFILES = Makefile.in
utils/nfsdctl/nfsdctl.8 new file +274 -0
275 lines not on this page · raw message
utils/nfsdctl/nfsdctl.c +1074 -204
1,445 lines not on this page · raw message
utils/nfsdctl/nfsdctl.h +3 -0
@@ -31,6 +31,8 @@ enum {enum {NFSD_A_SERVER_WORKER_THREADS =1 , +NFSD_A_SERVER_WORKER_GRACETIME , +NFSD_A_SERVER_WORKER_LEASETIME , __NFSD_A_SERVER_WORKER_MAX,NFSD_A_SERVER_WORKER_MAX = (__NFSD_A_SERVER_WORKER_MAX -1 )
@@ -39,6 +41,7 @@ enum {enum {NFSD_A_VERSION_MAJOR =1 ,NFSD_A_VERSION_MINOR , +NFSD_A_VERSION_ENABLED , __NFSD_A_VERSION_MAX,NFSD_A_VERSION_MAX = (__NFSD_A_VERSION_MAX -1 )
Signature · 1 line
2.44.0
Jeff Layton
maintainerPATCH v2 3/4 nfsdctl: asciidoc source for the manpage
In reply to Jeff LaytonConvert to manpage with:
asciidoctor -b manpage nfsdctl.adoc
--- utils/nfsdctl/nfsdctl.adoc | 140 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+)
utils/nfsdctl/nfsdctl.adoc new file +140 -0
@@ -0,0 +1,140 @@ += nfsdctl(8) +Jeff Layton +:doctype: manpage + +== NAME + +nfsdctl - control program for the Linux kernel NFS server + +== SYNOPSIS + +*nfsdctl* [ _OPTION_ ] COMMAND ... + +== DESCRIPTION + +nfsdctl is a control and query program for the in-kernel NFS server. There are several +subcommands (documented below) that allow the admin to configure or query different +aspects of the NFS server. + +To get information about different subcommand usage, pass the subcommand the +--help parameter. For example: + + nfsdctl listener --help + +== OPTIONS + +*-d, --debug*:: + Enable debug logging + +*-h, --help*:: + Print program help text + +*-V, --version*:: + Print program version + +== SUBCOMMANDS + +Each subcommand can also accept its own set of options and arguments. The +--help option is standard for all subcommands: + +*autostart*:: + Start the server using the settings in the [nfsd] section of /etc/nfs.conf. + This subcommand takes no arguments. + +*listener*:: + + Get/set the listening sockets for the server. Run this without arguments to + get a list of the sockets on which the server is currently listening. To add + or remove sockets, pass it whitespace-separated strings in the format: + + { +|- }{ protocol }:{ address }:{ port } + + The fields are: + + + to add a listener, - to remove one + protocol: protocol name (e.g. tcp, udp, rdma) + address: hostname or address + port: port number or service name + + All fields are required, except for the address. If address is an empty string, + then the listeners will be opened for INADDR_ANY and IN6ADDR_ANY_INIT for ipv6 + (if enabled). The address can be either a hostname or an IP address. IPv4 + addresses must be in dotted-quad form. IPv6 addresses should be in standard + colon separated form, and must be enclosed in square brackets. + +*status*:: + + Get information about RPCs currently executing in the server. This subcommand + takes no arguments. + +*threads*:: + + Get/set the number of running nfsd threads. Pass this subcommand a positive + integer to change the currently active number of threads. Passing it a value + of 0 will shut down the NFS server. Run this without arguments to get the + current number of running threads. + +*version*:: + + Get/set the enabled NFS versions for the server. Run without arguments to + get a list of supported versions and whether they are currently enabled or + disabled. To enable or disable a version, pass it a string in the format: + + { +|- }{ MAJOR }{.{ MINOR }} + + The fields are: + + + to enable a version, - to disable + MAJOR: the major version integer value + MINOR: the minor version integet value + + The minorversion field is optional. If not given, it will disable or enable + all minorversions for that major version. + +== EXAMPLES + +Start the server with the settings in nfs.conf: + + nfsdctl autostart + +Get a list of current listening sockets: + + nfsdctl listener + +Show the supported and enabled NFS versions: + + nfsdctl version + +Add TCP listener on all addresses (both v4 and v6), port 2049: + + nfsdctl listener +tcp::2049 + +Add RDMA listener on 1.2.3.4 port 20049: + + nfsdctl listener +rdma:1.2.3.4:20049 + +Add same listener on IPv6 address f00::ba4 port 20050: + + nfsdctl listener +rdma:[f00::ba4]:20050 + +Enable NFS version 3, disable v4.0: + + nfsdctl version +3 -4.0 + +Change the number of running threads to 256: + + nfsdctl threads 256 + +== NOTES + +nfsdctl is intended to supersede rpc.nfsd(8), which controls the nfs server +using the files under /proc/fs/nfsd. nfsdctl instead uses a netlink(7) +interface to achieve the same goals. + +Most of the commands that query the NFS server can be run as an unprivileged +user, but configuring the server typically requires an account with elevated +privileges. + +== SEE ALSO + +nfs.conf(5), rpc.nfsd(8), rpc.mountd(8), exports(5), exportfs(8), nfs.conf(5), rpc.rquotad(8), nfsstat(8), netconfig(5)
Signature · 1 line
2.44.0
Jeff Layton
maintainerPATCH v2 4/4 systemd: use nfsdctl to start and stop the nfs server
In reply to Jeff LaytonAttempt to use nfsdctl to start and stop the nfs-server. If that fails for any reason, use rpc.nfsd to do it instead.
--- systemd/nfs-server.service | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
systemd/nfs-server.service +2 -2
@@ -23,8 +23,8 @@ After=rpc-gssd.service gssproxy.service rpc-svcgssd.service Type=oneshot RemainAfterExit=yes ExecStartPre=-/usr/sbin/exportfs -r -ExecStart=/usr/sbin/rpc.nfsd -ExecStop=/usr/sbin/rpc.nfsd 0 +ExecStart=/bin/sh -c '/usr/sbin/nfsdctl autostart || /usr/sbin/rpc.nfsd' +ExecStop=/bin/sh -c '/usr/sbin/nfsdctl threads 0 || /usr/sbin/rpc.nfsd 0' ExecStopPost=/usr/sbin/exportfs -au ExecStopPost=/usr/sbin/exportfs -f
Signature · 1 line
2.44.0
Hello,
Quoted 49 lines · Jeff Layton
Lorenzo posted an updated version of his netlink interface patches yesterday [1]. This is an update to adapt to those changes, and to bring the tool closer to feature completion for release.
This series first adds Lorenzo's original userland nfsdctl tool to the nfs-utils tree, and then converts it to a subcommand-based interface, in the spirit of tools like nmcli or virsh.
This version should be at feature parity with rpc.nfsd. This posting also includes a manpage and an update to the nfs-server.service to start using the new interface when possible.
I've also included a patch that adds the manpage source. It's much nicer to edit that and regenerate it if we have to update it later. We can drop that patch if you just want to keep the result though.
Assuming we're good with the new kernel interfaces, this should be pretty close to ready for merge.
[1]: https://lore.kernel.org/linux-nfs/[email protected]/
Signed-off-by Jeff Layton <[email protected]>---
Changes in v2:
- Adapt to latest kernel netlink interface changes (in particular, send the leastime and gracetime when they are set in the config).
- More help text for different subcommands
- New nfsdctl(8) manpage
- Patch to make systemd preferentially use nfsdctl instead of rpc.nfsd
- Link to v1: https://lore.kernel.org/r/[email protected]---
Jeff Layton (3):
nfsdctl: convert it to a command-line based interface
nfsdctl: asciidoc source for the manpage
systemd: use nfsdctl to start and stop the nfs serverLorenzo Bianconi (1):
nfsdctl: add the nfsdctl utility to nfs-utilsconfigure.ac | 13 + systemd/nfs-server.service | 4 +- utils/Makefile.am | 4 + utils/nfsdctl/Makefile.am | 13 + utils/nfsdctl/nfsdctl.8 | 274 +++++++++ utils/nfsdctl/nfsdctl.adoc | 140 +++++ utils/nfsdctl/nfsdctl.c | 1401 ++++++++++++++++++++++++++++++++++++++++++++ utils/nfsdctl/nfsdctl.h | 186 ++++++ 8 files changed, 2033 insertions(+), 2 deletions(-)
Quoted 5 lines
---
base-commit:117102ee541f38fd7d9274feb8b5586f88d4f655
change-id: 20240412-nfsdctl-fa8bd8430cfdBest regards,
I'm not sure this is ready for prime time....
nfsdctl status
[nothing and there is a mount]
nfsdctl version
Error: Operation not supported
nfsdctl listener
Error: Operation not supported
nfsdctl threads 256
Error: Operation not supported
The command does bring up the server.
These are examples from the man page
I have not invested why... but it just makes
me nervous that examples in the man page
do not work.
I have everything queued up ready to go
so lets work on this during the Bakeathon
next week.
steved.
Jeff Layton
maintainerQuoted 75 lines · Steve Dickson
Hello,
Quoted 49 lines · Jeff Layton
Lorenzo posted an updated version of his netlink interface patches yesterday [1]. This is an update to adapt to those changes, and to bring the tool closer to feature completion for release.
This series first adds Lorenzo's original userland nfsdctl tool to the nfs-utils tree, and then converts it to a subcommand-based interface, in the spirit of tools like nmcli or virsh.
This version should be at feature parity with rpc.nfsd. This posting also includes a manpage and an update to the nfs-server.service to start using the new interface when possible.
I've also included a patch that adds the manpage source. It's much nicer to edit that and regenerate it if we have to update it later. We can drop that patch if you just want to keep the result though.
Assuming we're good with the new kernel interfaces, this should be pretty close to ready for merge.
[1]: https://lore.kernel.org/linux-nfs/[email protected]/
Signed-off-by Jeff Layton <[email protected]>---
Changes in v2:
- Adapt to latest kernel netlink interface changes (in particular, send the leastime and gracetime when they are set in the config).
- More help text for different subcommands
- New nfsdctl(8) manpage
- Patch to make systemd preferentially use nfsdctl instead of rpc.nfsd
- Link to v1: https://lore.kernel.org/r/[email protected]---
Jeff Layton (3):
nfsdctl: convert it to a command-line based interface
nfsdctl: asciidoc source for the manpage
systemd: use nfsdctl to start and stop the nfs serverLorenzo Bianconi (1):
nfsdctl: add the nfsdctl utility to nfs-utilsconfigure.ac | 13 + systemd/nfs-server.service | 4 +- utils/Makefile.am | 4 + utils/nfsdctl/Makefile.am | 13 + utils/nfsdctl/nfsdctl.8 | 274 +++++++++ utils/nfsdctl/nfsdctl.adoc | 140 +++++ utils/nfsdctl/nfsdctl.c | 1401 ++++++++++++++++++++++++++++++++++++++++++++ utils/nfsdctl/nfsdctl.h | 186 ++++++ 8 files changed, 2033 insertions(+), 2 deletions(-)Quoted 5 lines
---
base-commit:117102ee541f38fd7d9274feb8b5586f88d4f655
change-id: 20240412-nfsdctl-fa8bd8430cfdBest regards,
I'm not sure this is ready for prime time....
nfsdctl status
[nothing and there is a mount]nfsdctl version
Error: Operation not supportednfsdctl listener
Error: Operation not supportednfsdctl threads 256
Error: Operation not supportedThe command does bring up the server.
These are examples from the man page
Quoted 8 lines
I have not invested why... but it just makes
me nervous that examples in the man page
do not work.I have everything queued up ready to go
so lets work on this during the Bakeathon
next week.
Your kernel needs to have the patches in [1].
Signature · 1 line
Jeff Layton <[email protected]>