Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Stanislav Kinsbursky and committed by
Trond Myklebust
70abc49b ccdc28f8

+26 -13
+2 -1
include/linux/sunrpc/sched.h
··· 244 244 void rpciod_down(void); 245 245 int __rpc_wait_for_completion_task(struct rpc_task *task, int (*)(void *)); 246 246 #ifdef RPC_DEBUG 247 - void rpc_show_tasks(void); 247 + struct net; 248 + void rpc_show_tasks(struct net *); 248 249 #endif 249 250 int rpc_init_mempool(void); 250 251 void rpc_destroy_mempool(void);
+15 -11
net/sunrpc/clnt.c
··· 38 38 #include <linux/sunrpc/bc_xprt.h> 39 39 40 40 #include "sunrpc.h" 41 + #include "netns.h" 41 42 42 43 #ifdef RPC_DEBUG 43 44 # define RPCDBG_FACILITY RPCDBG_CALL ··· 51 50 /* 52 51 * All RPC clients are linked into this list 53 52 */ 54 - static LIST_HEAD(all_clients); 55 - static DEFINE_SPINLOCK(rpc_client_lock); 56 53 57 54 static DECLARE_WAIT_QUEUE_HEAD(destroy_wait); 58 55 ··· 80 81 81 82 static void rpc_register_client(struct rpc_clnt *clnt) 82 83 { 83 - spin_lock(&rpc_client_lock); 84 - list_add(&clnt->cl_clients, &all_clients); 85 - spin_unlock(&rpc_client_lock); 84 + struct sunrpc_net *sn = net_generic(clnt->cl_xprt->xprt_net, sunrpc_net_id); 85 + 86 + spin_lock(&sn->rpc_client_lock); 87 + list_add(&clnt->cl_clients, &sn->all_clients); 88 + spin_unlock(&sn->rpc_client_lock); 86 89 } 87 90 88 91 static void rpc_unregister_client(struct rpc_clnt *clnt) 89 92 { 90 - spin_lock(&rpc_client_lock); 93 + struct sunrpc_net *sn = net_generic(clnt->cl_xprt->xprt_net, sunrpc_net_id); 94 + 95 + spin_lock(&sn->rpc_client_lock); 91 96 list_del(&clnt->cl_clients); 92 - spin_unlock(&rpc_client_lock); 97 + spin_unlock(&sn->rpc_client_lock); 93 98 } 94 99 95 100 static void __rpc_clnt_remove_pipedir(struct rpc_clnt *clnt) ··· 1886 1883 task->tk_action, rpc_waitq); 1887 1884 } 1888 1885 1889 - void rpc_show_tasks(void) 1886 + void rpc_show_tasks(struct net *net) 1890 1887 { 1891 1888 struct rpc_clnt *clnt; 1892 1889 struct rpc_task *task; 1893 1890 int header = 0; 1891 + struct sunrpc_net *sn = net_generic(net, sunrpc_net_id); 1894 1892 1895 - spin_lock(&rpc_client_lock); 1896 - list_for_each_entry(clnt, &all_clients, cl_clients) { 1893 + spin_lock(&sn->rpc_client_lock); 1894 + list_for_each_entry(clnt, &sn->all_clients, cl_clients) { 1897 1895 spin_lock(&clnt->cl_lock); 1898 1896 list_for_each_entry(task, &clnt->cl_tasks, tk_task) { 1899 1897 if (!header) { ··· 1905 1901 } 1906 1902 spin_unlock(&clnt->cl_lock); 1907 1903 } 1908 - spin_unlock(&rpc_client_lock); 1904 + spin_unlock(&sn->rpc_client_lock); 1909 1905 } 1910 1906 #endif
+3
net/sunrpc/netns.h
··· 12 12 13 13 struct super_block *pipefs_sb; 14 14 struct mutex pipefs_sb_lock; 15 + 16 + struct list_head all_clients; 17 + spinlock_t rpc_client_lock; 15 18 }; 16 19 17 20 extern int sunrpc_net_id;
+3
net/sunrpc/sunrpc_syms.c
··· 29 29 static __net_init int sunrpc_init_net(struct net *net) 30 30 { 31 31 int err; 32 + struct sunrpc_net *sn = net_generic(net, sunrpc_net_id); 32 33 33 34 err = rpc_proc_init(net); 34 35 if (err) ··· 40 39 goto err_ipmap; 41 40 42 41 rpc_pipefs_init_net(net); 42 + INIT_LIST_HEAD(&sn->all_clients); 43 + spin_lock_init(&sn->rpc_client_lock); 43 44 return 0; 44 45 45 46 err_ipmap:
+3 -1
net/sunrpc/sysctl.c
··· 20 20 #include <linux/sunrpc/stats.h> 21 21 #include <linux/sunrpc/svc_xprt.h> 22 22 23 + #include "netns.h" 24 + 23 25 /* 24 26 * Declare the debug flags here 25 27 */ ··· 112 110 *(unsigned int *) table->data = value; 113 111 /* Display the RPC tasks on writing to rpc_debug */ 114 112 if (strcmp(table->procname, "rpc_debug") == 0) 115 - rpc_show_tasks(); 113 + rpc_show_tasks(&init_net); 116 114 } else { 117 115 if (!access_ok(VERIFY_WRITE, buffer, left)) 118 116 return -EFAULT;