aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorStanislav Kinsbursky <skinsbursky@parallels.com>2012-01-12 13:07:51 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-01-31 18:20:25 -0500
commit70abc49b4f4a4ef04a6bd9852edbd047b480bed7 (patch)
tree7c9a266ff8838d7945106920a5f0251861a850a5 /net
parentccdc28f81c91f7ef2dc6c28d27f50264b19e4dd5 (diff)
SUNRPC: make SUNPRC clients list per network namespace context
This patch moves static SUNRPC clients list and it's lock to sunrpc_net structure. Currently this list is used only for debug purposes. But later it will be used also for selecting clients by networks namespace on PipeFS mount/umount events. Per-network namespace lists will make this faster and simplier. Note: client list is taken from "init_net" network namespace context in rpc_show_tasks(). This will be changed some day later with making SUNRPC sysctl's per network namespace context. Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net')
-rw-r--r--net/sunrpc/clnt.c26
-rw-r--r--net/sunrpc/netns.h3
-rw-r--r--net/sunrpc/sunrpc_syms.c3
-rw-r--r--net/sunrpc/sysctl.c4
4 files changed, 24 insertions, 12 deletions
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 5ef192c1a57c..90e82c5daeb6 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -38,6 +38,7 @@
38#include <linux/sunrpc/bc_xprt.h> 38#include <linux/sunrpc/bc_xprt.h>
39 39
40#include "sunrpc.h" 40#include "sunrpc.h"
41#include "netns.h"
41 42
42#ifdef RPC_DEBUG 43#ifdef RPC_DEBUG
43# define RPCDBG_FACILITY RPCDBG_CALL 44# define RPCDBG_FACILITY RPCDBG_CALL
@@ -50,8 +51,6 @@
50/* 51/*
51 * All RPC clients are linked into this list 52 * All RPC clients are linked into this list
52 */ 53 */
53static LIST_HEAD(all_clients);
54static DEFINE_SPINLOCK(rpc_client_lock);
55 54
56static DECLARE_WAIT_QUEUE_HEAD(destroy_wait); 55static DECLARE_WAIT_QUEUE_HEAD(destroy_wait);
57 56
@@ -81,16 +80,20 @@ static int rpc_ping(struct rpc_clnt *clnt);
81 80
82static void rpc_register_client(struct rpc_clnt *clnt) 81static void rpc_register_client(struct rpc_clnt *clnt)
83{ 82{
84 spin_lock(&rpc_client_lock); 83 struct sunrpc_net *sn = net_generic(clnt->cl_xprt->xprt_net, sunrpc_net_id);
85 list_add(&clnt->cl_clients, &all_clients); 84
86 spin_unlock(&rpc_client_lock); 85 spin_lock(&sn->rpc_client_lock);
86 list_add(&clnt->cl_clients, &sn->all_clients);
87 spin_unlock(&sn->rpc_client_lock);
87} 88}
88 89
89static void rpc_unregister_client(struct rpc_clnt *clnt) 90static void rpc_unregister_client(struct rpc_clnt *clnt)
90{ 91{
91 spin_lock(&rpc_client_lock); 92 struct sunrpc_net *sn = net_generic(clnt->cl_xprt->xprt_net, sunrpc_net_id);
93
94 spin_lock(&sn->rpc_client_lock);
92 list_del(&clnt->cl_clients); 95 list_del(&clnt->cl_clients);
93 spin_unlock(&rpc_client_lock); 96 spin_unlock(&sn->rpc_client_lock);
94} 97}
95 98
96static void __rpc_clnt_remove_pipedir(struct rpc_clnt *clnt) 99static void __rpc_clnt_remove_pipedir(struct rpc_clnt *clnt)
@@ -1883,14 +1886,15 @@ static void rpc_show_task(const struct rpc_clnt *clnt,
1883 task->tk_action, rpc_waitq); 1886 task->tk_action, rpc_waitq);
1884} 1887}
1885 1888
1886void rpc_show_tasks(void) 1889void rpc_show_tasks(struct net *net)
1887{ 1890{
1888 struct rpc_clnt *clnt; 1891 struct rpc_clnt *clnt;
1889 struct rpc_task *task; 1892 struct rpc_task *task;
1890 int header = 0; 1893 int header = 0;
1894 struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
1891 1895
1892 spin_lock(&rpc_client_lock); 1896 spin_lock(&sn->rpc_client_lock);
1893 list_for_each_entry(clnt, &all_clients, cl_clients) { 1897 list_for_each_entry(clnt, &sn->all_clients, cl_clients) {
1894 spin_lock(&clnt->cl_lock); 1898 spin_lock(&clnt->cl_lock);
1895 list_for_each_entry(task, &clnt->cl_tasks, tk_task) { 1899 list_for_each_entry(task, &clnt->cl_tasks, tk_task) {
1896 if (!header) { 1900 if (!header) {
@@ -1901,6 +1905,6 @@ void rpc_show_tasks(void)
1901 } 1905 }
1902 spin_unlock(&clnt->cl_lock); 1906 spin_unlock(&clnt->cl_lock);
1903 } 1907 }
1904 spin_unlock(&rpc_client_lock); 1908 spin_unlock(&sn->rpc_client_lock);
1905} 1909}
1906#endif 1910#endif
diff --git a/net/sunrpc/netns.h b/net/sunrpc/netns.h
index 11d2f4863403..0f3af34fa502 100644
--- a/net/sunrpc/netns.h
+++ b/net/sunrpc/netns.h
@@ -12,6 +12,9 @@ struct sunrpc_net {
12 12
13 struct super_block *pipefs_sb; 13 struct super_block *pipefs_sb;
14 struct mutex pipefs_sb_lock; 14 struct mutex pipefs_sb_lock;
15
16 struct list_head all_clients;
17 spinlock_t rpc_client_lock;
15}; 18};
16 19
17extern int sunrpc_net_id; 20extern int sunrpc_net_id;
diff --git a/net/sunrpc/sunrpc_syms.c b/net/sunrpc/sunrpc_syms.c
index 7086d11589c8..b4217dc8599c 100644
--- a/net/sunrpc/sunrpc_syms.c
+++ b/net/sunrpc/sunrpc_syms.c
@@ -29,6 +29,7 @@ int sunrpc_net_id;
29static __net_init int sunrpc_init_net(struct net *net) 29static __net_init int sunrpc_init_net(struct net *net)
30{ 30{
31 int err; 31 int err;
32 struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
32 33
33 err = rpc_proc_init(net); 34 err = rpc_proc_init(net);
34 if (err) 35 if (err)
@@ -39,6 +40,8 @@ static __net_init int sunrpc_init_net(struct net *net)
39 goto err_ipmap; 40 goto err_ipmap;
40 41
41 rpc_pipefs_init_net(net); 42 rpc_pipefs_init_net(net);
43 INIT_LIST_HEAD(&sn->all_clients);
44 spin_lock_init(&sn->rpc_client_lock);
42 return 0; 45 return 0;
43 46
44err_ipmap: 47err_ipmap:
diff --git a/net/sunrpc/sysctl.c b/net/sunrpc/sysctl.c
index e65dcc613339..af7d339add9d 100644
--- a/net/sunrpc/sysctl.c
+++ b/net/sunrpc/sysctl.c
@@ -20,6 +20,8 @@
20#include <linux/sunrpc/stats.h> 20#include <linux/sunrpc/stats.h>
21#include <linux/sunrpc/svc_xprt.h> 21#include <linux/sunrpc/svc_xprt.h>
22 22
23#include "netns.h"
24
23/* 25/*
24 * Declare the debug flags here 26 * Declare the debug flags here
25 */ 27 */
@@ -110,7 +112,7 @@ proc_dodebug(ctl_table *table, int write,
110 *(unsigned int *) table->data = value; 112 *(unsigned int *) table->data = value;
111 /* Display the RPC tasks on writing to rpc_debug */ 113 /* Display the RPC tasks on writing to rpc_debug */
112 if (strcmp(table->procname, "rpc_debug") == 0) 114 if (strcmp(table->procname, "rpc_debug") == 0)
113 rpc_show_tasks(); 115 rpc_show_tasks(&init_net);
114 } else { 116 } else {
115 if (!access_ok(VERIFY_WRITE, buffer, left)) 117 if (!access_ok(VERIFY_WRITE, buffer, left))
116 return -EFAULT; 118 return -EFAULT;