diff options
author | Pavel Emelyanov <xemul@parallels.com> | 2010-09-27 06:01:58 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2010-09-27 10:16:12 -0400 |
commit | 4f42d0d53ca4737f82937edb0efc83564c124853 (patch) | |
tree | 487cbc8e7bc9ed643fbbfb2216230c15ed3b1552 | |
parent | 2f72c9b73730c335381b13e2bd221abe1acea394 (diff) |
sunrpc: Make the /proc/net/rpc appear in net namespaces
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
-rw-r--r-- | include/linux/sunrpc/stats.h | 23 | ||||
-rw-r--r-- | net/sunrpc/cache.c | 11 | ||||
-rw-r--r-- | net/sunrpc/netns.h | 1 | ||||
-rw-r--r-- | net/sunrpc/stats.c | 43 | ||||
-rw-r--r-- | net/sunrpc/sunrpc_syms.c | 16 |
5 files changed, 59 insertions, 35 deletions
diff --git a/include/linux/sunrpc/stats.h b/include/linux/sunrpc/stats.h index 5fa0f2084307..680471d1f28a 100644 --- a/include/linux/sunrpc/stats.h +++ b/include/linux/sunrpc/stats.h | |||
@@ -38,8 +38,21 @@ struct svc_stat { | |||
38 | rpcbadclnt; | 38 | rpcbadclnt; |
39 | }; | 39 | }; |
40 | 40 | ||
41 | void rpc_proc_init(void); | 41 | struct net; |
42 | void rpc_proc_exit(void); | 42 | #ifdef CONFIG_PROC_FS |
43 | int rpc_proc_init(struct net *); | ||
44 | void rpc_proc_exit(struct net *); | ||
45 | #else | ||
46 | static inline int rpc_proc_init(struct net *net) | ||
47 | { | ||
48 | return 0; | ||
49 | } | ||
50 | |||
51 | static inline void rpc_proc_exit(struct net *net) | ||
52 | { | ||
53 | } | ||
54 | #endif | ||
55 | |||
43 | #ifdef MODULE | 56 | #ifdef MODULE |
44 | void rpc_modcount(struct inode *, int); | 57 | void rpc_modcount(struct inode *, int); |
45 | #endif | 58 | #endif |
@@ -54,9 +67,6 @@ void svc_proc_unregister(const char *); | |||
54 | 67 | ||
55 | void svc_seq_show(struct seq_file *, | 68 | void svc_seq_show(struct seq_file *, |
56 | const struct svc_stat *); | 69 | const struct svc_stat *); |
57 | |||
58 | extern struct proc_dir_entry *proc_net_rpc; | ||
59 | |||
60 | #else | 70 | #else |
61 | 71 | ||
62 | static inline struct proc_dir_entry *rpc_proc_register(struct rpc_stat *s) { return NULL; } | 72 | static inline struct proc_dir_entry *rpc_proc_register(struct rpc_stat *s) { return NULL; } |
@@ -69,9 +79,6 @@ static inline void svc_proc_unregister(const char *p) {} | |||
69 | 79 | ||
70 | static inline void svc_seq_show(struct seq_file *seq, | 80 | static inline void svc_seq_show(struct seq_file *seq, |
71 | const struct svc_stat *st) {} | 81 | const struct svc_stat *st) {} |
72 | |||
73 | #define proc_net_rpc NULL | ||
74 | |||
75 | #endif | 82 | #endif |
76 | 83 | ||
77 | #endif /* _LINUX_SUNRPC_STATS_H */ | 84 | #endif /* _LINUX_SUNRPC_STATS_H */ |
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c index e84e7ddeecd4..e20968aac68a 100644 --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c | |||
@@ -34,7 +34,7 @@ | |||
34 | #include <linux/sunrpc/cache.h> | 34 | #include <linux/sunrpc/cache.h> |
35 | #include <linux/sunrpc/stats.h> | 35 | #include <linux/sunrpc/stats.h> |
36 | #include <linux/sunrpc/rpc_pipe_fs.h> | 36 | #include <linux/sunrpc/rpc_pipe_fs.h> |
37 | #include <net/net_namespace.h> | 37 | #include "netns.h" |
38 | 38 | ||
39 | #define RPCDBG_FACILITY RPCDBG_CACHE | 39 | #define RPCDBG_FACILITY RPCDBG_CACHE |
40 | 40 | ||
@@ -1540,6 +1540,8 @@ static const struct file_operations cache_flush_operations_procfs = { | |||
1540 | 1540 | ||
1541 | static void remove_cache_proc_entries(struct cache_detail *cd, struct net *net) | 1541 | static void remove_cache_proc_entries(struct cache_detail *cd, struct net *net) |
1542 | { | 1542 | { |
1543 | struct sunrpc_net *sn; | ||
1544 | |||
1543 | if (cd->u.procfs.proc_ent == NULL) | 1545 | if (cd->u.procfs.proc_ent == NULL) |
1544 | return; | 1546 | return; |
1545 | if (cd->u.procfs.flush_ent) | 1547 | if (cd->u.procfs.flush_ent) |
@@ -1549,15 +1551,18 @@ static void remove_cache_proc_entries(struct cache_detail *cd, struct net *net) | |||
1549 | if (cd->u.procfs.content_ent) | 1551 | if (cd->u.procfs.content_ent) |
1550 | remove_proc_entry("content", cd->u.procfs.proc_ent); | 1552 | remove_proc_entry("content", cd->u.procfs.proc_ent); |
1551 | cd->u.procfs.proc_ent = NULL; | 1553 | cd->u.procfs.proc_ent = NULL; |
1552 | remove_proc_entry(cd->name, proc_net_rpc); | 1554 | sn = net_generic(net, sunrpc_net_id); |
1555 | remove_proc_entry(cd->name, sn->proc_net_rpc); | ||
1553 | } | 1556 | } |
1554 | 1557 | ||
1555 | #ifdef CONFIG_PROC_FS | 1558 | #ifdef CONFIG_PROC_FS |
1556 | static int create_cache_proc_entries(struct cache_detail *cd, struct net *net) | 1559 | static int create_cache_proc_entries(struct cache_detail *cd, struct net *net) |
1557 | { | 1560 | { |
1558 | struct proc_dir_entry *p; | 1561 | struct proc_dir_entry *p; |
1562 | struct sunrpc_net *sn; | ||
1559 | 1563 | ||
1560 | cd->u.procfs.proc_ent = proc_mkdir(cd->name, proc_net_rpc); | 1564 | sn = net_generic(net, sunrpc_net_id); |
1565 | cd->u.procfs.proc_ent = proc_mkdir(cd->name, sn->proc_net_rpc); | ||
1561 | if (cd->u.procfs.proc_ent == NULL) | 1566 | if (cd->u.procfs.proc_ent == NULL) |
1562 | goto out_nomem; | 1567 | goto out_nomem; |
1563 | cd->u.procfs.channel_ent = NULL; | 1568 | cd->u.procfs.channel_ent = NULL; |
diff --git a/net/sunrpc/netns.h b/net/sunrpc/netns.h index b2d18af2815e..e52ce897dde5 100644 --- a/net/sunrpc/netns.h +++ b/net/sunrpc/netns.h | |||
@@ -5,6 +5,7 @@ | |||
5 | #include <net/netns/generic.h> | 5 | #include <net/netns/generic.h> |
6 | 6 | ||
7 | struct sunrpc_net { | 7 | struct sunrpc_net { |
8 | struct proc_dir_entry *proc_net_rpc; | ||
8 | }; | 9 | }; |
9 | 10 | ||
10 | extern int sunrpc_net_id; | 11 | extern int sunrpc_net_id; |
diff --git a/net/sunrpc/stats.c b/net/sunrpc/stats.c index ea1046f3f9a3..f71a73107ae9 100644 --- a/net/sunrpc/stats.c +++ b/net/sunrpc/stats.c | |||
@@ -22,11 +22,10 @@ | |||
22 | #include <linux/sunrpc/clnt.h> | 22 | #include <linux/sunrpc/clnt.h> |
23 | #include <linux/sunrpc/svcsock.h> | 23 | #include <linux/sunrpc/svcsock.h> |
24 | #include <linux/sunrpc/metrics.h> | 24 | #include <linux/sunrpc/metrics.h> |
25 | #include <net/net_namespace.h> | ||
26 | 25 | ||
27 | #define RPCDBG_FACILITY RPCDBG_MISC | 26 | #include "netns.h" |
28 | 27 | ||
29 | struct proc_dir_entry *proc_net_rpc = NULL; | 28 | #define RPCDBG_FACILITY RPCDBG_MISC |
30 | 29 | ||
31 | /* | 30 | /* |
32 | * Get RPC client stats | 31 | * Get RPC client stats |
@@ -218,10 +217,11 @@ EXPORT_SYMBOL_GPL(rpc_print_iostats); | |||
218 | static inline struct proc_dir_entry * | 217 | static inline struct proc_dir_entry * |
219 | do_register(const char *name, void *data, const struct file_operations *fops) | 218 | do_register(const char *name, void *data, const struct file_operations *fops) |
220 | { | 219 | { |
221 | rpc_proc_init(); | 220 | struct sunrpc_net *sn; |
222 | dprintk("RPC: registering /proc/net/rpc/%s\n", name); | ||
223 | 221 | ||
224 | return proc_create_data(name, 0, proc_net_rpc, fops, data); | 222 | dprintk("RPC: registering /proc/net/rpc/%s\n", name); |
223 | sn = net_generic(&init_net, sunrpc_net_id); | ||
224 | return proc_create_data(name, 0, sn->proc_net_rpc, fops, data); | ||
225 | } | 225 | } |
226 | 226 | ||
227 | struct proc_dir_entry * | 227 | struct proc_dir_entry * |
@@ -234,7 +234,10 @@ EXPORT_SYMBOL_GPL(rpc_proc_register); | |||
234 | void | 234 | void |
235 | rpc_proc_unregister(const char *name) | 235 | rpc_proc_unregister(const char *name) |
236 | { | 236 | { |
237 | remove_proc_entry(name, proc_net_rpc); | 237 | struct sunrpc_net *sn; |
238 | |||
239 | sn = net_generic(&init_net, sunrpc_net_id); | ||
240 | remove_proc_entry(name, sn->proc_net_rpc); | ||
238 | } | 241 | } |
239 | EXPORT_SYMBOL_GPL(rpc_proc_unregister); | 242 | EXPORT_SYMBOL_GPL(rpc_proc_unregister); |
240 | 243 | ||
@@ -248,25 +251,29 @@ EXPORT_SYMBOL_GPL(svc_proc_register); | |||
248 | void | 251 | void |
249 | svc_proc_unregister(const char *name) | 252 | svc_proc_unregister(const char *name) |
250 | { | 253 | { |
251 | remove_proc_entry(name, proc_net_rpc); | 254 | struct sunrpc_net *sn; |
255 | |||
256 | sn = net_generic(&init_net, sunrpc_net_id); | ||
257 | remove_proc_entry(name, sn->proc_net_rpc); | ||
252 | } | 258 | } |
253 | EXPORT_SYMBOL_GPL(svc_proc_unregister); | 259 | EXPORT_SYMBOL_GPL(svc_proc_unregister); |
254 | 260 | ||
255 | void | 261 | int rpc_proc_init(struct net *net) |
256 | rpc_proc_init(void) | ||
257 | { | 262 | { |
263 | struct sunrpc_net *sn; | ||
264 | |||
258 | dprintk("RPC: registering /proc/net/rpc\n"); | 265 | dprintk("RPC: registering /proc/net/rpc\n"); |
259 | if (!proc_net_rpc) | 266 | sn = net_generic(net, sunrpc_net_id); |
260 | proc_net_rpc = proc_mkdir("rpc", init_net.proc_net); | 267 | sn->proc_net_rpc = proc_mkdir("rpc", net->proc_net); |
268 | if (sn->proc_net_rpc == NULL) | ||
269 | return -ENOMEM; | ||
270 | |||
271 | return 0; | ||
261 | } | 272 | } |
262 | 273 | ||
263 | void | 274 | void rpc_proc_exit(struct net *net) |
264 | rpc_proc_exit(void) | ||
265 | { | 275 | { |
266 | dprintk("RPC: unregistering /proc/net/rpc\n"); | 276 | dprintk("RPC: unregistering /proc/net/rpc\n"); |
267 | if (proc_net_rpc) { | 277 | remove_proc_entry("rpc", net->proc_net); |
268 | proc_net_rpc = NULL; | ||
269 | remove_proc_entry("rpc", init_net.proc_net); | ||
270 | } | ||
271 | } | 278 | } |
272 | 279 | ||
diff --git a/net/sunrpc/sunrpc_syms.c b/net/sunrpc/sunrpc_syms.c index faa23229bd25..c076af8535db 100644 --- a/net/sunrpc/sunrpc_syms.c +++ b/net/sunrpc/sunrpc_syms.c | |||
@@ -28,11 +28,21 @@ int sunrpc_net_id; | |||
28 | 28 | ||
29 | static __net_init int sunrpc_init_net(struct net *net) | 29 | static __net_init int sunrpc_init_net(struct net *net) |
30 | { | 30 | { |
31 | int err; | ||
32 | |||
33 | err = rpc_proc_init(net); | ||
34 | if (err) | ||
35 | goto err_proc; | ||
36 | |||
31 | return 0; | 37 | return 0; |
38 | |||
39 | err_proc: | ||
40 | return err; | ||
32 | } | 41 | } |
33 | 42 | ||
34 | static __net_exit void sunrpc_exit_net(struct net *net) | 43 | static __net_exit void sunrpc_exit_net(struct net *net) |
35 | { | 44 | { |
45 | rpc_proc_exit(net); | ||
36 | } | 46 | } |
37 | 47 | ||
38 | static struct pernet_operations sunrpc_net_ops = { | 48 | static struct pernet_operations sunrpc_net_ops = { |
@@ -67,9 +77,6 @@ init_sunrpc(void) | |||
67 | #ifdef RPC_DEBUG | 77 | #ifdef RPC_DEBUG |
68 | rpc_register_sysctl(); | 78 | rpc_register_sysctl(); |
69 | #endif | 79 | #endif |
70 | #ifdef CONFIG_PROC_FS | ||
71 | rpc_proc_init(); | ||
72 | #endif | ||
73 | cache_register(&ip_map_cache); | 80 | cache_register(&ip_map_cache); |
74 | cache_register(&unix_gid_cache); | 81 | cache_register(&unix_gid_cache); |
75 | svc_init_xprt_sock(); /* svc sock transport */ | 82 | svc_init_xprt_sock(); /* svc sock transport */ |
@@ -101,9 +108,6 @@ cleanup_sunrpc(void) | |||
101 | #ifdef RPC_DEBUG | 108 | #ifdef RPC_DEBUG |
102 | rpc_unregister_sysctl(); | 109 | rpc_unregister_sysctl(); |
103 | #endif | 110 | #endif |
104 | #ifdef CONFIG_PROC_FS | ||
105 | rpc_proc_exit(); | ||
106 | #endif | ||
107 | rcu_barrier(); /* Wait for completion of call_rcu()'s */ | 111 | rcu_barrier(); /* Wait for completion of call_rcu()'s */ |
108 | } | 112 | } |
109 | MODULE_LICENSE("GPL"); | 113 | MODULE_LICENSE("GPL"); |