NFSD: Expose callback statistics in /proc/net/rpc/nfsd
Subsystems (2)
Dai Ngo
reviewerPATCH 1/1 NFSD: Expose callback statistics in /proc/net/rpc/nfsd
Extend /proc/net/rpc/nfsd output to report NFSv4 callback activity:
. Add system-wide counters for each callback operation.
. Add per-client callback operation statistics, similar to mountstats(8)
raw format.
--- fs/nfsd/nfs4callback.c | 33 ++++++++++++++++++++++++++++++++- fs/nfsd/nfsd.h | 1 + fs/nfsd/stats.c | 2 ++ 3 files changed, 35 insertions(+), 1 deletion(-)
fs/nfsd/nfs4callback.c +32 -1
@@ -36,6 +36,7 @@#include <linux/sunrpc/xprt.h> #include <linux/sunrpc/svc_xprt.h> #include <linux/slab.h> +#include <linux/sunrpc/metrics.h> #include "nfsd.h" #include "state.h" #include "netns.h"
@@ -1016,7 +1017,7 @@ static int nfs4_xdr_dec_cb_offload(struct rpc_rqst *rqstp, .p_decode = nfs4_xdr_dec_##restype, \ .p_arglen = NFS4_enc_##argtype##_sz, \ .p_replen = NFS4_dec_##restype##_sz, \ - .p_statidx = NFSPROC4_CB_##call, \ + .p_statidx = NFSPROC4_CLNT_##proc, \ .p_name = #proc, \ }
@@ -1786,3 +1787,33 @@ bool nfsd4_run_cb(struct nfsd4_callback *cb)nfsd41_cb_inflight_end (clp);return queued; } + +void nfsd4_show_cb_stats (struct nfsd_net *nn,struct seq_file *seq) +{ +const struct rpc_procinfo *pinfo; +const struct rpc_version *ver; +struct nfs4_client *clp; +int ix; + +/* display system-wide status, count per op */ + ver = cb_program.version[1 ]; +for (ix =0 ; ix < ver->nrprocs; ix++) { + pinfo = &ver->procs[ix]; +if (pinfo->p_name) +seq_printf (seq,"%s: %d\n" , + pinfo->p_name, ver->counts[pinfo->p_statidx]); + } + +/* display per-client status, similar to mountstats(8) in raw format */ +spin_lock (&nn->client_lock); +for (ix =0 ; ix <CLIENT_HASH_SIZE ; ix++) { +list_for_each_entry (clp, &nn->conf_id_hashtbl[ix], cl_idhash) { +if (!clp->cl_cb_client) +continue ; +seq_printf (seq,"\nClient[%pISpc]:\n" , + (struct sockaddr *)&clp->cl_addr); +rpc_clnt_show_stats (seq, clp->cl_cb_client); + } + } +spin_unlock (&nn->client_lock); +}
fs/nfsd/nfsd.h +1 -0
@@ -591,6 +591,7 @@ extern void nfsd4_ssc_init_umount_work(struct nfsd_net *nn);#endif extern void nfsd4_init_leases_net (struct nfsd_net *nn); +void nfsd4_show_cb_stats (struct nfsd_net *nn,struct seq_file *seq);#else /* CONFIG_NFSD_V4 */ static inline int nfsd4_is_junction (struct dentry *dentry)
fs/nfsd/stats.c +2 -0
@@ -66,6 +66,8 @@ static int nfsd_show(struct seq_file *seq, void *v) percpu_counter_sum_positive(&nn->counter[NFSD_STATS_WDELEG_GETATTR]));seq_putc (seq,'\n' ); + +nfsd4_show_cb_stats (nn, seq);#endif return 0 ;
Signature · 1 line
2.47.3
Chuck Lever
maintainerHello Dai!
Quoted 5 lines · Dai Ngo
Extend
/proc/net/rpc/nfsdoutput to report NFSv4 callback activity:. Add system-wide counters for each callback operation.
. Add per-client callback operation statistics, similar to mountstats(8)
raw format.
The commit message needs to justify why you are modifying a legacy /proc interface. I assume it is because you want these metrics to appear in an existing NFS administrative tool like nfsstat ?
Quoted 89 lines
Signed-off-by Dai Ngo <[email protected]>--- fs/nfsd/nfs4callback.c | 33 ++++++++++++++++++++++++++++++++- fs/nfsd/nfsd.h | 1 + fs/nfsd/stats.c | 2 ++ 3 files changed, 35 insertions(+), 1 deletion(-)fs/nfsd/nfs4callback.c +32
-1@@ -36,6 +36,7 @@#include <linux/sunrpc/xprt.h> #include <linux/sunrpc/svc_xprt.h> #include <linux/slab.h> +#include <linux/sunrpc/metrics.h> #include "nfsd.h" #include "state.h" #include "netns.h" @@ -1016,7 +1017,7 @@ static int nfs4_xdr_dec_cb_offload(struct rpc_rqst *rqstp, .p_decode = nfs4_xdr_dec_##restype, \ .p_arglen = NFS4_enc_##argtype##_sz, \ .p_replen = NFS4_dec_##restype##_sz, \ - .p_statidx = NFSPROC4_CB_##call, \ + .p_statidx = NFSPROC4_CLNT_##proc, \ .p_name = #proc, \ }@@ -1786,3 +1787,33 @@ bool nfsd4_run_cb(struct nfsd4_callback *cb)nfsd41_cb_inflight_end (clp);return queued; } + +void nfsd4_show_cb_stats (struct nfsd_net *nn,struct seq_file *seq) +{ +const struct rpc_procinfo *pinfo; +const struct rpc_version *ver; +struct nfs4_client *clp; +int ix; + +/* display system-wide status, count per op */ + ver = cb_program.version[1 ]; +for (ix =0 ; ix < ver->nrprocs; ix++) { + pinfo = &ver->procs[ix]; +if (pinfo->p_name) +seq_printf (seq,"%s: %d\n" , + pinfo->p_name, ver->counts[pinfo->p_statidx]); + } + +/* display per-client status, similar to mountstats(8) in raw format */ +spin_lock (&nn->client_lock); +for (ix =0 ; ix <CLIENT_HASH_SIZE ; ix++) { +list_for_each_entry (clp, &nn->conf_id_hashtbl[ix], cl_idhash) { +if (!clp->cl_cb_client) +continue ; +seq_printf (seq,"\nClient[%pISpc]:\n" , + (struct sockaddr *)&clp->cl_addr); +rpc_clnt_show_stats (seq, clp->cl_cb_client); + } + } +spin_unlock (&nn->client_lock); +}fs/nfsd/nfsd.h +1
-0@@ -591,6 +591,7 @@ extern void nfsd4_ssc_init_umount_work(struct nfsd_net *nn);#endif extern void nfsd4_init_leases_net (struct nfsd_net *nn); +void nfsd4_show_cb_stats (struct nfsd_net *nn,struct seq_file *seq);#else /* CONFIG_NFSD_V4 */ static inline int nfsd4_is_junction (struct dentry *dentry)fs/nfsd/stats.c +2
-0@@ -66,6 +66,8 @@ static int nfsd_show(struct seq_file *seq, void *v) percpu_counter_sum_positive(&nn->counter[NFSD_STATS_WDELEG_GETATTR]));seq_putc (seq,'\n' ); + +nfsd4_show_cb_stats (nn, seq);#endif return 0 ;Signature · 1 line
2.47.3
Signature · 1 line
Chuck Lever
Dai Ngo
reviewerQuoted 10 lines · Chuck Lever
Hello Dai!
Quoted 5 lines · Dai Ngo
Extend
/proc/net/rpc/nfsdoutput to report NFSv4 callback activity:. Add system-wide counters for each callback operation.
. Add per-client callback operation statistics, similar to mountstats(8)
raw format.The commit message needs to justify why you are modifying a legacy /proc interface.
Oh I did not know /proc is a legacy interface. What is the proper way to display nfsd statistics?
Quoted 2 lines
I assume it is because you want these metrics to
appear in an existing NFS administrative tool like nfsstat ?
I should have made this clearer in the commit message.
nfsd already maintains backchannel statistics, but there's currently no convenient way to view them during normal operation - developers typically have to inspect a vmcore.
This patch addresses that gap by adding the backchannel statistics to the existing output of /proc/net/rpc/nfsd.
At this time, I don't plan to extend nfsstat(8) to report these statistics, as this patch is intended for developer use only.
-Dai
Quoted 91 lines
Quoted 91 lines
Signed-off-by Dai Ngo <[email protected]>--- fs/nfsd/nfs4callback.c | 33 ++++++++++++++++++++++++++++++++- fs/nfsd/nfsd.h | 1 + fs/nfsd/stats.c | 2 ++ 3 files changed, 35 insertions(+), 1 deletion(-)fs/nfsd/nfs4callback.c +32
-1@@ -36,6 +36,7 @@#include <linux/sunrpc/xprt.h> #include <linux/sunrpc/svc_xprt.h> #include <linux/slab.h> +#include <linux/sunrpc/metrics.h> #include "nfsd.h" #include "state.h" #include "netns.h" @@ -1016,7 +1017,7 @@ static int nfs4_xdr_dec_cb_offload(struct rpc_rqst *rqstp, .p_decode = nfs4_xdr_dec_##restype, \ .p_arglen = NFS4_enc_##argtype##_sz, \ .p_replen = NFS4_dec_##restype##_sz, \ - .p_statidx = NFSPROC4_CB_##call, \ + .p_statidx = NFSPROC4_CLNT_##proc, \ .p_name = #proc, \ }@@ -1786,3 +1787,33 @@ bool nfsd4_run_cb(struct nfsd4_callback *cb)nfsd41_cb_inflight_end (clp);return queued; } + +void nfsd4_show_cb_stats (struct nfsd_net *nn,struct seq_file *seq) +{ +const struct rpc_procinfo *pinfo; +const struct rpc_version *ver; +struct nfs4_client *clp; +int ix; + +/* display system-wide status, count per op */ + ver = cb_program.version[1 ]; +for (ix =0 ; ix < ver->nrprocs; ix++) { + pinfo = &ver->procs[ix]; +if (pinfo->p_name) +seq_printf (seq,"%s: %d\n" , + pinfo->p_name, ver->counts[pinfo->p_statidx]); + } + +/* display per-client status, similar to mountstats(8) in raw format */ +spin_lock (&nn->client_lock); +for (ix =0 ; ix <CLIENT_HASH_SIZE ; ix++) { +list_for_each_entry (clp, &nn->conf_id_hashtbl[ix], cl_idhash) { +if (!clp->cl_cb_client) +continue ; +seq_printf (seq,"\nClient[%pISpc]:\n" , + (struct sockaddr *)&clp->cl_addr); +rpc_clnt_show_stats (seq, clp->cl_cb_client); + } + } +spin_unlock (&nn->client_lock); +}fs/nfsd/nfsd.h +1
-0@@ -591,6 +591,7 @@ extern void nfsd4_ssc_init_umount_work(struct nfsd_net *nn);#endif extern void nfsd4_init_leases_net (struct nfsd_net *nn); +void nfsd4_show_cb_stats (struct nfsd_net *nn,struct seq_file *seq);#else /* CONFIG_NFSD_V4 */ static inline int nfsd4_is_junction (struct dentry *dentry)fs/nfsd/stats.c +2
-0@@ -66,6 +66,8 @@ static int nfsd_show(struct seq_file *seq, void *v) percpu_counter_sum_positive(&nn->counter[NFSD_STATS_WDELEG_GETATTR]));seq_putc (seq,'\n' ); + +nfsd4_show_cb_stats (nn, seq);#endif return 0 ;Signature · 1 line
2.47.3
Jeff Layton
maintainerQuoted 6 lines · Dai Ngo
Quoted 5 lines · Chuck Lever
Hello Dai!
Quoted 2 lines · Dai Ngo
Extend
/proc/net/rpc/nfsdoutput to report NFSv4 callback activity:
Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
. Add system-wide counters for each callback operation.
. Add per-client callback operation statistics, similar to mountstats(8)
raw format.The commit message needs to justify why you are modifying a legacy /proc interface.
Oh I did not know /proc is a legacy interface. What is the proper way to display nfsd statistics?
We have a new netlink commands for nfsd that give us request status. It would be good to either extend that or add a new command that allows statistics. Netlink is much better suited for this since it's a lot easier to extend than dealing with procfiles.
Quoted 9 lines
Quoted 2 lines
I assume it is because you want these metrics to
appear in an existing NFS administrative tool like nfsstat ?I should have made this clearer in the commit message.
nfsd already maintains backchannel statistics, but there's currently no convenient way to view them during normal operation - developers typically have to inspect a vmcore.
Quoted 6 lines
This patch addresses that gap by adding the backchannel statistics to the existing output of
/proc/net/rpc/nfsd.At this time, I don't plan to extend nfsstat(8) to report these statistics, as this patch is intended for developer use only.
Even more reason to use netlink then.
Quoted 92 lines
Quoted 92 lines
Quoted 92 lines
Signed-off-by Dai Ngo <[email protected]>--- fs/nfsd/nfs4callback.c | 33 ++++++++++++++++++++++++++++++++- fs/nfsd/nfsd.h | 1 + fs/nfsd/stats.c | 2 ++ 3 files changed, 35 insertions(+), 1 deletion(-)fs/nfsd/nfs4callback.c +32
-1@@ -36,6 +36,7 @@#include <linux/sunrpc/xprt.h> #include <linux/sunrpc/svc_xprt.h> #include <linux/slab.h> +#include <linux/sunrpc/metrics.h> #include "nfsd.h" #include "state.h" #include "netns.h" @@ -1016,7 +1017,7 @@ static int nfs4_xdr_dec_cb_offload(struct rpc_rqst *rqstp, .p_decode = nfs4_xdr_dec_##restype, \ .p_arglen = NFS4_enc_##argtype##_sz, \ .p_replen = NFS4_dec_##restype##_sz, \ - .p_statidx = NFSPROC4_CB_##call, \ + .p_statidx = NFSPROC4_CLNT_##proc, \ .p_name = #proc, \ }@@ -1786,3 +1787,33 @@ bool nfsd4_run_cb(struct nfsd4_callback *cb)nfsd41_cb_inflight_end (clp);return queued; } + +void nfsd4_show_cb_stats (struct nfsd_net *nn,struct seq_file *seq) +{ +const struct rpc_procinfo *pinfo; +const struct rpc_version *ver; +struct nfs4_client *clp; +int ix; + +/* display system-wide status, count per op */ + ver = cb_program.version[1 ]; +for (ix =0 ; ix < ver->nrprocs; ix++) { + pinfo = &ver->procs[ix]; +if (pinfo->p_name) +seq_printf (seq,"%s: %d\n" , + pinfo->p_name, ver->counts[pinfo->p_statidx]); + } + +/* display per-client status, similar to mountstats(8) in raw format */ +spin_lock (&nn->client_lock); +for (ix =0 ; ix <CLIENT_HASH_SIZE ; ix++) { +list_for_each_entry (clp, &nn->conf_id_hashtbl[ix], cl_idhash) { +if (!clp->cl_cb_client) +continue ; +seq_printf (seq,"\nClient[%pISpc]:\n" , + (struct sockaddr *)&clp->cl_addr); +rpc_clnt_show_stats (seq, clp->cl_cb_client); + } + } +spin_unlock (&nn->client_lock); +}fs/nfsd/nfsd.h +1
-0@@ -591,6 +591,7 @@ extern void nfsd4_ssc_init_umount_work(struct nfsd_net *nn);#endif extern void nfsd4_init_leases_net (struct nfsd_net *nn); +void nfsd4_show_cb_stats (struct nfsd_net *nn,struct seq_file *seq);#else /* CONFIG_NFSD_V4 */ static inline int nfsd4_is_junction (struct dentry *dentry)fs/nfsd/stats.c +2
-0@@ -66,6 +66,8 @@ static int nfsd_show(struct seq_file *seq, void *v) percpu_counter_sum_positive(&nn->counter[NFSD_STATS_WDELEG_GETATTR]));seq_putc (seq,'\n' ); + +nfsd4_show_cb_stats (nn, seq);#endif return 0 ;Signature · 1 line
2.47.3
Signature · 1 line
Jeff Layton <[email protected]>
Quoted 3 lines · Dai Ngo
Extend
/proc/net/rpc/nfsdoutput to report NFSv4 callback activity:. Add system-wide counters for each callback operation.
Why system-wide rather than per-net-namespace?
NeilBrown
Quoted 94 lines
. Add per-client callback operation statistics, similar to mountstats(8)
raw format.Signed-off-by Dai Ngo <[email protected]>--- fs/nfsd/nfs4callback.c | 33 ++++++++++++++++++++++++++++++++- fs/nfsd/nfsd.h | 1 + fs/nfsd/stats.c | 2 ++ 3 files changed, 35 insertions(+), 1 deletion(-)fs/nfsd/nfs4callback.c +32
-1@@ -36,6 +36,7 @@#include <linux/sunrpc/xprt.h> #include <linux/sunrpc/svc_xprt.h> #include <linux/slab.h> +#include <linux/sunrpc/metrics.h> #include "nfsd.h" #include "state.h" #include "netns.h" @@ -1016,7 +1017,7 @@ static int nfs4_xdr_dec_cb_offload(struct rpc_rqst *rqstp, .p_decode = nfs4_xdr_dec_##restype, \ .p_arglen = NFS4_enc_##argtype##_sz, \ .p_replen = NFS4_dec_##restype##_sz, \ - .p_statidx = NFSPROC4_CB_##call, \ + .p_statidx = NFSPROC4_CLNT_##proc, \ .p_name = #proc, \ }@@ -1786,3 +1787,33 @@ bool nfsd4_run_cb(struct nfsd4_callback *cb)nfsd41_cb_inflight_end (clp);return queued; } + +void nfsd4_show_cb_stats (struct nfsd_net *nn,struct seq_file *seq) +{ +const struct rpc_procinfo *pinfo; +const struct rpc_version *ver; +struct nfs4_client *clp; +int ix; + +/* display system-wide status, count per op */ + ver = cb_program.version[1 ]; +for (ix =0 ; ix < ver->nrprocs; ix++) { + pinfo = &ver->procs[ix]; +if (pinfo->p_name) +seq_printf (seq,"%s: %d\n" , + pinfo->p_name, ver->counts[pinfo->p_statidx]); + } + +/* display per-client status, similar to mountstats(8) in raw format */ +spin_lock (&nn->client_lock); +for (ix =0 ; ix <CLIENT_HASH_SIZE ; ix++) { +list_for_each_entry (clp, &nn->conf_id_hashtbl[ix], cl_idhash) { +if (!clp->cl_cb_client) +continue ; +seq_printf (seq,"\nClient[%pISpc]:\n" , + (struct sockaddr *)&clp->cl_addr); +rpc_clnt_show_stats (seq, clp->cl_cb_client); + } + } +spin_unlock (&nn->client_lock); +}fs/nfsd/nfsd.h +1
-0@@ -591,6 +591,7 @@ extern void nfsd4_ssc_init_umount_work(struct nfsd_net *nn);#endif extern void nfsd4_init_leases_net (struct nfsd_net *nn); +void nfsd4_show_cb_stats (struct nfsd_net *nn,struct seq_file *seq);#else /* CONFIG_NFSD_V4 */ static inline int nfsd4_is_junction (struct dentry *dentry)fs/nfsd/stats.c +2
-0@@ -66,6 +66,8 @@ static int nfsd_show(struct seq_file *seq, void *v) percpu_counter_sum_positive(&nn->counter[NFSD_STATS_WDELEG_GETATTR]));seq_putc (seq,'\n' ); + +nfsd4_show_cb_stats (nn, seq);#endif return 0 ;Signature · 1 line
2.47.3
Dai Ngo
reviewerQuoted 5 lines · NeilBrown
Quoted 3 lines · Dai Ngo
Extend
/proc/net/rpc/nfsdoutput to report NFSv4 callback activity:. Add system-wide counters for each callback operation.
Why system-wide rather than per-net-namespace?
These counters are currently embedded in cb_program which is defined globally and not in nfsd_net. Am i using the wrong terminology?
-Dai
Quoted 98 lines
NeilBrown
Quoted 94 lines
. Add per-client callback operation statistics, similar to mountstats(8)
raw format.Signed-off-by Dai Ngo <[email protected]>--- fs/nfsd/nfs4callback.c | 33 ++++++++++++++++++++++++++++++++- fs/nfsd/nfsd.h | 1 + fs/nfsd/stats.c | 2 ++ 3 files changed, 35 insertions(+), 1 deletion(-)fs/nfsd/nfs4callback.c +32
-1@@ -36,6 +36,7 @@#include <linux/sunrpc/xprt.h> #include <linux/sunrpc/svc_xprt.h> #include <linux/slab.h> +#include <linux/sunrpc/metrics.h> #include "nfsd.h" #include "state.h" #include "netns.h" @@ -1016,7 +1017,7 @@ static int nfs4_xdr_dec_cb_offload(struct rpc_rqst *rqstp, .p_decode = nfs4_xdr_dec_##restype, \ .p_arglen = NFS4_enc_##argtype##_sz, \ .p_replen = NFS4_dec_##restype##_sz, \ - .p_statidx = NFSPROC4_CB_##call, \ + .p_statidx = NFSPROC4_CLNT_##proc, \ .p_name = #proc, \ }@@ -1786,3 +1787,33 @@ bool nfsd4_run_cb(struct nfsd4_callback *cb)nfsd41_cb_inflight_end (clp);return queued; } + +void nfsd4_show_cb_stats (struct nfsd_net *nn,struct seq_file *seq) +{ +const struct rpc_procinfo *pinfo; +const struct rpc_version *ver; +struct nfs4_client *clp; +int ix; + +/* display system-wide status, count per op */ + ver = cb_program.version[1 ]; +for (ix =0 ; ix < ver->nrprocs; ix++) { + pinfo = &ver->procs[ix]; +if (pinfo->p_name) +seq_printf (seq,"%s: %d\n" , + pinfo->p_name, ver->counts[pinfo->p_statidx]); + } + +/* display per-client status, similar to mountstats(8) in raw format */ +spin_lock (&nn->client_lock); +for (ix =0 ; ix <CLIENT_HASH_SIZE ; ix++) { +list_for_each_entry (clp, &nn->conf_id_hashtbl[ix], cl_idhash) { +if (!clp->cl_cb_client) +continue ; +seq_printf (seq,"\nClient[%pISpc]:\n" , + (struct sockaddr *)&clp->cl_addr); +rpc_clnt_show_stats (seq, clp->cl_cb_client); + } + } +spin_unlock (&nn->client_lock); +}fs/nfsd/nfsd.h +1
-0@@ -591,6 +591,7 @@ extern void nfsd4_ssc_init_umount_work(struct nfsd_net *nn);#endif extern void nfsd4_init_leases_net (struct nfsd_net *nn); +void nfsd4_show_cb_stats (struct nfsd_net *nn,struct seq_file *seq);#else /* CONFIG_NFSD_V4 */ static inline int nfsd4_is_junction (struct dentry *dentry)fs/nfsd/stats.c +2
-0@@ -66,6 +66,8 @@ static int nfsd_show(struct seq_file *seq, void *v) percpu_counter_sum_positive(&nn->counter[NFSD_STATS_WDELEG_GETATTR]));seq_putc (seq,'\n' ); + +nfsd4_show_cb_stats (nn, seq);#endif return 0 ;Signature · 1 line
2.47.3
Quoted 9 lines · Dai Ngo
Quoted 5 lines · NeilBrown
Quoted 3 lines · Dai Ngo
Extend
/proc/net/rpc/nfsdoutput to report NFSv4 callback activity:. Add system-wide counters for each callback operation.
Why system-wide rather than per-net-namespace?
These counters are currently embedded in
cb_programwhich is defined globally and not innfsd_net. Am i using the wrong terminology?
Sorry - I hadn't properly processed that these are existing statistics and you are only exporting them.
So I change my comment to: please don't do that. I don't think it is appropriate to export global statistics. We should only export per-net-namespace statistics.
So place convert the statistics collect to per-net-namespace, then export them.
Thanks,
NeilBrown
Chuck Lever
maintainerQuoted 14 lines · NeilBrown
Quoted 9 lines · Dai Ngo
Quoted 5 lines · NeilBrown
Quoted 3 lines · Dai Ngo
Extend
/proc/net/rpc/nfsdoutput to report NFSv4 callback activity:. Add system-wide counters for each callback operation.
Why system-wide rather than per-net-namespace?
These counters are currently embedded in
cb_programwhich is defined globally and not innfsd_net. Am i using the wrong terminology?Sorry - I hadn't properly processed that these are existing statistics and you are only exporting them.
Quoted 6 lines
So I change my comment to: please don't do that. I don't think it is appropriate to export global statistics. We should only export per-net-namespace statistics.
So place convert the statistics collect to per-net-namespace, then export them.
+1
Signature · 1 line
Chuck Lever