| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * linux/net/sunrpc/stats.c |
|---|
| 3 | 4 | * |
|---|
| .. | .. |
|---|
| 68 | 69 | return single_open(file, rpc_proc_show, PDE_DATA(inode)); |
|---|
| 69 | 70 | } |
|---|
| 70 | 71 | |
|---|
| 71 | | -static const struct file_operations rpc_proc_fops = { |
|---|
| 72 | | - .owner = THIS_MODULE, |
|---|
| 73 | | - .open = rpc_proc_open, |
|---|
| 74 | | - .read = seq_read, |
|---|
| 75 | | - .llseek = seq_lseek, |
|---|
| 76 | | - .release = single_release, |
|---|
| 72 | +static const struct proc_ops rpc_proc_ops = { |
|---|
| 73 | + .proc_open = rpc_proc_open, |
|---|
| 74 | + .proc_read = seq_read, |
|---|
| 75 | + .proc_lseek = seq_lseek, |
|---|
| 76 | + .proc_release = single_release, |
|---|
| 77 | 77 | }; |
|---|
| 78 | 78 | |
|---|
| 79 | 79 | /* |
|---|
| .. | .. |
|---|
| 176 | 176 | |
|---|
| 177 | 177 | execute = ktime_sub(now, task->tk_start); |
|---|
| 178 | 178 | op_metrics->om_execute = ktime_add(op_metrics->om_execute, execute); |
|---|
| 179 | + if (task->tk_status < 0) |
|---|
| 180 | + op_metrics->om_error_status++; |
|---|
| 179 | 181 | |
|---|
| 180 | 182 | spin_unlock(&op_metrics->om_lock); |
|---|
| 181 | 183 | |
|---|
| .. | .. |
|---|
| 218 | 220 | a->om_queue = ktime_add(a->om_queue, b->om_queue); |
|---|
| 219 | 221 | a->om_rtt = ktime_add(a->om_rtt, b->om_rtt); |
|---|
| 220 | 222 | a->om_execute = ktime_add(a->om_execute, b->om_execute); |
|---|
| 223 | + a->om_error_status += b->om_error_status; |
|---|
| 221 | 224 | } |
|---|
| 222 | 225 | |
|---|
| 223 | 226 | static void _print_rpc_iostats(struct seq_file *seq, struct rpc_iostats *stats, |
|---|
| 224 | 227 | int op, const struct rpc_procinfo *procs) |
|---|
| 225 | 228 | { |
|---|
| 226 | 229 | _print_name(seq, op, procs); |
|---|
| 227 | | - seq_printf(seq, "%lu %lu %lu %Lu %Lu %Lu %Lu %Lu\n", |
|---|
| 230 | + seq_printf(seq, "%lu %lu %lu %llu %llu %llu %llu %llu %lu\n", |
|---|
| 228 | 231 | stats->om_ops, |
|---|
| 229 | 232 | stats->om_ntrans, |
|---|
| 230 | 233 | stats->om_timeouts, |
|---|
| .. | .. |
|---|
| 232 | 235 | stats->om_bytes_recv, |
|---|
| 233 | 236 | ktime_to_ms(stats->om_queue), |
|---|
| 234 | 237 | ktime_to_ms(stats->om_rtt), |
|---|
| 235 | | - ktime_to_ms(stats->om_execute)); |
|---|
| 238 | + ktime_to_ms(stats->om_execute), |
|---|
| 239 | + stats->om_error_status); |
|---|
| 240 | +} |
|---|
| 241 | + |
|---|
| 242 | +static int do_print_stats(struct rpc_clnt *clnt, struct rpc_xprt *xprt, void *seqv) |
|---|
| 243 | +{ |
|---|
| 244 | + struct seq_file *seq = seqv; |
|---|
| 245 | + |
|---|
| 246 | + xprt->ops->print_stats(xprt, seq); |
|---|
| 247 | + return 0; |
|---|
| 236 | 248 | } |
|---|
| 237 | 249 | |
|---|
| 238 | 250 | void rpc_clnt_show_stats(struct seq_file *seq, struct rpc_clnt *clnt) |
|---|
| 239 | 251 | { |
|---|
| 240 | | - struct rpc_xprt *xprt; |
|---|
| 241 | 252 | unsigned int op, maxproc = clnt->cl_maxproc; |
|---|
| 242 | 253 | |
|---|
| 243 | 254 | if (!clnt->cl_metrics) |
|---|
| .. | .. |
|---|
| 247 | 258 | seq_printf(seq, "p/v: %u/%u (%s)\n", |
|---|
| 248 | 259 | clnt->cl_prog, clnt->cl_vers, clnt->cl_program->name); |
|---|
| 249 | 260 | |
|---|
| 250 | | - rcu_read_lock(); |
|---|
| 251 | | - xprt = rcu_dereference(clnt->cl_xprt); |
|---|
| 252 | | - if (xprt) |
|---|
| 253 | | - xprt->ops->print_stats(xprt, seq); |
|---|
| 254 | | - rcu_read_unlock(); |
|---|
| 261 | + rpc_clnt_iterate_for_each_xprt(clnt, do_print_stats, seq); |
|---|
| 255 | 262 | |
|---|
| 256 | 263 | seq_printf(seq, "\tper-op statistics\n"); |
|---|
| 257 | 264 | for (op = 0; op < maxproc; op++) { |
|---|
| .. | .. |
|---|
| 273 | 280 | */ |
|---|
| 274 | 281 | static inline struct proc_dir_entry * |
|---|
| 275 | 282 | do_register(struct net *net, const char *name, void *data, |
|---|
| 276 | | - const struct file_operations *fops) |
|---|
| 283 | + const struct proc_ops *proc_ops) |
|---|
| 277 | 284 | { |
|---|
| 278 | 285 | struct sunrpc_net *sn; |
|---|
| 279 | 286 | |
|---|
| 280 | 287 | dprintk("RPC: registering /proc/net/rpc/%s\n", name); |
|---|
| 281 | 288 | sn = net_generic(net, sunrpc_net_id); |
|---|
| 282 | | - return proc_create_data(name, 0, sn->proc_net_rpc, fops, data); |
|---|
| 289 | + return proc_create_data(name, 0, sn->proc_net_rpc, proc_ops, data); |
|---|
| 283 | 290 | } |
|---|
| 284 | 291 | |
|---|
| 285 | 292 | struct proc_dir_entry * |
|---|
| 286 | 293 | rpc_proc_register(struct net *net, struct rpc_stat *statp) |
|---|
| 287 | 294 | { |
|---|
| 288 | | - return do_register(net, statp->program->name, statp, &rpc_proc_fops); |
|---|
| 295 | + return do_register(net, statp->program->name, statp, &rpc_proc_ops); |
|---|
| 289 | 296 | } |
|---|
| 290 | 297 | EXPORT_SYMBOL_GPL(rpc_proc_register); |
|---|
| 291 | 298 | |
|---|
| .. | .. |
|---|
| 300 | 307 | EXPORT_SYMBOL_GPL(rpc_proc_unregister); |
|---|
| 301 | 308 | |
|---|
| 302 | 309 | struct proc_dir_entry * |
|---|
| 303 | | -svc_proc_register(struct net *net, struct svc_stat *statp, const struct file_operations *fops) |
|---|
| 310 | +svc_proc_register(struct net *net, struct svc_stat *statp, const struct proc_ops *proc_ops) |
|---|
| 304 | 311 | { |
|---|
| 305 | | - return do_register(net, statp->program->pg_name, statp, fops); |
|---|
| 312 | + return do_register(net, statp->program->pg_name, statp, proc_ops); |
|---|
| 306 | 313 | } |
|---|
| 307 | 314 | EXPORT_SYMBOL_GPL(svc_proc_register); |
|---|
| 308 | 315 | |
|---|