Thomas Gleixner | 457c899 | 2019-05-19 13:08:55 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
| 3 | * linux/net/sunrpc/stats.c |
| 4 | * |
| 5 | * procfs-based user access to generic RPC statistics. The stats files |
| 6 | * reside in /proc/net/rpc. |
| 7 | * |
| 8 | * The read routines assume that the buffer passed in is just big enough. |
| 9 | * If you implement an RPC service that has its own stats routine which |
| 10 | * appends the generic RPC stats, make sure you don't exceed the PAGE_SIZE |
| 11 | * limit. |
| 12 | * |
| 13 | * Copyright (C) 1995, 1996, 1997 Olaf Kirch <okir@monad.swb.de> |
| 14 | */ |
| 15 | |
| 16 | #include <linux/module.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 17 | #include <linux/slab.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | |
| 19 | #include <linux/init.h> |
| 20 | #include <linux/kernel.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 21 | #include <linux/proc_fs.h> |
| 22 | #include <linux/seq_file.h> |
| 23 | #include <linux/sunrpc/clnt.h> |
| 24 | #include <linux/sunrpc/svcsock.h> |
Chuck Lever | 11c556b | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 25 | #include <linux/sunrpc/metrics.h> |
Trond Myklebust | 2446ab6 | 2012-03-01 17:00:56 -0500 | [diff] [blame] | 26 | #include <linux/rcupdate.h> |
Pavel Emelyanov | 4f42d0d | 2010-09-27 14:01:58 +0400 | [diff] [blame] | 27 | |
Chuck Lever | 40bf7eb | 2018-03-16 10:33:49 -0400 | [diff] [blame] | 28 | #include <trace/events/sunrpc.h> |
| 29 | |
Pavel Emelyanov | 4f42d0d | 2010-09-27 14:01:58 +0400 | [diff] [blame] | 30 | #include "netns.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | |
| 32 | #define RPCDBG_FACILITY RPCDBG_MISC |
| 33 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | /* |
| 35 | * Get RPC client stats |
| 36 | */ |
| 37 | static int rpc_proc_show(struct seq_file *seq, void *v) { |
| 38 | const struct rpc_stat *statp = seq->private; |
| 39 | const struct rpc_program *prog = statp->program; |
Chuck Lever | ea339d4 | 2007-10-26 13:32:56 -0400 | [diff] [blame] | 40 | unsigned int i, j; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | |
| 42 | seq_printf(seq, |
Max Kellermann | 49e31cb | 2005-09-06 15:18:03 -0700 | [diff] [blame] | 43 | "net %u %u %u %u\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | statp->netcnt, |
| 45 | statp->netudpcnt, |
| 46 | statp->nettcpcnt, |
| 47 | statp->nettcpconn); |
| 48 | seq_printf(seq, |
Max Kellermann | 49e31cb | 2005-09-06 15:18:03 -0700 | [diff] [blame] | 49 | "rpc %u %u %u\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | statp->rpccnt, |
| 51 | statp->rpcretrans, |
| 52 | statp->rpcauthrefresh); |
| 53 | |
| 54 | for (i = 0; i < prog->nrvers; i++) { |
| 55 | const struct rpc_version *vers = prog->version[i]; |
| 56 | if (!vers) |
| 57 | continue; |
Max Kellermann | 49e31cb | 2005-09-06 15:18:03 -0700 | [diff] [blame] | 58 | seq_printf(seq, "proc%u %u", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | vers->number, vers->nrprocs); |
| 60 | for (j = 0; j < vers->nrprocs; j++) |
Christoph Hellwig | 1c5876d | 2017-05-08 23:27:10 +0200 | [diff] [blame] | 61 | seq_printf(seq, " %u", vers->counts[j]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | seq_putc(seq, '\n'); |
| 63 | } |
| 64 | return 0; |
| 65 | } |
| 66 | |
| 67 | static int rpc_proc_open(struct inode *inode, struct file *file) |
| 68 | { |
Muchun Song | 359745d | 2022-01-21 22:14:23 -0800 | [diff] [blame] | 69 | return single_open(file, rpc_proc_show, pde_data(inode)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | } |
| 71 | |
Alexey Dobriyan | 97a3253 | 2020-02-03 17:37:17 -0800 | [diff] [blame] | 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, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | }; |
| 78 | |
| 79 | /* |
| 80 | * Get RPC server stats |
| 81 | */ |
Christoph Hellwig | 7fd38af | 2017-05-08 23:40:27 +0200 | [diff] [blame] | 82 | void svc_seq_show(struct seq_file *seq, const struct svc_stat *statp) |
| 83 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | const struct svc_program *prog = statp->program; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | const struct svc_version *vers; |
Chuck Lever | ea339d4 | 2007-10-26 13:32:56 -0400 | [diff] [blame] | 86 | unsigned int i, j; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | |
| 88 | seq_printf(seq, |
Max Kellermann | 49e31cb | 2005-09-06 15:18:03 -0700 | [diff] [blame] | 89 | "net %u %u %u %u\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | statp->netcnt, |
| 91 | statp->netudpcnt, |
| 92 | statp->nettcpcnt, |
| 93 | statp->nettcpconn); |
| 94 | seq_printf(seq, |
Max Kellermann | 49e31cb | 2005-09-06 15:18:03 -0700 | [diff] [blame] | 95 | "rpc %u %u %u %u %u\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | statp->rpccnt, |
| 97 | statp->rpcbadfmt+statp->rpcbadauth+statp->rpcbadclnt, |
| 98 | statp->rpcbadfmt, |
| 99 | statp->rpcbadauth, |
| 100 | statp->rpcbadclnt); |
| 101 | |
| 102 | for (i = 0; i < prog->pg_nvers; i++) { |
Christoph Hellwig | 7fd38af | 2017-05-08 23:40:27 +0200 | [diff] [blame] | 103 | vers = prog->pg_vers[i]; |
| 104 | if (!vers) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | continue; |
Max Kellermann | 49e31cb | 2005-09-06 15:18:03 -0700 | [diff] [blame] | 106 | seq_printf(seq, "proc%d %u", i, vers->vs_nproc); |
Christoph Hellwig | 7fd38af | 2017-05-08 23:40:27 +0200 | [diff] [blame] | 107 | for (j = 0; j < vers->vs_nproc; j++) |
| 108 | seq_printf(seq, " %u", vers->vs_count[j]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | seq_putc(seq, '\n'); |
| 110 | } |
| 111 | } |
Trond Myklebust | 24c3767 | 2008-12-23 16:30:12 -0500 | [diff] [blame] | 112 | EXPORT_SYMBOL_GPL(svc_seq_show); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | |
Chuck Lever | 11c556b | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 114 | /** |
| 115 | * rpc_alloc_iostats - allocate an rpc_iostats structure |
| 116 | * @clnt: RPC program, version, and xprt |
| 117 | * |
| 118 | */ |
| 119 | struct rpc_iostats *rpc_alloc_iostats(struct rpc_clnt *clnt) |
| 120 | { |
Chuck Lever | edef129 | 2014-11-08 20:15:09 -0500 | [diff] [blame] | 121 | struct rpc_iostats *stats; |
| 122 | int i; |
| 123 | |
| 124 | stats = kcalloc(clnt->cl_maxproc, sizeof(*stats), GFP_KERNEL); |
| 125 | if (stats) { |
| 126 | for (i = 0; i < clnt->cl_maxproc; i++) |
| 127 | spin_lock_init(&stats[i].om_lock); |
| 128 | } |
| 129 | return stats; |
Chuck Lever | 11c556b | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 130 | } |
Trond Myklebust | e8914c6 | 2007-07-14 15:39:59 -0400 | [diff] [blame] | 131 | EXPORT_SYMBOL_GPL(rpc_alloc_iostats); |
Chuck Lever | 11c556b | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 132 | |
| 133 | /** |
| 134 | * rpc_free_iostats - release an rpc_iostats structure |
| 135 | * @stats: doomed rpc_iostats structure |
| 136 | * |
| 137 | */ |
| 138 | void rpc_free_iostats(struct rpc_iostats *stats) |
| 139 | { |
| 140 | kfree(stats); |
| 141 | } |
Trond Myklebust | e8914c6 | 2007-07-14 15:39:59 -0400 | [diff] [blame] | 142 | EXPORT_SYMBOL_GPL(rpc_free_iostats); |
Chuck Lever | 11c556b | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 143 | |
| 144 | /** |
Weston Andros Adamson | 840210f | 2014-06-24 10:59:52 -0400 | [diff] [blame] | 145 | * rpc_count_iostats_metrics - tally up per-task stats |
Chuck Lever | 11c556b | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 146 | * @task: completed rpc_task |
Weston Andros Adamson | 840210f | 2014-06-24 10:59:52 -0400 | [diff] [blame] | 147 | * @op_metrics: stat structure for OP that will accumulate stats from @task |
Chuck Lever | 11c556b | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 148 | */ |
Weston Andros Adamson | 840210f | 2014-06-24 10:59:52 -0400 | [diff] [blame] | 149 | void rpc_count_iostats_metrics(const struct rpc_task *task, |
| 150 | struct rpc_iostats *op_metrics) |
Chuck Lever | 11c556b | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 151 | { |
| 152 | struct rpc_rqst *req = task->tk_rqstp; |
Chuck Lever | 40bf7eb | 2018-03-16 10:33:49 -0400 | [diff] [blame] | 153 | ktime_t backlog, execute, now; |
Chuck Lever | 11c556b | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 154 | |
Weston Andros Adamson | 840210f | 2014-06-24 10:59:52 -0400 | [diff] [blame] | 155 | if (!op_metrics || !req) |
Chuck Lever | 11c556b | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 156 | return; |
Ricardo Labiaga | 55ae1aa | 2009-04-01 09:23:03 -0400 | [diff] [blame] | 157 | |
Chuck Lever | edef129 | 2014-11-08 20:15:09 -0500 | [diff] [blame] | 158 | now = ktime_get(); |
Chuck Lever | edef129 | 2014-11-08 20:15:09 -0500 | [diff] [blame] | 159 | spin_lock(&op_metrics->om_lock); |
| 160 | |
Chuck Lever | 11c556b | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 161 | op_metrics->om_ops++; |
Chuck Lever | ae09531 | 2016-11-29 10:52:32 -0500 | [diff] [blame] | 162 | /* kernel API: om_ops must never become larger than om_ntrans */ |
| 163 | op_metrics->om_ntrans += max(req->rq_ntrans, 1); |
Chuck Lever | 11c556b | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 164 | op_metrics->om_timeouts += task->tk_timeouts; |
| 165 | |
Trond Myklebust | d60dbb2 | 2010-05-13 12:51:49 -0400 | [diff] [blame] | 166 | op_metrics->om_bytes_sent += req->rq_xmit_bytes_sent; |
Ricardo Labiaga | dd2b63d | 2009-04-01 09:23:28 -0400 | [diff] [blame] | 167 | op_metrics->om_bytes_recv += req->rq_reply_bytes_recvd; |
Chuck Lever | 11c556b | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 168 | |
Chuck Lever | 40bf7eb | 2018-03-16 10:33:49 -0400 | [diff] [blame] | 169 | backlog = 0; |
Chuck Lever | ae09531 | 2016-11-29 10:52:32 -0500 | [diff] [blame] | 170 | if (ktime_to_ns(req->rq_xtime)) { |
Chuck Lever | 40bf7eb | 2018-03-16 10:33:49 -0400 | [diff] [blame] | 171 | backlog = ktime_sub(req->rq_xtime, task->tk_start); |
| 172 | op_metrics->om_queue = ktime_add(op_metrics->om_queue, backlog); |
Chuck Lever | ae09531 | 2016-11-29 10:52:32 -0500 | [diff] [blame] | 173 | } |
Chuck Lever | 40bf7eb | 2018-03-16 10:33:49 -0400 | [diff] [blame] | 174 | |
Trond Myklebust | d60dbb2 | 2010-05-13 12:51:49 -0400 | [diff] [blame] | 175 | op_metrics->om_rtt = ktime_add(op_metrics->om_rtt, req->rq_rtt); |
Chuck Lever | 11c556b | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 176 | |
Chuck Lever | 40bf7eb | 2018-03-16 10:33:49 -0400 | [diff] [blame] | 177 | execute = ktime_sub(now, task->tk_start); |
| 178 | op_metrics->om_execute = ktime_add(op_metrics->om_execute, execute); |
Dave Wysochanski | a332518 | 2019-05-23 16:13:50 -0400 | [diff] [blame] | 179 | if (task->tk_status < 0) |
| 180 | op_metrics->om_error_status++; |
Chuck Lever | edef129 | 2014-11-08 20:15:09 -0500 | [diff] [blame] | 181 | |
| 182 | spin_unlock(&op_metrics->om_lock); |
Chuck Lever | 40bf7eb | 2018-03-16 10:33:49 -0400 | [diff] [blame] | 183 | |
| 184 | trace_rpc_stats_latency(req->rq_task, backlog, req->rq_rtt, execute); |
Chuck Lever | 11c556b | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 185 | } |
Weston Andros Adamson | 840210f | 2014-06-24 10:59:52 -0400 | [diff] [blame] | 186 | EXPORT_SYMBOL_GPL(rpc_count_iostats_metrics); |
| 187 | |
| 188 | /** |
| 189 | * rpc_count_iostats - tally up per-task stats |
| 190 | * @task: completed rpc_task |
| 191 | * @stats: array of stat structures |
| 192 | * |
| 193 | * Uses the statidx from @task |
| 194 | */ |
| 195 | void rpc_count_iostats(const struct rpc_task *task, struct rpc_iostats *stats) |
| 196 | { |
| 197 | rpc_count_iostats_metrics(task, |
| 198 | &stats[task->tk_msg.rpc_proc->p_statidx]); |
| 199 | } |
Weston Andros Adamson | 0a70219 | 2012-02-17 13:15:24 -0500 | [diff] [blame] | 200 | EXPORT_SYMBOL_GPL(rpc_count_iostats); |
Chuck Lever | 11c556b | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 201 | |
Adrian Bunk | ec535ce | 2006-04-18 13:21:50 -0400 | [diff] [blame] | 202 | static void _print_name(struct seq_file *seq, unsigned int op, |
Christoph Hellwig | 499b498 | 2017-05-12 15:36:49 +0200 | [diff] [blame] | 203 | const struct rpc_procinfo *procs) |
Chuck Lever | cc0175c | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 204 | { |
| 205 | if (procs[op].p_name) |
| 206 | seq_printf(seq, "\t%12s: ", procs[op].p_name); |
| 207 | else if (op == 0) |
| 208 | seq_printf(seq, "\t NULL: "); |
| 209 | else |
| 210 | seq_printf(seq, "\t%12u: ", op); |
| 211 | } |
| 212 | |
Dave Wysochanski | 189e195 | 2018-07-10 14:59:24 -0400 | [diff] [blame] | 213 | static void _add_rpc_iostats(struct rpc_iostats *a, struct rpc_iostats *b) |
| 214 | { |
| 215 | a->om_ops += b->om_ops; |
| 216 | a->om_ntrans += b->om_ntrans; |
| 217 | a->om_timeouts += b->om_timeouts; |
| 218 | a->om_bytes_sent += b->om_bytes_sent; |
| 219 | a->om_bytes_recv += b->om_bytes_recv; |
| 220 | a->om_queue = ktime_add(a->om_queue, b->om_queue); |
| 221 | a->om_rtt = ktime_add(a->om_rtt, b->om_rtt); |
| 222 | a->om_execute = ktime_add(a->om_execute, b->om_execute); |
Dave Wysochanski | a332518 | 2019-05-23 16:13:50 -0400 | [diff] [blame] | 223 | a->om_error_status += b->om_error_status; |
Dave Wysochanski | 189e195 | 2018-07-10 14:59:24 -0400 | [diff] [blame] | 224 | } |
| 225 | |
Dave Wysochanski | acdce5f | 2018-07-10 14:59:23 -0400 | [diff] [blame] | 226 | static void _print_rpc_iostats(struct seq_file *seq, struct rpc_iostats *stats, |
| 227 | int op, const struct rpc_procinfo *procs) |
| 228 | { |
| 229 | _print_name(seq, op, procs); |
Dave Wysochanski | a332518 | 2019-05-23 16:13:50 -0400 | [diff] [blame] | 230 | seq_printf(seq, "%lu %lu %lu %llu %llu %llu %llu %llu %lu\n", |
Dave Wysochanski | acdce5f | 2018-07-10 14:59:23 -0400 | [diff] [blame] | 231 | stats->om_ops, |
| 232 | stats->om_ntrans, |
| 233 | stats->om_timeouts, |
| 234 | stats->om_bytes_sent, |
| 235 | stats->om_bytes_recv, |
| 236 | ktime_to_ms(stats->om_queue), |
| 237 | ktime_to_ms(stats->om_rtt), |
Dave Wysochanski | a332518 | 2019-05-23 16:13:50 -0400 | [diff] [blame] | 238 | ktime_to_ms(stats->om_execute), |
| 239 | stats->om_error_status); |
Dave Wysochanski | acdce5f | 2018-07-10 14:59:23 -0400 | [diff] [blame] | 240 | } |
| 241 | |
NeilBrown | 10db569 | 2019-05-30 10:41:28 +1000 | [diff] [blame] | 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; |
| 248 | } |
| 249 | |
Dave Wysochanski | 016583d | 2018-07-31 10:10:51 -0400 | [diff] [blame] | 250 | void rpc_clnt_show_stats(struct seq_file *seq, struct rpc_clnt *clnt) |
Chuck Lever | 11c556b | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 251 | { |
Chuck Lever | 11c556b | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 252 | unsigned int op, maxproc = clnt->cl_maxproc; |
| 253 | |
Dave Wysochanski | 016583d | 2018-07-31 10:10:51 -0400 | [diff] [blame] | 254 | if (!clnt->cl_metrics) |
Chuck Lever | 11c556b | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 255 | return; |
| 256 | |
| 257 | seq_printf(seq, "\tRPC iostats version: %s ", RPC_IOSTATS_VERS); |
| 258 | seq_printf(seq, "p/v: %u/%u (%s)\n", |
Trond Myklebust | 55909f2 | 2013-08-23 11:48:15 -0400 | [diff] [blame] | 259 | clnt->cl_prog, clnt->cl_vers, clnt->cl_program->name); |
Chuck Lever | 11c556b | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 260 | |
NeilBrown | 10db569 | 2019-05-30 10:41:28 +1000 | [diff] [blame] | 261 | rpc_clnt_iterate_for_each_xprt(clnt, do_print_stats, seq); |
Chuck Lever | 11c556b | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 262 | |
| 263 | seq_printf(seq, "\tper-op statistics\n"); |
| 264 | for (op = 0; op < maxproc; op++) { |
Dave Wysochanski | 016583d | 2018-07-31 10:10:51 -0400 | [diff] [blame] | 265 | struct rpc_iostats stats = {}; |
| 266 | struct rpc_clnt *next = clnt; |
| 267 | do { |
| 268 | _add_rpc_iostats(&stats, &next->cl_metrics[op]); |
| 269 | if (next == next->cl_parent) |
| 270 | break; |
| 271 | next = next->cl_parent; |
| 272 | } while (next); |
| 273 | _print_rpc_iostats(seq, &stats, op, clnt->cl_procinfo); |
Chuck Lever | 11c556b | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 274 | } |
| 275 | } |
Dave Wysochanski | 016583d | 2018-07-31 10:10:51 -0400 | [diff] [blame] | 276 | EXPORT_SYMBOL_GPL(rpc_clnt_show_stats); |
Chuck Lever | 11c556b | 2006-03-20 13:44:22 -0500 | [diff] [blame] | 277 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | /* |
| 279 | * Register/unregister RPC proc files |
| 280 | */ |
| 281 | static inline struct proc_dir_entry * |
Stanislav Kinsbursky | ec7652a | 2011-12-06 16:42:40 +0300 | [diff] [blame] | 282 | do_register(struct net *net, const char *name, void *data, |
Alexey Dobriyan | 97a3253 | 2020-02-03 17:37:17 -0800 | [diff] [blame] | 283 | const struct proc_ops *proc_ops) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | { |
Pavel Emelyanov | 4f42d0d | 2010-09-27 14:01:58 +0400 | [diff] [blame] | 285 | struct sunrpc_net *sn; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | |
Pavel Emelyanov | 4f42d0d | 2010-09-27 14:01:58 +0400 | [diff] [blame] | 287 | dprintk("RPC: registering /proc/net/rpc/%s\n", name); |
Stanislav Kinsbursky | ec7652a | 2011-12-06 16:42:40 +0300 | [diff] [blame] | 288 | sn = net_generic(net, sunrpc_net_id); |
Alexey Dobriyan | 97a3253 | 2020-02-03 17:37:17 -0800 | [diff] [blame] | 289 | return proc_create_data(name, 0, sn->proc_net_rpc, proc_ops, data); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | } |
| 291 | |
| 292 | struct proc_dir_entry * |
Stanislav Kinsbursky | ec7652a | 2011-12-06 16:42:40 +0300 | [diff] [blame] | 293 | rpc_proc_register(struct net *net, struct rpc_stat *statp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | { |
Alexey Dobriyan | 97a3253 | 2020-02-03 17:37:17 -0800 | [diff] [blame] | 295 | return do_register(net, statp->program->name, statp, &rpc_proc_ops); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 296 | } |
Trond Myklebust | e8914c6 | 2007-07-14 15:39:59 -0400 | [diff] [blame] | 297 | EXPORT_SYMBOL_GPL(rpc_proc_register); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | |
| 299 | void |
Stanislav Kinsbursky | ec7652a | 2011-12-06 16:42:40 +0300 | [diff] [blame] | 300 | rpc_proc_unregister(struct net *net, const char *name) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | { |
Pavel Emelyanov | 4f42d0d | 2010-09-27 14:01:58 +0400 | [diff] [blame] | 302 | struct sunrpc_net *sn; |
| 303 | |
Stanislav Kinsbursky | ec7652a | 2011-12-06 16:42:40 +0300 | [diff] [blame] | 304 | sn = net_generic(net, sunrpc_net_id); |
Pavel Emelyanov | 4f42d0d | 2010-09-27 14:01:58 +0400 | [diff] [blame] | 305 | remove_proc_entry(name, sn->proc_net_rpc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | } |
Trond Myklebust | e8914c6 | 2007-07-14 15:39:59 -0400 | [diff] [blame] | 307 | EXPORT_SYMBOL_GPL(rpc_proc_unregister); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | |
| 309 | struct proc_dir_entry * |
Alexey Dobriyan | 97a3253 | 2020-02-03 17:37:17 -0800 | [diff] [blame] | 310 | svc_proc_register(struct net *net, struct svc_stat *statp, const struct proc_ops *proc_ops) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 311 | { |
Alexey Dobriyan | 97a3253 | 2020-02-03 17:37:17 -0800 | [diff] [blame] | 312 | return do_register(net, statp->program->pg_name, statp, proc_ops); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | } |
Trond Myklebust | 24c3767 | 2008-12-23 16:30:12 -0500 | [diff] [blame] | 314 | EXPORT_SYMBOL_GPL(svc_proc_register); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | |
| 316 | void |
Stanislav Kinsbursky | 246590f | 2011-12-06 16:42:49 +0300 | [diff] [blame] | 317 | svc_proc_unregister(struct net *net, const char *name) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | { |
Pavel Emelyanov | 4f42d0d | 2010-09-27 14:01:58 +0400 | [diff] [blame] | 319 | struct sunrpc_net *sn; |
| 320 | |
Stanislav Kinsbursky | 246590f | 2011-12-06 16:42:49 +0300 | [diff] [blame] | 321 | sn = net_generic(net, sunrpc_net_id); |
Pavel Emelyanov | 4f42d0d | 2010-09-27 14:01:58 +0400 | [diff] [blame] | 322 | remove_proc_entry(name, sn->proc_net_rpc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | } |
Trond Myklebust | 24c3767 | 2008-12-23 16:30:12 -0500 | [diff] [blame] | 324 | EXPORT_SYMBOL_GPL(svc_proc_unregister); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 325 | |
Pavel Emelyanov | 4f42d0d | 2010-09-27 14:01:58 +0400 | [diff] [blame] | 326 | int rpc_proc_init(struct net *net) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 327 | { |
Pavel Emelyanov | 4f42d0d | 2010-09-27 14:01:58 +0400 | [diff] [blame] | 328 | struct sunrpc_net *sn; |
| 329 | |
Chuck Lever | 46121cf | 2007-01-31 12:14:08 -0500 | [diff] [blame] | 330 | dprintk("RPC: registering /proc/net/rpc\n"); |
Pavel Emelyanov | 4f42d0d | 2010-09-27 14:01:58 +0400 | [diff] [blame] | 331 | sn = net_generic(net, sunrpc_net_id); |
| 332 | sn->proc_net_rpc = proc_mkdir("rpc", net->proc_net); |
| 333 | if (sn->proc_net_rpc == NULL) |
| 334 | return -ENOMEM; |
| 335 | |
| 336 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 337 | } |
| 338 | |
Pavel Emelyanov | 4f42d0d | 2010-09-27 14:01:58 +0400 | [diff] [blame] | 339 | void rpc_proc_exit(struct net *net) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | { |
Chuck Lever | 46121cf | 2007-01-31 12:14:08 -0500 | [diff] [blame] | 341 | dprintk("RPC: unregistering /proc/net/rpc\n"); |
Pavel Emelyanov | 4f42d0d | 2010-09-27 14:01:58 +0400 | [diff] [blame] | 342 | remove_proc_entry("rpc", net->proc_net); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 343 | } |