[PATCH v6 6/6] nfsd: export NFSv4 callback op stats via netlink
Jeff Layton <[email protected]>
| Newsgroups | gmane.linux.kernel,gmane.linux.nfs |
|---|---|
| Message-ID | <[email protected]> |
Add a proc4cb-ops nested attribute to the server-stats netlink dump, reusing the existing server-proc-entry (op/count) layout. The first dump message emits one entry per callback opcode (OP_CB_GETATTR..OP_CB_OFFLOAD) from the per-netns callback counters; the set is small and fits alongside the scalar stats, so no extra paging is needed. This lets nfsstat report NFSv4 backchannel operation counts over netlink, including CB_GETATTR which corresponds to the procfs wdeleg_getattr line. Assisted-by: Claude:claude-opus-4-8 Signed-off-by: Jeff Layton <[email protected]> --- Documentation/netlink/specs/nfsd.yaml | 6 ++++++ fs/nfsd/nfsctl.c | 21 +++++++++++++++++++++ include/uapi/linux/nfsd_netlink.h | 1 + 3 files changed, 28 insertions(+) diff --git a/Documentation/netlink/specs/nfsd.yaml b/Documentation/netlink/specs/nfsd.yaml index 2a89d355ee7b..642268819c6f 100644 --- a/Documentation/netlink/specs/nfsd.yaml +++ b/Documentation/netlink/specs/nfsd.yaml @@ -410,6 +410,11 @@ attribute-sets: type: nest nested-attributes: server-proc-entry multi-attr: true + - + name: proc4cb-ops + type: nest + nested-attributes: server-proc-entry + multi-attr: true operations: list: @@ -621,6 +626,7 @@ operations: - proc3-ops - proc4-ops - proc4ops-ops + - proc4cb-ops mcast-groups: list: diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index 4710415790e2..6e941d8d08e1 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c @@ -2475,6 +2475,27 @@ int nfsd_nl_server_stats_get_dumpit(struct sk_buff *skb, } #ifdef CONFIG_NFSD_V4 + /* NFSv4 callback (backchannel) per-operation counts */ + for (int op = OP_CB_GETATTR; op <= OP_CB_OFFLOAD; op++) { + struct nlattr *nest; + u64 cnt; + + cnt = percpu_counter_sum_positive( + &nn->cb_counter[op]); + + nest = nla_nest_start(skb, + NFSD_A_SERVER_STATS_PROC4CB_OPS); + if (!nest) + goto err_cancel; + if (nla_put_u32(skb, NFSD_A_SERVER_PROC_ENTRY_OP, op) || + nla_put_u64_64bit(skb, NFSD_A_SERVER_PROC_ENTRY_COUNT, + cnt, NFSD_A_SERVER_PROC_ENTRY_PAD)) { + nla_nest_cancel(skb, nest); + goto err_cancel; + } + nla_nest_end(skb, nest); + } + /* NFSv4 individual operation counts */ for (int i = 0; i <= LAST_NFS4_OP; i++) { struct nlattr *nest; diff --git a/include/uapi/linux/nfsd_netlink.h b/include/uapi/linux/nfsd_netlink.h index 3d076d173b1d..87da1d0bb21e 100644 --- a/include/uapi/linux/nfsd_netlink.h +++ b/include/uapi/linux/nfsd_netlink.h @@ -254,6 +254,7 @@ enum { NFSD_A_SERVER_STATS_PROC3_OPS, NFSD_A_SERVER_STATS_PROC4_OPS, NFSD_A_SERVER_STATS_PROC4OPS_OPS, + NFSD_A_SERVER_STATS_PROC4CB_OPS, __NFSD_A_SERVER_STATS_MAX, NFSD_A_SERVER_STATS_MAX = (__NFSD_A_SERVER_STATS_MAX - 1) -- 2.54.0