diff options
author | Trond Myklebust <Trond.Myklebust@netapp.com> | 2007-06-14 17:26:17 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2007-07-10 23:40:30 -0400 |
commit | 4ada539ed77c7a2bbcb75cafbbd7bd8d2b9bef7b (patch) | |
tree | cb4ba7df88aee07173dc7e44a3c35249ae4ab539 | |
parent | ab418d70e1fceda1e2824c45ba3323a1b1413507 (diff) |
SUNRPC: Make create_client() take a reference to the rpciod workqueue
Ensures that an rpc_client always has the possibility to send asynchronous
RPC calls.
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r-- | net/sunrpc/clnt.c | 7 | ||||
-rw-r--r-- | net/sunrpc/sched.c | 31 |
2 files changed, 7 insertions, 31 deletions
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 78bbb359281d..fe838e996ee3 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c | |||
@@ -111,6 +111,9 @@ static struct rpc_clnt * rpc_new_client(struct rpc_xprt *xprt, char *servname, s | |||
111 | dprintk("RPC: creating %s client for %s (xprt %p)\n", | 111 | dprintk("RPC: creating %s client for %s (xprt %p)\n", |
112 | program->name, servname, xprt); | 112 | program->name, servname, xprt); |
113 | 113 | ||
114 | err = rpciod_up(); | ||
115 | if (err) | ||
116 | goto out_no_rpciod; | ||
114 | err = -EINVAL; | 117 | err = -EINVAL; |
115 | if (!xprt) | 118 | if (!xprt) |
116 | goto out_no_xprt; | 119 | goto out_no_xprt; |
@@ -191,6 +194,8 @@ out_no_stats: | |||
191 | out_err: | 194 | out_err: |
192 | xprt_put(xprt); | 195 | xprt_put(xprt); |
193 | out_no_xprt: | 196 | out_no_xprt: |
197 | rpciod_down(); | ||
198 | out_no_rpciod: | ||
194 | return ERR_PTR(err); | 199 | return ERR_PTR(err); |
195 | } | 200 | } |
196 | 201 | ||
@@ -287,6 +292,7 @@ rpc_clone_client(struct rpc_clnt *clnt) | |||
287 | xprt_get(clnt->cl_xprt); | 292 | xprt_get(clnt->cl_xprt); |
288 | kref_get(&clnt->cl_kref); | 293 | kref_get(&clnt->cl_kref); |
289 | rpc_register_client(new); | 294 | rpc_register_client(new); |
295 | rpciod_up(); | ||
290 | return new; | 296 | return new; |
291 | out_no_path: | 297 | out_no_path: |
292 | rpc_free_iostats(new->cl_metrics); | 298 | rpc_free_iostats(new->cl_metrics); |
@@ -344,6 +350,7 @@ out_free: | |||
344 | rpc_free_iostats(clnt->cl_metrics); | 350 | rpc_free_iostats(clnt->cl_metrics); |
345 | clnt->cl_metrics = NULL; | 351 | clnt->cl_metrics = NULL; |
346 | xprt_put(clnt->cl_xprt); | 352 | xprt_put(clnt->cl_xprt); |
353 | rpciod_down(); | ||
347 | kfree(clnt); | 354 | kfree(clnt); |
348 | } | 355 | } |
349 | 356 | ||
diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c index f6eed4d4e5dd..05825154ddd9 100644 --- a/net/sunrpc/sched.c +++ b/net/sunrpc/sched.c | |||
@@ -39,7 +39,6 @@ static mempool_t *rpc_task_mempool __read_mostly; | |||
39 | static mempool_t *rpc_buffer_mempool __read_mostly; | 39 | static mempool_t *rpc_buffer_mempool __read_mostly; |
40 | 40 | ||
41 | static void __rpc_default_timer(struct rpc_task *task); | 41 | static void __rpc_default_timer(struct rpc_task *task); |
42 | static void rpciod_killall(void); | ||
43 | static void rpc_async_schedule(struct work_struct *); | 42 | static void rpc_async_schedule(struct work_struct *); |
44 | static void rpc_release_task(struct rpc_task *task); | 43 | static void rpc_release_task(struct rpc_task *task); |
45 | 44 | ||
@@ -52,7 +51,6 @@ static RPC_WAITQ(delay_queue, "delayq"); | |||
52 | * All RPC clients are linked into this list | 51 | * All RPC clients are linked into this list |
53 | */ | 52 | */ |
54 | static LIST_HEAD(all_clients); | 53 | static LIST_HEAD(all_clients); |
55 | static DECLARE_WAIT_QUEUE_HEAD(client_kill_wait); | ||
56 | 54 | ||
57 | /* | 55 | /* |
58 | * rpciod-related stuff | 56 | * rpciod-related stuff |
@@ -996,32 +994,6 @@ void rpc_killall_tasks(struct rpc_clnt *clnt) | |||
996 | spin_unlock(&clnt->cl_lock); | 994 | spin_unlock(&clnt->cl_lock); |
997 | } | 995 | } |
998 | 996 | ||
999 | static void rpciod_killall(void) | ||
1000 | { | ||
1001 | struct rpc_clnt *clnt; | ||
1002 | unsigned long flags; | ||
1003 | |||
1004 | for(;;) { | ||
1005 | clear_thread_flag(TIF_SIGPENDING); | ||
1006 | |||
1007 | spin_lock(&rpc_sched_lock); | ||
1008 | list_for_each_entry(clnt, &all_clients, cl_clients) | ||
1009 | rpc_killall_tasks(clnt); | ||
1010 | spin_unlock(&rpc_sched_lock); | ||
1011 | flush_workqueue(rpciod_workqueue); | ||
1012 | if (!list_empty(&all_clients)) | ||
1013 | break; | ||
1014 | dprintk("RPC: rpciod_killall: waiting for tasks " | ||
1015 | "to exit\n"); | ||
1016 | wait_event_timeout(client_kill_wait, | ||
1017 | list_empty(&all_clients), 1*HZ); | ||
1018 | } | ||
1019 | |||
1020 | spin_lock_irqsave(¤t->sighand->siglock, flags); | ||
1021 | recalc_sigpending(); | ||
1022 | spin_unlock_irqrestore(¤t->sighand->siglock, flags); | ||
1023 | } | ||
1024 | |||
1025 | void rpc_register_client(struct rpc_clnt *clnt) | 997 | void rpc_register_client(struct rpc_clnt *clnt) |
1026 | { | 998 | { |
1027 | spin_lock(&rpc_sched_lock); | 999 | spin_lock(&rpc_sched_lock); |
@@ -1033,8 +1005,6 @@ void rpc_unregister_client(struct rpc_clnt *clnt) | |||
1033 | { | 1005 | { |
1034 | spin_lock(&rpc_sched_lock); | 1006 | spin_lock(&rpc_sched_lock); |
1035 | list_del(&clnt->cl_clients); | 1007 | list_del(&clnt->cl_clients); |
1036 | if (list_empty(&all_clients)) | ||
1037 | wake_up(&client_kill_wait); | ||
1038 | spin_unlock(&rpc_sched_lock); | 1008 | spin_unlock(&rpc_sched_lock); |
1039 | } | 1009 | } |
1040 | 1010 | ||
@@ -1083,7 +1053,6 @@ rpciod_down(void) | |||
1083 | dprintk("RPC: destroying workqueue rpciod\n"); | 1053 | dprintk("RPC: destroying workqueue rpciod\n"); |
1084 | 1054 | ||
1085 | if (atomic_read(&rpciod_users) == 0 && rpciod_workqueue != NULL) { | 1055 | if (atomic_read(&rpciod_users) == 0 && rpciod_workqueue != NULL) { |
1086 | rpciod_killall(); | ||
1087 | destroy_workqueue(rpciod_workqueue); | 1056 | destroy_workqueue(rpciod_workqueue); |
1088 | rpciod_workqueue = NULL; | 1057 | rpciod_workqueue = NULL; |
1089 | } | 1058 | } |