Skip to contentSkip to conversation

nfsdctl: new nfs-utils tool for managing the kernel NFS server

RFC PATCH Superseded Jeff Layton 1 participant 3 messages Apr 12, 2024

Subsystems (2)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Jeff Layton

author maintainer
#0 lore raw

cover nfsdctl: new nfs-utils tool for managing the kernel NFS server

With Lorenzo's addition [1] of new kernel netlink interfaces, it's a good time to revisit how the kernel server is managed from userland.

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 is not quite at feature parity with rpc.nfsd(8) yet, at least as far as autostart supporting options in /etc/nfs.conf. We need a way to set the grace-time and lease-time. This also lacks a manpage and a lot of needed --help text, so it's not ready for merge yet.

Consider this a request for early feedback: Does this seem like a reasonable approach for managing the server?

[1]: https://lore.kernel.org/linux-nfs/[email protected]/

---
Jeff Layton (1):
nfsdctl: convert it to a command-line based interface

Lorenzo Bianconi (1):
nfsdctl: add the nfsdctl utility to nfs-utils

 configure.ac              |   13 +
 utils/Makefile.am         |    4 +
 utils/nfsdctl/Makefile.am |   10 +
 utils/nfsdctl/nfsdctl.c   | 1321 +++++++++++++++++++++++++++++++++++++++++++++
 utils/nfsdctl/nfsdctl.h   |  184 +++++++
 5 files changed, 1532 insertions(+)

---
base-commit: 4aaa812366170c5671a99eaca4d814cbf310cfd1
change-id: 20240412-nfsdctl-fa8bd8430cfd

Best regards,

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

RFC PATCH 1/2 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
index 58d1728c5bc6..ec5eea79a957 100644
@@ -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
index ab584190f17e..e5cb81e796bd 100644
@@ -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
new file mode 100644
index 000000000000..9b8484a81a3f
@@ -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
author maintainer
#2 lore raw

RFC PATCH 2/2 nfsdctl: convert it to a command-line based interface

In reply to Jeff Layton

Lorenzo'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.conf

Each can take different options, and we can expand this interface later with more commands as necessary.

---
 configure.ac              |    1 +
 utils/nfsdctl/Makefile.am |    4 +-
 utils/nfsdctl/nfsdctl.c   | 1202 +++++++++++++++++++++++++++++++++++++--------
 utils/nfsdctl/nfsdctl.h   |    1 +
 4 files changed, 1000 insertions(+), 208 deletions(-)
configure.ac +1 -0
index ec5eea79a957..f965865465ae 100644
@@ -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 +2 -2
index 9b8484a81a3f..c8522f50d4f8 100644
@@ -4,7 +4,7 @@ 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.c +996 -206

1,366 lines not on this page · raw message

utils/nfsdctl/nfsdctl.h +1 -0
index 6084435c05d9..02c6122f807a 100644
@@ -39,6 +39,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