hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/net/sunrpc/stats.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * linux/net/sunrpc/stats.c
34 *
....@@ -68,12 +69,11 @@
6869 return single_open(file, rpc_proc_show, PDE_DATA(inode));
6970 }
7071
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,
7777 };
7878
7979 /*
....@@ -176,6 +176,8 @@
176176
177177 execute = ktime_sub(now, task->tk_start);
178178 op_metrics->om_execute = ktime_add(op_metrics->om_execute, execute);
179
+ if (task->tk_status < 0)
180
+ op_metrics->om_error_status++;
179181
180182 spin_unlock(&op_metrics->om_lock);
181183
....@@ -218,13 +220,14 @@
218220 a->om_queue = ktime_add(a->om_queue, b->om_queue);
219221 a->om_rtt = ktime_add(a->om_rtt, b->om_rtt);
220222 a->om_execute = ktime_add(a->om_execute, b->om_execute);
223
+ a->om_error_status += b->om_error_status;
221224 }
222225
223226 static void _print_rpc_iostats(struct seq_file *seq, struct rpc_iostats *stats,
224227 int op, const struct rpc_procinfo *procs)
225228 {
226229 _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",
228231 stats->om_ops,
229232 stats->om_ntrans,
230233 stats->om_timeouts,
....@@ -232,12 +235,20 @@
232235 stats->om_bytes_recv,
233236 ktime_to_ms(stats->om_queue),
234237 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;
236248 }
237249
238250 void rpc_clnt_show_stats(struct seq_file *seq, struct rpc_clnt *clnt)
239251 {
240
- struct rpc_xprt *xprt;
241252 unsigned int op, maxproc = clnt->cl_maxproc;
242253
243254 if (!clnt->cl_metrics)
....@@ -247,11 +258,7 @@
247258 seq_printf(seq, "p/v: %u/%u (%s)\n",
248259 clnt->cl_prog, clnt->cl_vers, clnt->cl_program->name);
249260
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);
255262
256263 seq_printf(seq, "\tper-op statistics\n");
257264 for (op = 0; op < maxproc; op++) {
....@@ -273,19 +280,19 @@
273280 */
274281 static inline struct proc_dir_entry *
275282 do_register(struct net *net, const char *name, void *data,
276
- const struct file_operations *fops)
283
+ const struct proc_ops *proc_ops)
277284 {
278285 struct sunrpc_net *sn;
279286
280287 dprintk("RPC: registering /proc/net/rpc/%s\n", name);
281288 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);
283290 }
284291
285292 struct proc_dir_entry *
286293 rpc_proc_register(struct net *net, struct rpc_stat *statp)
287294 {
288
- return do_register(net, statp->program->name, statp, &rpc_proc_fops);
295
+ return do_register(net, statp->program->name, statp, &rpc_proc_ops);
289296 }
290297 EXPORT_SYMBOL_GPL(rpc_proc_register);
291298
....@@ -300,9 +307,9 @@
300307 EXPORT_SYMBOL_GPL(rpc_proc_unregister);
301308
302309 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)
304311 {
305
- return do_register(net, statp->program->pg_name, statp, fops);
312
+ return do_register(net, statp->program->pg_name, statp, proc_ops);
306313 }
307314 EXPORT_SYMBOL_GPL(svc_proc_register);
308315