[PATCH v2 0/2] nfsd: expose NFSv4 client state through Netlink

From: Prabhakar Pujeri

Date: Mon Aug 31 2026 - 05:39:31 EST


Administrators can inspect NFSv4 clients through the nfsd filesystem, but
collecting a server-wide view requires walking one directory and opening
multiple files for every client. That interface remains useful for detailed
inspection, but it is awkward for monitoring and automation.

Add a compact, privileged query to the existing nfsd Generic Netlink family:

1. Dump basic NFSv4 client identity, address, lease, confirmation,
reclaim, and callback state.
2. Add O(1) snapshots of per-client session and stateid record counts.

The existing nfsd filesystem files and their output remain unchanged. A
companion nfs-utils v2 series adds `nfsdctl clients`; its cover Message-ID is:

<cover.1787988918.git.prabhakar.pujeri@xxxxxxxx>

This reroll intentionally drops the grace-status patch. As discussed with
Chuck, that interface needs an explicitly scoped design that can represent
both current server-wide grace and possible per-export grace in the future.
I will address it in a separate proposal.

Changes since v1:

- replace the raw sockaddr attribute with separate IPv4/IPv6 address,
port, and optional IPv6 scope-ID attributes
- add a nonzero client-table generation and
genl_dump_check_consistent(), so churn marks the dump NLM_F_DUMP_INTR
- replace session-list and stateid-IDR walks under cl_lock with maintained
u64 counters, making every per-client snapshot O(1)
- encode counts as variable-width Netlink uint attributes
- drop the grace-status patch for a separately scoped design
- rebase onto nfsd-testing at 65b583e874b3

Validation performed:

- strict checkpatch on both patches: no errors, warnings, or checks
- YNL regeneration and all 33 schema checks; generated files remained clean
- headers_install and NFS admin-guide and Netlink-spec documentation builds
with SPHINXOPTS=-W
- full x86_64 GCC 16.1.1 kernel/modules build with W=1; no NFSD or
changed-file warnings
- focused NFSD W=1 build and Sparse over every fs/nfsd translation unit:
no findings
- two independent two-vCPU QEMU boots of the exact locally built kernel
- each boot created one live NFSv4.2 client with one session, open stateid,
lock stateid, and delegation stateid, and zero layout stateids
- raw Netlink, nfsdctl, and /proc/fs/nfsd/clients state agreed in both runs
- no kernel warning, Oops, panic, sanitizer report, lockup, or stall

Development assistance: an LLM assisted with review analysis, implementation,
commit-message drafting, and test-harness development; Sparse was used for
static analysis.

Assisted-by: LLM sparse

v1: https://lore.kernel.org/r/cover.1787638668.git.prabhakar.pujeri@xxxxxxxx

Prabhakar Pujeri (2):
nfsd: add a Netlink dump of NFSv4 clients
nfsd: report per-client NFSv4 state usage through Netlink

.../admin-guide/nfs/nfsd-admin-interfaces.rst | 22 ++
Documentation/netlink/specs/nfsd.yaml | 118 ++++++
fs/nfsd/netlink.c | 5 +
fs/nfsd/netlink.h | 1 +
fs/nfsd/netns.h | 1 +
fs/nfsd/nfs4ctl.h | 10 +
fs/nfsd/nfs4layouts.c | 2 +-
fs/nfsd/nfs4state.c | 341 +++++++++++++++++-
fs/nfsd/nfsctl.c | 13 +
fs/nfsd/state.h | 7 +
include/uapi/linux/nfsd_netlink.h | 43 +++
11 files changed, 553 insertions(+), 10 deletions(-)


base-commit: 65b583e874b371d539314272006833653364a06b
--
2.54.0