Skip to content

Commit 70abc49

Browse files
Stanislav KinsburskyTrond Myklebust
authored andcommitted
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>
1 parent ccdc28f commit 70abc49

5 files changed

Lines changed: 26 additions & 13 deletions

File tree

‎include/linux/sunrpc/sched.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,8 @@ int rpciod_up(void);
244244
void rpciod_down(void);
245245
int __rpc_wait_for_completion_task(struct rpc_task *task, int (*)(void *));
246246
#ifdef RPC_DEBUG
247-
void rpc_show_tasks(void);
247+
struct net;
248+
void rpc_show_tasks(struct net *);
248249
#endif
249250
int rpc_init_mempool(void);
250251
void rpc_destroy_mempool(void);

‎net/sunrpc/clnt.c‎

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include <linux/sunrpc/bc_xprt.h>
3939

4040
#include "sunrpc.h"
41+
#include "netns.h"
4142

4243
#ifdef RPC_DEBUG
4344
# define RPCDBG_FACILITY RPCDBG_CALL
@@ -50,8 +51,6 @@
5051
/*
5152
* All RPC clients are linked into this list
5253
*/
53-
static LIST_HEAD(all_clients);
54-
static DEFINE_SPINLOCK(rpc_client_lock);
5554

5655
static DECLARE_WAIT_QUEUE_HEAD(destroy_wait);
5756

@@ -81,16 +80,20 @@ static int rpc_ping(struct rpc_clnt *clnt);
8180

8281
static void rpc_register_client(struct rpc_clnt *clnt)
8382
{
84-
spin_lock(&rpc_client_lock);
85-
list_add(&clnt->cl_clients, &all_clients);
86-
spin_unlock(&rpc_client_lock);
83+
struct sunrpc_net *sn = net_generic(clnt->cl_xprt->xprt_net, sunrpc_net_id);
84+
85+
spin_lock(&sn->rpc_client_lock);
86+
list_add(&clnt->cl_clients, &sn->all_clients);
87+
spin_unlock(&sn->rpc_client_lock);
8788
}
8889

8990
static void rpc_unregister_client(struct rpc_clnt *clnt)
9091
{
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);
9295
list_del(&clnt->cl_clients);
93-
spin_unlock(&rpc_client_lock);
96+
spin_unlock(&sn->rpc_client_lock);
9497
}
9598

9699
static void __rpc_clnt_remove_pipedir(struct rpc_clnt *clnt)
@@ -1883,14 +1886,15 @@ static void rpc_show_task(const struct rpc_clnt *clnt,
18831886
task->tk_action, rpc_waitq);
18841887
}
18851888

1886-
void rpc_show_tasks(void)
1889+
void rpc_show_tasks(struct net *net)
18871890
{
18881891
struct rpc_clnt *clnt;
18891892
struct rpc_task *task;
18901893
int header = 0;
1894+
struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
18911895

1892-
spin_lock(&rpc_client_lock);
1893-
list_for_each_entry(clnt, &all_clients, cl_clients) {
1896+
spin_lock(&sn->rpc_client_lock);
1897+
list_for_each_entry(clnt, &sn->all_clients, cl_clients) {
18941898
spin_lock(&clnt->cl_lock);
18951899
list_for_each_entry(task, &clnt->cl_tasks, tk_task) {
18961900
if (!header) {
@@ -1901,6 +1905,6 @@ void rpc_show_tasks(void)
19011905
}
19021906
spin_unlock(&clnt->cl_lock);
19031907
}
1904-
spin_unlock(&rpc_client_lock);
1908+
spin_unlock(&sn->rpc_client_lock);
19051909
}
19061910
#endif

‎net/sunrpc/netns.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ struct sunrpc_net {
1212

1313
struct super_block *pipefs_sb;
1414
struct mutex pipefs_sb_lock;
15+
16+
struct list_head all_clients;
17+
spinlock_t rpc_client_lock;
1518
};
1619

1720
extern int sunrpc_net_id;

‎net/sunrpc/sunrpc_syms.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ int sunrpc_net_id;
2929
static __net_init int sunrpc_init_net(struct net *net)
3030
{
3131
int err;
32+
struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
3233

3334
err = rpc_proc_init(net);
3435
if (err)
@@ -39,6 +40,8 @@ static __net_init int sunrpc_init_net(struct net *net)
3940
goto err_ipmap;
4041

4142
rpc_pipefs_init_net(net);
43+
INIT_LIST_HEAD(&sn->all_clients);
44+
spin_lock_init(&sn->rpc_client_lock);
4245
return 0;
4346

4447
err_ipmap:

‎net/sunrpc/sysctl.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include <linux/sunrpc/stats.h>
2121
#include <linux/sunrpc/svc_xprt.h>
2222

23+
#include "netns.h"
24+
2325
/*
2426
* Declare the debug flags here
2527
*/
@@ -110,7 +112,7 @@ proc_dodebug(ctl_table *table, int write,
110112
*(unsigned int *) table->data = value;
111113
/* Display the RPC tasks on writing to rpc_debug */
112114
if (strcmp(table->procname, "rpc_debug") == 0)
113-
rpc_show_tasks();
115+
rpc_show_tasks(&init_net);
114116
} else {
115117
if (!access_ok(VERIFY_WRITE, buffer, left))
116118
return -EFAULT;

0 commit comments

Comments
 (0)