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