nfsdctl: list NFSv4 clients
Subsystems (2)
v2 cover nfsdctl: list NFSv4 clients
Add the userspace consumer for the companion NFSD Netlink client-state v2 series, whose cover Message-ID is:
The first patch adds a privileged nfsdctl clients table for basic client identity, address, lease, confirmation, reclaim, and callback state. The second adds session and stateid record counts.
Attribute presence remains the compatibility boundary. Missing count attributes are displayed as dashes. The bundled UAPI header permits building before the new kernel header is installed, while the configure probe selects a system header only when it contains the complete count extension.
Changes since v1:
- decode separate IPv4/IPv6 address, port, and scope-ID attributes instead of raw sockaddr data
- detect NLM_F_DUMP_INTR on client records and NLMSG_DONE, and fail with a retry diagnostic rather than displaying a potentially inconsistent list
- decode variable-width 32-bit or 64-bit uint count attributes and display counts as uint64_t values
- drop the companion grace-status patch with the kernel-side grace patch
Validation performed:
- strict checkpatch on both patches: no errors, warnings, or checks
- full nfs-utils build and make check using the bundled UAPI header: no failures or errors; one environment-dependent test skipped
- full build and make check against headers_install from the final kernel:
no failures or errors; one environment-dependent test skipped
- bundled and kernel-source NFSD UAPI headers compared byte-for-byte
- two independent two-vCPU QEMU boots of the exact companion kernel
- each nfsdctl clients run displayed the expected NFSv4.2 client, loopback peer, lease, callback/reclaim state, one session, one open, one lock, one delegation, and zero layouts
- nfsdctl output agreed with raw Netlink and /proc/fs/nfsd/clients state
Development assistance: an LLM assisted with review analysis, implementation, commit-message drafting, and test-harness development.
v1: https://lore.kernel.org/r/[email protected]
Prabhakar Pujeri (2):
nfsdctl: add a command to list NFSv4 clients
nfsdctl: display per-client NFSv4 state usage
configure.ac | 2 +- support/include/nfsd_netlink.h | 43 +++++ utils/nfsdctl/nfsdctl.8 | 21 +++ utils/nfsdctl/nfsdctl.adoc | 14 ++ utils/nfsdctl/nfsdctl.c | 310 +++++++++++++++++++++++++++++++++ 5 files changed, 389 insertions(+), 1 deletion(-)
base-commit: 67ed1bdb1af1c70a5fd3b377a997401b7676b827
Signature · 1 line
2.54.0
PATCH v2 1/2 nfsdctl: add a command to list NFSv4 clients
Monitoring NFSv4 clients currently requires walking the nfsd filesystem and parsing a separate info file for every client. Add a clients command that consumes the new NFSD_CMD_CLIENT_GET Netlink dump and presents one row per client.
Report the server-generated client ID, peer address, minor version, client state, lease time remaining, reclaim status, and callback state. Decode the peer from separate IPv4 or IPv6 address, port, and scope-ID attributes. Keep unknown enum values visible as "unknown" so newer kernels remain usable with this client.
Detect NLM_F_DUMP_INTR on both client records and NLMSG_DONE. Report an error instead of silently presenting a client list that may have skipped or repeated a record.
Update the bundled UAPI header and require NFSD_CMD_CLIENT_GET before selecting a system copy of that header.
---
Changes since v1:
- decode separate address, port, and scope-ID attributes
- reject interrupted dumps and ask the administrator to retry
configure.ac | 2 +- support/include/nfsd_netlink.h | 38 +++++ utils/nfsdctl/nfsdctl.8 | 19 +++ utils/nfsdctl/nfsdctl.adoc | 12 ++ utils/nfsdctl/nfsdctl.c | 255 +++++++++++++++++++++++++++++++++ 5 files changed, 325 insertions(+), 1 deletion(-)
configure.ac +1 -1
@@ -259,7 +259,7 @@ AC_CHECK_HEADERS(linux/nfsd_netlink.h) # ensure the system netlink headers have the latest features AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <linux/nfsd_netlink.h>]], - [[int foo = NFSD_CMD_SERVER_STATS_GET;]])], + [[int foo = NFSD_CMD_CLIENT_GET;]])], [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>]],
support/include/nfsd_netlink.h +38 -0
@@ -50,6 +50,26 @@ enum nfsd_xprtsec_mode { NFSD_XPRTSEC_MODE_MTLS = 4, }; +/* +* State of an NFSv4 client record. +*/ +enum nfsd_client_state { +NFSD_CLIENT_STATE_UNCONFIRMED , +NFSD_CLIENT_STATE_ACTIVE , +NFSD_CLIENT_STATE_COURTESY , +NFSD_CLIENT_STATE_EXPIRABLE , +}; + +/* +* State of an NFSv4 client's callback channel. +*/ +enum nfsd_callback_state { +NFSD_CALLBACK_STATE_UP , +NFSD_CALLBACK_STATE_UNKNOWN , +NFSD_CALLBACK_STATE_DOWN , +NFSD_CALLBACK_STATE_FAULT , +}; +enum {NFSD_A_CACHE_NOTIFY_CACHE_TYPE =1 ,
@@ -260,6 +280,23 @@ enum {NFSD_A_SERVER_STATS_MAX = (__NFSD_A_SERVER_STATS_MAX -1 ) }; +enum { +NFSD_A_CLIENT_CLIENTID =1 , +NFSD_A_CLIENT_PAD , +NFSD_A_CLIENT_ADDRESS4 , +NFSD_A_CLIENT_ADDRESS6 , +NFSD_A_CLIENT_ADDRESS_PORT , +NFSD_A_CLIENT_ADDRESS_SCOPE_ID , +NFSD_A_CLIENT_MINOR_VERSION , +NFSD_A_CLIENT_STATE , +NFSD_A_CLIENT_LEASE_REMAINING , +NFSD_A_CLIENT_RECLAIM_COMPLETE , +NFSD_A_CLIENT_CALLBACK_STATE , + + __NFSD_A_CLIENT_MAX, +NFSD_A_CLIENT_MAX = (__NFSD_A_CLIENT_MAX -1 ) +}; +enum {NFSD_CMD_RPC_STATUS_GET =1 ,NFSD_CMD_THREADS_SET ,
@@ -280,6 +317,7 @@ enum {NFSD_CMD_UNLOCK_FILESYSTEM ,NFSD_CMD_UNLOCK_EXPORT ,NFSD_CMD_SERVER_STATS_GET , +NFSD_CMD_CLIENT_GET , __NFSD_CMD_MAX,NFSD_CMD_MAX = (__NFSD_CMD_MAX -1 )
utils/nfsdctl/nfsdctl.8 +19 -0
@@ -81,6 +81,15 @@ This subcommand takes no arguments. Note that if a "threads=" value is not set i nfs.conf, 16 server threads will be brought online. .RE .sp +\fBclients\fP +.RS 4 +List NFSv4 clients known to the server. The output reports each client\(cqs +server-generated client ID, peer address, minor version, lease and callback +states, lease time remaining, and reclaim status. This subcommand requires +elevated privileges. If the client set changes in a way that interrupts the +dump, the command reports an error and should be retried. +.RE +.sp \fBlistener\fP .RS 4 Get/set the listening sockets for the server. Run this without arguments to
@@ -259,6 +268,16 @@ nfsdctl listener .fi .if n .RE .sp +Show the NFSv4 clients known to the server: +.sp +.if n .RS 4 +.nf +.fam C +nfsdctl clients +.fam +.fi +.if n .RE +.sp Show the supported and enabled NFS versions: .sp .if n .RS 4
utils/nfsdctl/nfsdctl.adoc +12 -0
@@ -46,6 +46,14 @@ Each subcommand can also accept its own set of options and arguments. The This subcommand takes no arguments. Note that if a "threads=" value is not set in nfs.conf, 16 server threads will be brought online. +*clients*:: + + List NFSv4 clients known to the server. The output reports each client's + server-generated client ID, peer address, minor version, lease and callback + states, lease time remaining, and reclaim status. This subcommand requires + elevated privileges. If the client set changes in a way that interrupts the + dump, the command reports an error and should be retried. + *listener*:: Get/set the listening sockets for the server. Run this without arguments to
@@ -138,6 +146,10 @@ Get a list of current listening sockets: nfsdctl listener +Show the NFSv4 clients known to the server: + + nfsdctl clients + Show the supported and enabled NFS versions: nfsdctl version
utils/nfsdctl/nfsdctl.c +255 -0
315 lines not on this page · raw message
Signature · 1 line
2.54.0
PATCH v2 2/2 nfsdctl: display per-client NFSv4 state usage
In reply to Prabhakar PujeriExtend the clients table with the session and stateid record counts exported by NFSD. These totals help an operator identify which client is retaining server-side state before using the detailed nfsd filesystem views.
Decode both four-byte and eight-byte representations of the Netlink uint attributes and display the complete u64 value. Display a dash when a count attribute is absent or malformed. This keeps the command accurate when a new nfsdctl is used with a kernel that supports the base client dump but not the count extension.
Require the last count attribute before selecting the system UAPI header so building against a header with only the base command still uses the bundled copy.
---
Changes since v1:
- decode 32-bit and 64-bit variable-width uint count attributes
- store and format all counts as uint64_t values
configure.ac | 2 +- support/include/nfsd_netlink.h | 5 +++ utils/nfsdctl/nfsdctl.8 | 8 +++-- utils/nfsdctl/nfsdctl.adoc | 8 +++-- utils/nfsdctl/nfsdctl.c | 63 +++++++++++++++++++++++++++++++--- 5 files changed, 75 insertions(+), 11 deletions(-)
configure.ac +1 -1
@@ -259,7 +259,7 @@ AC_CHECK_HEADERS(linux/nfsd_netlink.h) # ensure the system netlink headers have the latest features AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <linux/nfsd_netlink.h>]], - [[int foo = NFSD_CMD_CLIENT_GET;]])], + [[int foo = NFSD_A_CLIENT_LAYOUT_STATEIDS;]])], [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>]],
support/include/nfsd_netlink.h +5 -0
@@ -292,6 +292,11 @@ enum {NFSD_A_CLIENT_LEASE_REMAINING ,NFSD_A_CLIENT_RECLAIM_COMPLETE ,NFSD_A_CLIENT_CALLBACK_STATE , +NFSD_A_CLIENT_SESSIONS , +NFSD_A_CLIENT_OPEN_STATEIDS , +NFSD_A_CLIENT_LOCK_STATEIDS , +NFSD_A_CLIENT_DELEGATION_STATEIDS , +NFSD_A_CLIENT_LAYOUT_STATEIDS , __NFSD_A_CLIENT_MAX,NFSD_A_CLIENT_MAX = (__NFSD_A_CLIENT_MAX -1 )
utils/nfsdctl/nfsdctl.8 +5 -3
@@ -85,9 +85,11 @@ nfs.conf, 16 server threads will be brought online. .RS 4 List NFSv4 clients known to the server. The output reports each client\(cqs server-generated client ID, peer address, minor version, lease and callback -states, lease time remaining, and reclaim status. This subcommand requires -elevated privileges. If the client set changes in a way that interrupts the -dump, the command reports an error and should be retried. +states, lease time remaining, reclaim status, session count, and counts of +open, lock, delegation, and layout stateids. This subcommand requires elevated +privileges. +If the client set changes in a way that interrupts the dump, the command +reports an error and should be retried. .RE .sp \fBlistener\fP
utils/nfsdctl/nfsdctl.adoc +5 -3
@@ -50,9 +50,11 @@ Each subcommand can also accept its own set of options and arguments. The List NFSv4 clients known to the server. The output reports each client's server-generated client ID, peer address, minor version, lease and callback - states, lease time remaining, and reclaim status. This subcommand requires - elevated privileges. If the client set changes in a way that interrupts the - dump, the command reports an error and should be retried. + states, lease time remaining, reclaim status, session count, and counts of + open, lock, delegation, and layout stateids. This subcommand requires elevated + privileges. + If the client set changes in a way that interrupts the dump, the command + reports an error and should be retried. *listener*::
utils/nfsdctl/nfsdctl.c +59 -4
108 lines not on this page · raw message
Signature · 1 line
2.54.0