History

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.

Jeff Layton committed 4 months ago

Commit 36ed32f1 parent c1cd8445 files · +369 −0Browse files

Showing the changes to include/uapi (1 of 5 files). Show all

Unified · Split

include/uapi/linux/nfsd_netlink.h+35−0
@@ -225,6 +225,40 @@ enum { · 224 unmodified lines
225225 NFSD_A_UNLOCK_EXPORT_MAX = (__NFSD_A_UNLOCK_EXPORT_MAX - 1)
226226 };
227227
228+enum {
229+ NFSD_A_SERVER_PROC_ENTRY_OP = 1,
230+ NFSD_A_SERVER_PROC_ENTRY_COUNT,
231+ NFSD_A_SERVER_PROC_ENTRY_PAD,
232+
233+ __NFSD_A_SERVER_PROC_ENTRY_MAX,
234+ NFSD_A_SERVER_PROC_ENTRY_MAX = (__NFSD_A_SERVER_PROC_ENTRY_MAX - 1)
235+};
236+
237+enum {
238+ NFSD_A_SERVER_STATS_RC_HITS = 1,
239+ NFSD_A_SERVER_STATS_RC_MISSES,
240+ NFSD_A_SERVER_STATS_RC_NOCACHE,
241+ NFSD_A_SERVER_STATS_PAD,
242+ NFSD_A_SERVER_STATS_FH_STALE,
243+ NFSD_A_SERVER_STATS_IO_READ,
244+ NFSD_A_SERVER_STATS_IO_WRITE,
245+ NFSD_A_SERVER_STATS_NETCNT,
246+ NFSD_A_SERVER_STATS_NETUDPCNT,
247+ NFSD_A_SERVER_STATS_NETTCPCNT,
248+ NFSD_A_SERVER_STATS_NETTCPCONN,
249+ NFSD_A_SERVER_STATS_RPCCNT,
250+ NFSD_A_SERVER_STATS_RPCBADFMT,
251+ NFSD_A_SERVER_STATS_RPCBADAUTH,
252+ NFSD_A_SERVER_STATS_RPCBADCLNT,
253+ NFSD_A_SERVER_STATS_PROC2_OPS,
254+ NFSD_A_SERVER_STATS_PROC3_OPS,
255+ NFSD_A_SERVER_STATS_PROC4_OPS,
256+ NFSD_A_SERVER_STATS_PROC4OPS_OPS,
257+
258+ __NFSD_A_SERVER_STATS_MAX,
259+ NFSD_A_SERVER_STATS_MAX = (__NFSD_A_SERVER_STATS_MAX - 1)
260+};
261+
228262 enum {
229263 NFSD_CMD_RPC_STATUS_GET = 1,
230264 NFSD_CMD_THREADS_SET,
@@ -244,6 +278,7 @@ enum { · 13 unmodified lines
244278 NFSD_CMD_UNLOCK_IP,
245279 NFSD_CMD_UNLOCK_FILESYSTEM,
246280 NFSD_CMD_UNLOCK_EXPORT,
281+ NFSD_CMD_SERVER_STATS_GET,
247282
248283 __NFSD_CMD_MAX,
249284 NFSD_CMD_MAX = (__NFSD_CMD_MAX - 1)