mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-09-12 18:53:40 -04:00
nfsd: implement server-stats-get netlink handler
Implement nfsd_nl_server_stats_get_dumpit() which exposes the
NFS server statistics currently available via /proc/net/rpc/nfsd
through the nfsd generic netlink family.
The handler uses a dump operation to stream statistics across one
or more netlink messages. The reply is divided into sections that
are emitted in order:
- scalar stats (reply cache, filehandle, IO, network, RPC),
emitted once in the first message, then
- per-version procedure counts (proc2/3/4-ops) and the NFSv4
per-operation counts (proc4ops-ops), using the per-netns
vs_count arrays.
cb->args[0] tracks the current section and cb->args[1] the entry
index within it, so a section that does not fit in the current
message is closed and resumed in the next one. This matters because
the first dump message is allocated at NLMSG_GOODSIZE (a single page
on most architectures) regardless of the client's receive buffer;
packing every counter into one message would overflow it and fail
the dump with -EMSGSIZE. Userspace merges the attributes from every
message.
This allows nfsstat to retrieve server statistics via netlink
with a procfs fallback for older kernels.
Assisted-by: LLM
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Link: https://patch.msgid.link/20260717-exportd-netlink-v7-3-b7ce17b83b60@kernel.org
Signed-off-by: Chuck Lever <cel@kernel.org>
This commit is contained in:
@@ -225,6 +225,40 @@ enum {
|
||||
NFSD_A_UNLOCK_EXPORT_MAX = (__NFSD_A_UNLOCK_EXPORT_MAX - 1)
|
||||
};
|
||||
|
||||
enum {
|
||||
NFSD_A_SERVER_PROC_ENTRY_OP = 1,
|
||||
NFSD_A_SERVER_PROC_ENTRY_COUNT,
|
||||
NFSD_A_SERVER_PROC_ENTRY_PAD,
|
||||
|
||||
__NFSD_A_SERVER_PROC_ENTRY_MAX,
|
||||
NFSD_A_SERVER_PROC_ENTRY_MAX = (__NFSD_A_SERVER_PROC_ENTRY_MAX - 1)
|
||||
};
|
||||
|
||||
enum {
|
||||
NFSD_A_SERVER_STATS_RC_HITS = 1,
|
||||
NFSD_A_SERVER_STATS_RC_MISSES,
|
||||
NFSD_A_SERVER_STATS_RC_NOCACHE,
|
||||
NFSD_A_SERVER_STATS_PAD,
|
||||
NFSD_A_SERVER_STATS_FH_STALE,
|
||||
NFSD_A_SERVER_STATS_IO_READ,
|
||||
NFSD_A_SERVER_STATS_IO_WRITE,
|
||||
NFSD_A_SERVER_STATS_NETCNT,
|
||||
NFSD_A_SERVER_STATS_NETUDPCNT,
|
||||
NFSD_A_SERVER_STATS_NETTCPCNT,
|
||||
NFSD_A_SERVER_STATS_NETTCPCONN,
|
||||
NFSD_A_SERVER_STATS_RPCCNT,
|
||||
NFSD_A_SERVER_STATS_RPCBADFMT,
|
||||
NFSD_A_SERVER_STATS_RPCBADAUTH,
|
||||
NFSD_A_SERVER_STATS_RPCBADCLNT,
|
||||
NFSD_A_SERVER_STATS_PROC2_OPS,
|
||||
NFSD_A_SERVER_STATS_PROC3_OPS,
|
||||
NFSD_A_SERVER_STATS_PROC4_OPS,
|
||||
NFSD_A_SERVER_STATS_PROC4OPS_OPS,
|
||||
|
||||
__NFSD_A_SERVER_STATS_MAX,
|
||||
NFSD_A_SERVER_STATS_MAX = (__NFSD_A_SERVER_STATS_MAX - 1)
|
||||
};
|
||||
|
||||
enum {
|
||||
NFSD_CMD_RPC_STATUS_GET = 1,
|
||||
NFSD_CMD_THREADS_SET,
|
||||
@@ -244,6 +278,7 @@ enum {
|
||||
NFSD_CMD_UNLOCK_IP,
|
||||
NFSD_CMD_UNLOCK_FILESYSTEM,
|
||||
NFSD_CMD_UNLOCK_EXPORT,
|
||||
NFSD_CMD_SERVER_STATS_GET,
|
||||
|
||||
__NFSD_CMD_MAX,
|
||||
NFSD_CMD_MAX = (__NFSD_CMD_MAX - 1)
|
||||
|
||||
Reference in New Issue
Block a user