NFS: Fix output of mountstats for NFSv4 state opcodes such as SEQUENCE and RENEW
Subsystems (3)
v2 cover NFS: Fix output of mountstats for NFSv4 state opcodes such as SEQUENCE and RENEW
This patch series fixes the counts for NFSv4 lease and session related opcodes such as SEQUENCE and RENEW. Before this patch series, all of the iostats counts shown in /proc/self/mountstats were always 0. This complicates troubleshooting so I am proposing a small change to the sunrpc interface to print these stats.
The series renames an exported symbol in sunrpc, rpc_print_iostats, to rpc_clnt_show_stats, as described in the header.
As pointed out by Chuck Lever in the RFC patch, the output format remains the same so this series does not change RPC_IOSTATS_VERS. Along with this small change, the patch header in the third patch is slightly changed to better explain the types of opcodes that are now properly counted.
Dave Wysochanski (3):
sunrpc: add _print_rpc_iostats() to output metrics for one RPC op
sunrpc: Add _add_rpc_iostats() to add rpc_iostats metrics
sunrpc: Change rpc_print_iostats to rpc_clnt_show_stats and handle
rpc_clnt clones
fs/nfs/super.c | 2 +- include/linux/sunrpc/metrics.h | 4 ++-- net/sunrpc/stats.c | 54 ++++++++++++++++++++++++++++++------------ 3 files changed, 42 insertions(+), 18 deletions(-)
Signature · 1 line
2.14.3
PATCH v2 1/3 sunrpc: add _print_rpc_iostats() to output metrics for one RPC op
Refactor the output of the metrics for one RPC op into an internal function. No functional change.
--- net/sunrpc/stats.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-)
net/sunrpc/stats.c +16 -11
@@ -208,6 +208,21 @@ static void _print_name(struct seq_file *seq, unsigned int op,seq_printf (seq,"\t%12u: " , op); } +static void _print_rpc_iostats (struct seq_file *seq,struct rpc_iostats *stats, +int op,const struct rpc_procinfo *procs) +{ +_print_name (seq, op, procs); +seq_printf (seq,"%lu %lu %lu %Lu %Lu %Lu %Lu %Lu\n" , + stats->om_ops, + stats->om_ntrans, + stats->om_timeouts, + stats->om_bytes_sent, + stats->om_bytes_recv, +ktime_to_ms (stats->om_queue), +ktime_to_ms (stats->om_rtt), +ktime_to_ms (stats->om_execute)); +} +void rpc_print_iostats (struct seq_file *seq,struct rpc_clnt *clnt) {struct rpc_iostats *stats = clnt->cl_metrics;
@@ -229,17 +244,7 @@ void rpc_print_iostats(struct seq_file *seq, struct rpc_clnt *clnt)seq_printf (seq,"\tper-op statistics\n" );for (op =0 ; op < maxproc; op++) { -struct rpc_iostats *metrics = &stats[op]; -_print_name (seq, op, clnt->cl_procinfo); -seq_printf (seq,"%lu %lu %lu %Lu %Lu %Lu %Lu %Lu\n" , - metrics->om_ops, - metrics->om_ntrans, - metrics->om_timeouts, - metrics->om_bytes_sent, - metrics->om_bytes_recv, -ktime_to_ms (metrics->om_queue), -ktime_to_ms (metrics->om_rtt), -ktime_to_ms (metrics->om_execute)); +_print_rpc_iostats (seq, &stats[op], op, clnt->cl_procinfo); } }EXPORT_SYMBOL_GPL (rpc_print_iostats);
Signature · 1 line
2.14.3
PATCH v2 2/3 sunrpc: Add _add_rpc_iostats() to add rpc_iostats metrics
In reply to Dave WysochanskiAdd a helper function to add the metrics in two rpc_iostats structures.
--- net/sunrpc/stats.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
net/sunrpc/stats.c +12 -0
@@ -208,6 +208,18 @@ static void _print_name(struct seq_file *seq, unsigned int op,seq_printf (seq,"\t%12u: " , op); } +static void _add_rpc_iostats (struct rpc_iostats *a,struct rpc_iostats *b) +{ + a->om_ops += b->om_ops; + a->om_ntrans += b->om_ntrans; + a->om_timeouts += b->om_timeouts; + a->om_bytes_sent += b->om_bytes_sent; + a->om_bytes_recv += b->om_bytes_recv; + a->om_queue =ktime_add (a->om_queue, b->om_queue); + a->om_rtt =ktime_add (a->om_rtt, b->om_rtt); + a->om_execute =ktime_add (a->om_execute, b->om_execute); +} +static void _print_rpc_iostats (struct seq_file *seq,struct rpc_iostats *stats,int op,const struct rpc_procinfo *procs) {
Signature · 1 line
2.14.3
PATCH v2 3/3 sunrpc: Change rpc_print_iostats to rpc_clnt_show_stats and handle rpc_clnt clones
In reply to Dave WysochanskiThe existing rpc_print_iostats has a few shortcomings. First, the naming is not consistent with other functions in the kernel that display stats. Second, it is really displaying stats for an rpc_clnt structure as it displays both xprt stats and per-op stats. Third, it does not handle rpc_clnt clones, which is important for the one in-kernel tree caller of this function, the NFS client's nfs_show_stats function.
Fix all of the above by renaming the rpc_print_iostats to rpc_clnt_show_stats and looping through any rpc_clnt clones via cl_parent.
Once this interface is fixed, this addresses a problem with NFSv4. Before this patch, the /proc/self/mountstats always showed incorrect counts for NFSv4 lease and session related opcodes such as SEQUENCE, RENEW, SETCLIENTID, CREATE_SESSION, etc. These counts were always 0 even though many ops would go over the wire. The reason for this is there are multiple rpc_clnt structures allocated for any given NFSv4 mount, and inside nfs_show_stats() we callled into rpc_print_iostats() which only handled one of them, nfs_server->client. Fix these counts by calling sunrpc's new rpc_clnt_show_stats() function, which handles cloned rpc_clnt structs and prints the stats together.
Note that one side-effect of the above is that multiple mounts from the same NFS server will show identical counts in the above ops due to the fact the one rpc_clnt (representing the NFSv4 client state) is shared across mounts.
--- fs/nfs/super.c | 2 +- include/linux/sunrpc/metrics.h | 4 ++-- net/sunrpc/stats.c | 17 ++++++++++++----- 3 files changed, 15 insertions(+), 8 deletions(-)
fs/nfs/super.c +1 -1
@@ -884,7 +884,7 @@ int nfs_show_stats(struct seq_file *m, struct dentry *root)#endif seq_printf (m,"\n" ); -rpc_print_iostats (m, nfss->client); +rpc_clnt_show_stats (m, nfss->client);return 0 ; }
include/linux/sunrpc/metrics.h +2 -2
@@ -82,7 +82,7 @@ void rpc_count_iostats(const struct rpc_task *, struct rpc_iostats *);void rpc_count_iostats_metrics (const struct rpc_task *,struct rpc_iostats *); -void rpc_print_iostats (struct seq_file *,struct rpc_clnt *); +void rpc_clnt_show_stats (struct seq_file *,struct rpc_clnt *);void rpc_free_iostats (struct rpc_iostats *);#else /* CONFIG_PROC_FS */
@@ -95,7 +95,7 @@ static inline void rpc_count_iostats_metrics(const struct rpc_task *task, { } -static inline void rpc_print_iostats (struct seq_file *seq,struct rpc_clnt *clnt) {} +static inline void rpc_clnt_show_stats (struct seq_file *seq,struct rpc_clnt *clnt) {}static inline void rpc_free_iostats (struct rpc_iostats *stats) {}#endif /* CONFIG_PROC_FS */
net/sunrpc/stats.c +12 -5
@@ -235,13 +235,12 @@ static void _print_rpc_iostats(struct seq_file *seq, struct rpc_iostats *stats, ktime_to_ms(stats->om_execute)); } -void rpc_print_iostats (struct seq_file *seq,struct rpc_clnt *clnt) +void rpc_clnt_show_stats (struct seq_file *seq,struct rpc_clnt *clnt) { -struct rpc_iostats *stats = clnt->cl_metrics;struct rpc_xprt *xprt;unsigned int op, maxproc = clnt->cl_maxproc; -if (!stats) +if (!clnt->cl_metrics)return ;seq_printf (seq,"\tRPC iostats version: %s " ,RPC_IOSTATS_VERS );
@@ -256,10 +255,18 @@ void rpc_print_iostats(struct seq_file *seq, struct rpc_clnt *clnt)seq_printf (seq,"\tper-op statistics\n" );for (op =0 ; op < maxproc; op++) { -_print_rpc_iostats (seq, &stats[op], op, clnt->cl_procinfo); +struct rpc_iostats stats = {0 }; +struct rpc_clnt *next = clnt; +do { +_add_rpc_iostats (&stats, &next->cl_metrics[op]); +if (next == next->cl_parent) +break ; + next = next->cl_parent; + }while (next); +_print_rpc_iostats (seq, &stats, op, clnt->cl_procinfo); } } -EXPORT_SYMBOL_GPL (rpc_print_iostats); +EXPORT_SYMBOL_GPL (rpc_clnt_show_stats);/* * Register/unregister RPC proc files
Signature · 1 line
2.14.3