nfsdctl: list NFSv4 clients
Subsystems (2)
cover nfsdctl: list NFSv4 clients
Add the userspace consumer for the companion NFSD Netlink client-state series, whose cover Message-ID is:
The series mirrors the kernel ABI split:
1. Display the explicit recovery-grace value returned by threads-get.
2. Add a privileged nfsdctl clients table for basic client state.
3. Extend the table with session and stateid record counts.
Attribute presence remains the compatibility boundary. An older kernel omits the grace value, and missing count attributes are displayed as dashes. The bundled UAPI header permits building before the new kernel header is installed. The configure probe requires the final count attribute, so a system header containing only the base client command also falls back to the complete bundled copy.
Validation performed:
- full nfs-utils build at each applicable patch state
- final make check: no failures; one environment-dependent test skipped
- bundled nfsd Netlink UAPI compared byte-for-byte with the kernel copy
- two-vCPU QEMU test with a live NFSv4.2 loopback mount
- grace yes/no transitions displayed by nfsdctl threads
- live client row showing one session, open stateid, lock stateid, and delegation stateid; zero layout stateids
- callback, reclaim, lease, peer-address, and client-ID fields checked
The series is based on the current nfs-utils master branch. The exact base is recorded in the base-commit trailer below.
Prabhakar Pujeri (3):
nfsdctl: report NFSv4 grace state
nfsdctl: add a command to list NFSv4 clients
nfsdctl: display per-client NFSv4 state usage
configure.ac | 2 +- support/include/nfsd_netlink.h | 41 +++++ utils/nfsdctl/nfsdctl.8 | 22 ++- utils/nfsdctl/nfsdctl.adoc | 15 +- utils/nfsdctl/nfsdctl.c | 268 +++++++++++++++++++++++++++++++++ 5 files changed, 345 insertions(+), 3 deletions(-)
base-commit: 67ed1bdb1af1c70a5fd3b377a997401b7676b827
Signature · 1 line
2.54.0
PATCH 1/3 nfsdctl: report NFSv4 grace state
The threads command reports the server's thread configuration, but an operator also needs to know whether the NFSv4 server is accepting normal state operations or only recovery requests.
Display the kernel's new in-grace value when the attribute is present. Checking its presence prevents a new nfsdctl from reporting an older kernel's lack of the attribute as "no".
--- configure.ac | 2 +- support/include/nfsd_netlink.h | 1 + utils/nfsdctl/nfsdctl.8 | 3 ++- utils/nfsdctl/nfsdctl.adoc | 3 ++- utils/nfsdctl/nfsdctl.c | 8 ++++++++ 5 files changed, 14 insertions(+), 3 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_SERVER_STATS_GET;]])], + [[int foo = NFSD_A_SERVER_IN_GRACE;]])], [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 +1 -0
@@ -84,6 +84,7 @@ enum {NFSD_A_SERVER_SCOPE ,NFSD_A_SERVER_MIN_THREADS ,NFSD_A_SERVER_FH_KEY , +NFSD_A_SERVER_IN_GRACE , __NFSD_A_SERVER_MAX,NFSD_A_SERVER_MAX = (__NFSD_A_SERVER_MAX -1 )
utils/nfsdctl/nfsdctl.8 +2 -1
@@ -144,7 +144,8 @@ takes no arguments. Get/set the number of running nfsd threads in each pool. Pass a list of integers 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 in each pool. +get the current number of running threads in each pool and whether the +NFSv4 server is in its recovery grace period. .RE .sp .if n .RS 4
utils/nfsdctl/nfsdctl.adoc +2 -1
@@ -82,7 +82,8 @@ Each subcommand can also accept its own set of options and arguments. The Get/set the number of running nfsd threads in each pool. Pass a list of integers 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 in each pool. + get the current number of running threads in each pool and whether the + NFSv4 server is in its recovery grace period. [source,bash] ----
utils/nfsdctl/nfsdctl.c +8 -0
@@ -311,6 +311,8 @@ static void parse_threads_get(struct genlmsghdr *gnlh)struct nlattr *attr;int rem, pools =0 , i =0 ;uint32_t *pool_threads =NULL ; +bool in_grace = false; +bool have_in_grace = false;nla_for_each_attr (attr,genlmsg_attrdata (gnlh,0 ),genlmsg_attrlen (gnlh,0 ), rem)
@@ -337,6 +339,10 @@ static void parse_threads_get(struct genlmsghdr *gnlh)case NFSD_A_SERVER_MIN_THREADS :printf ("min-threads: %u\n" ,nla_get_u32 (attr));break ; +case NFSD_A_SERVER_IN_GRACE : + in_grace =nla_get_u8 (attr); + have_in_grace = true; +break ;default :break ; }
@@ -346,6 +352,8 @@ static void parse_threads_get(struct genlmsghdr *gnlh)for (i =0 ; i < pools; ++i)printf (" %d" , pool_threads[i]);putchar ('\n' ); +if (have_in_grace) +printf ("in-grace: %s\n" , in_grace ?"yes" :"no" ); }static void parse_pool_mode_get (struct genlmsghdr *gnlh)
Signature · 1 line
2.54.0
PATCH 2/3 nfsdctl: add a command to list NFSv4 clients
In reply to Prabhakar PujeriMonitoring 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. Format both IPv4 and IPv6 socket addresses, including their ports and IPv6 scope IDs. Keep unknown enum values visible as "unknown" so newer kernels remain usable with this client.
Update the bundled UAPI header and require NFSD_CMD_CLIENT_GET before selecting a system copy of that header.
--- configure.ac | 2 +- support/include/nfsd_netlink.h | 35 ++++++ utils/nfsdctl/nfsdctl.8 | 18 +++ utils/nfsdctl/nfsdctl.adoc | 11 ++ utils/nfsdctl/nfsdctl.c | 217 +++++++++++++++++++++++++++++++++ 5 files changed, 282 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_A_SERVER_IN_GRACE;]])], + [[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 +35 -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 ,
@@ -261,6 +281,20 @@ 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_ADDRESS , +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 ,
@@ -281,6 +315,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 +18 -0
@@ -81,6 +81,14 @@ 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. +.RE +.sp \fBlistener\fP .RS 4 Get/set the listening sockets for the server. Run this without arguments to
@@ -260,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 +11 -0
@@ -46,6 +46,13 @@ 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. + *listener*:: Get/set the listening sockets for the server. Run this without arguments to
@@ -139,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 +217 -0
271 lines not on this page · raw message
Signature · 1 line
2.54.0
PATCH 3/3 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.
Display a dash when a count attribute is absent. 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.
--- configure.ac | 2 +- support/include/nfsd_netlink.h | 5 ++++ utils/nfsdctl/nfsdctl.8 | 5 ++-- utils/nfsdctl/nfsdctl.adoc | 5 ++-- utils/nfsdctl/nfsdctl.c | 51 +++++++++++++++++++++++++++++++--- 5 files changed, 59 insertions(+), 9 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
@@ -290,6 +290,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 +3 -2
@@ -85,8 +85,9 @@ 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. +states, lease time remaining, reclaim status, session count, and counts of +open, lock, delegation, and layout stateids. This subcommand requires elevated +privileges. .RE .sp \fBlistener\fP
utils/nfsdctl/nfsdctl.adoc +3 -2
@@ -50,8 +50,9 @@ 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. + states, lease time remaining, reclaim status, session count, and counts of + open, lock, delegation, and layout stateids. This subcommand requires elevated + privileges. *listener*::
utils/nfsdctl/nfsdctl.c +47 -4
95 lines not on this page · raw message
Signature · 1 line
2.54.0
Jeff Layton
maintainerQuoted 45 lines · Prabhakar Pujeri
Add the userspace consumer for the companion NFSD Netlink client-state series, whose cover Message-ID is:
The series mirrors the kernel ABI split:
1. Display the explicit recovery-grace value returned by threads-get.
2. Add a privilegednfsdctl clientstable for basic client state.
3. Extend the table with session and stateid record counts.Attribute presence remains the compatibility boundary. An older kernel omits the grace value, and missing count attributes are displayed as dashes. The bundled UAPI header permits building before the new kernel header is installed. The configure probe requires the final count attribute, so a system header containing only the base client command also falls back to the complete bundled copy.
Validation performed:
- full nfs-utils build at each applicable patch state
- finalmake check: no failures; one environment-dependent test skipped
- bundled nfsd Netlink UAPI compared byte-for-byte with the kernel copy
- two-vCPU QEMU test with a live NFSv4.2 loopback mount
- grace yes/no transitions displayed bynfsdctl threads
- live client row showing one session, open stateid, lock stateid, and delegation stateid; zero layout stateids
- callback, reclaim, lease, peer-address, and client-ID fields checkedThe series is based on the current nfs-utils master branch. The exact base is recorded in the base-commit trailer below.
Prabhakar Pujeri (3):
nfsdctl: report NFSv4 grace state
nfsdctl: add a command to list NFSv4 clients
nfsdctl: display per-client NFSv4 state usageconfigure.ac | 2 +- support/include/nfsd_netlink.h | 41 +++++ utils/nfsdctl/nfsdctl.8 | 22 ++- utils/nfsdctl/nfsdctl.adoc | 15 +- utils/nfsdctl/nfsdctl.c | 268 +++++++++++++++++++++++++++++++++ 5 files changed, 345 insertions(+), 3 deletions(-)
Quoted 1 line
base-commit:
67ed1bdb1af1c70a5fd3b377a997401b7676b827
Sashiko has some comments about this that probably need to be addressed before we apply these. There is potential for a softlockup in patch #3, in particular:
https://sashiko.dev/#/patchset/cover.1787638668.git.prabhakar.pujeri%40dell.com
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 46 lines · Jeff Layton
Quoted 45 lines · Prabhakar Pujeri
Add the userspace consumer for the companion NFSD Netlink client-state series, whose cover Message-ID is:
<[email protected]>The series mirrors the kernel ABI split:
1. Display the explicit recovery-grace value returned by threads-get.
2. Add a privilegednfsdctl clientstable for basic client state.
3. Extend the table with session and stateid record counts.Attribute presence remains the compatibility boundary. An older kernel omits the grace value, and missing count attributes are displayed as dashes. The bundled UAPI header permits building before the new kernel header is installed. The configure probe requires the final count attribute, so a system header containing only the base client command also falls back to the complete bundled copy.
Validation performed:
- full nfs-utils build at each applicable patch state
- finalmake check: no failures; one environment-dependent test skipped
- bundled nfsd Netlink UAPI compared byte-for-byte with the kernel copy
- two-vCPU QEMU test with a live NFSv4.2 loopback mount
- grace yes/no transitions displayed bynfsdctl threads
- live client row showing one session, open stateid, lock stateid, and delegation stateid; zero layout stateids
- callback, reclaim, lease, peer-address, and client-ID fields checkedThe series is based on the current nfs-utils master branch. The exact base is recorded in the base-commit trailer below.
Prabhakar Pujeri (3):
nfsdctl: report NFSv4 grace state
nfsdctl: add a command to list NFSv4 clients
nfsdctl: display per-client NFSv4 state usageconfigure.ac | 2 +- support/include/nfsd_netlink.h | 41 +++++ utils/nfsdctl/nfsdctl.8 | 22 ++- utils/nfsdctl/nfsdctl.adoc | 15 +- utils/nfsdctl/nfsdctl.c | 268 +++++++++++++++++++++++++++++++++ 5 files changed, 345 insertions(+), 3 deletions(-)
Quoted 7 lines
Quoted 1 line
base-commit:
67ed1bdb1af1c70a5fd3b377a997401b7676b827Sashiko has some comments about this that probably need to be addressed before we apply these. There is potential for a softlockup in patch #3, in particular:
https://sashiko.dev/#/patchset/cover.1787638668.git.prabhakar.pujeri%40dell.com
Okay... I'll wait to apply them until things get sorted out... but I will keep them on my todo list...
steved.