SUNRPC: Make create_client() take a reference to the rpciod workqueue
[safe/jmp/linux-2.6] / net / sunrpc / clnt.c
index be5524d..fe838e9 100644 (file)
@@ -111,6 +111,9 @@ static struct rpc_clnt * rpc_new_client(struct rpc_xprt *xprt, char *servname, s
        dprintk("RPC:       creating %s client for %s (xprt %p)\n",
                        program->name, servname, xprt);
 
+       err = rpciod_up();
+       if (err)
+               goto out_no_rpciod;
        err = -EINVAL;
        if (!xprt)
                goto out_no_xprt;
@@ -191,6 +194,8 @@ out_no_stats:
 out_err:
        xprt_put(xprt);
 out_no_xprt:
+       rpciod_down();
+out_no_rpciod:
        return ERR_PTR(err);
 }
 
@@ -269,6 +274,12 @@ rpc_clone_client(struct rpc_clnt *clnt)
        new = kmemdup(clnt, sizeof(*new), GFP_KERNEL);
        if (!new)
                goto out_no_clnt;
+       new->cl_parent = clnt;
+       /* Turn off autobind on clones */
+       new->cl_autobind = 0;
+       INIT_LIST_HEAD(&new->cl_tasks);
+       spin_lock_init(&new->cl_lock);
+       rpc_init_rtt(&new->cl_rtt_default, clnt->cl_xprt->timeout.to_initval);
        new->cl_metrics = rpc_alloc_iostats(clnt);
        if (new->cl_metrics == NULL)
                goto out_no_stats;
@@ -276,17 +287,12 @@ rpc_clone_client(struct rpc_clnt *clnt)
        err = rpc_setup_pipedir(new, clnt->cl_program->pipe_dir_name);
        if (err != 0)
                goto out_no_path;
-       new->cl_parent = clnt;
-       kref_get(&clnt->cl_kref);
-       new->cl_xprt = xprt_get(clnt->cl_xprt);
-       /* Turn off autobind on clones */
-       new->cl_autobind = 0;
-       INIT_LIST_HEAD(&new->cl_tasks);
-       spin_lock_init(&new->cl_lock);
-       rpc_init_rtt(&new->cl_rtt_default, clnt->cl_xprt->timeout.to_initval);
        if (new->cl_auth)
                atomic_inc(&new->cl_auth->au_count);
+       xprt_get(clnt->cl_xprt);
+       kref_get(&clnt->cl_kref);
        rpc_register_client(new);
+       rpciod_up();
        return new;
 out_no_path:
        rpc_free_iostats(new->cl_metrics);
@@ -344,6 +350,7 @@ out_free:
        rpc_free_iostats(clnt->cl_metrics);
        clnt->cl_metrics = NULL;
        xprt_put(clnt->cl_xprt);
+       rpciod_down();
        kfree(clnt);
 }