Commit 4c402b40 authored by Trond Myklebust's avatar Trond Myklebust

SUNRPC: Remove rpc_clnt->cl_count

The kref now does most of what cl_count + cl_user used to do. The only
remaining role for cl_count is to tell us if we are in a 'shutdown'
phase. We can provide that information using a single bit field instead
of a full atomic counter.

Also rename rpc_destroy_client() to rpc_close_client(), which reflects
better what its role is these days.
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 8ad7c892
...@@ -25,7 +25,6 @@ struct rpc_inode; ...@@ -25,7 +25,6 @@ struct rpc_inode;
*/ */
struct rpc_clnt { struct rpc_clnt {
struct kref cl_kref; /* Number of references */ struct kref cl_kref; /* Number of references */
atomic_t cl_count; /* Number of clones */
struct list_head cl_clients; /* Global list of clients */ struct list_head cl_clients; /* Global list of clients */
struct list_head cl_tasks; /* List of tasks */ struct list_head cl_tasks; /* List of tasks */
spinlock_t cl_lock; /* spinlock */ spinlock_t cl_lock; /* spinlock */
...@@ -119,8 +118,7 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args); ...@@ -119,8 +118,7 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args);
struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *, struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *,
struct rpc_program *, int); struct rpc_program *, int);
struct rpc_clnt *rpc_clone_client(struct rpc_clnt *); struct rpc_clnt *rpc_clone_client(struct rpc_clnt *);
int rpc_shutdown_client(struct rpc_clnt *); void rpc_shutdown_client(struct rpc_clnt *);
int rpc_destroy_client(struct rpc_clnt *);
void rpc_release_client(struct rpc_clnt *); void rpc_release_client(struct rpc_clnt *);
void rpc_register_client(struct rpc_clnt *); void rpc_register_client(struct rpc_clnt *);
void rpc_unregister_client(struct rpc_clnt *); void rpc_unregister_client(struct rpc_clnt *);
......
...@@ -121,7 +121,6 @@ static struct rpc_clnt * rpc_new_client(struct rpc_xprt *xprt, char *servname, s ...@@ -121,7 +121,6 @@ static struct rpc_clnt * rpc_new_client(struct rpc_xprt *xprt, char *servname, s
clnt = kzalloc(sizeof(*clnt), GFP_KERNEL); clnt = kzalloc(sizeof(*clnt), GFP_KERNEL);
if (!clnt) if (!clnt)
goto out_err; goto out_err;
atomic_set(&clnt->cl_count, 1);
clnt->cl_parent = clnt; clnt->cl_parent = clnt;
clnt->cl_server = clnt->cl_inline_name; clnt->cl_server = clnt->cl_inline_name;
...@@ -270,7 +269,6 @@ rpc_clone_client(struct rpc_clnt *clnt) ...@@ -270,7 +269,6 @@ rpc_clone_client(struct rpc_clnt *clnt)
new = kmemdup(clnt, sizeof(*new), GFP_KERNEL); new = kmemdup(clnt, sizeof(*new), GFP_KERNEL);
if (!new) if (!new)
goto out_no_clnt; goto out_no_clnt;
atomic_set(&new->cl_count, 1);
new->cl_metrics = rpc_alloc_iostats(clnt); new->cl_metrics = rpc_alloc_iostats(clnt);
if (new->cl_metrics == NULL) if (new->cl_metrics == NULL)
goto out_no_stats; goto out_no_stats;
...@@ -303,8 +301,7 @@ rpc_clone_client(struct rpc_clnt *clnt) ...@@ -303,8 +301,7 @@ rpc_clone_client(struct rpc_clnt *clnt)
* Properly shut down an RPC client, terminating all outstanding * Properly shut down an RPC client, terminating all outstanding
* requests. * requests.
*/ */
int void rpc_shutdown_client(struct rpc_clnt *clnt)
rpc_shutdown_client(struct rpc_clnt *clnt)
{ {
dprintk("RPC: shutting down %s client for %s\n", dprintk("RPC: shutting down %s client for %s\n",
clnt->cl_protname, clnt->cl_server); clnt->cl_protname, clnt->cl_server);
...@@ -315,7 +312,7 @@ rpc_shutdown_client(struct rpc_clnt *clnt) ...@@ -315,7 +312,7 @@ rpc_shutdown_client(struct rpc_clnt *clnt)
list_empty(&clnt->cl_tasks), 1*HZ); list_empty(&clnt->cl_tasks), 1*HZ);
} }
return rpc_destroy_client(clnt); rpc_release_client(clnt);
} }
/* /*
...@@ -363,18 +360,6 @@ rpc_release_client(struct rpc_clnt *clnt) ...@@ -363,18 +360,6 @@ rpc_release_client(struct rpc_clnt *clnt)
kref_put(&clnt->cl_kref, rpc_free_client); kref_put(&clnt->cl_kref, rpc_free_client);
} }
/*
* Delete an RPC client
*/
int
rpc_destroy_client(struct rpc_clnt *clnt)
{
if (!atomic_dec_and_test(&clnt->cl_count))
return 1;
kref_put(&clnt->cl_kref, rpc_free_client);
return 0;
}
/** /**
* rpc_bind_new_program - bind a new RPC program to an existing client * rpc_bind_new_program - bind a new RPC program to an existing client
* @old - old rpc_client * @old - old rpc_client
......
...@@ -380,7 +380,7 @@ void rpcb_getport(struct rpc_task *task) ...@@ -380,7 +380,7 @@ void rpcb_getport(struct rpc_task *task)
} }
child = rpc_run_task(rpcb_clnt, RPC_TASK_ASYNC, &rpcb_getport_ops, map); child = rpc_run_task(rpcb_clnt, RPC_TASK_ASYNC, &rpcb_getport_ops, map);
rpc_destroy_client(rpcb_clnt); rpc_release_client(rpcb_clnt);
if (IS_ERR(child)) { if (IS_ERR(child)) {
status = -EIO; status = -EIO;
dprintk("RPC: %5u rpcb_getport rpc_run_task failed\n", dprintk("RPC: %5u rpcb_getport rpc_run_task failed\n",
......
...@@ -35,7 +35,6 @@ EXPORT_SYMBOL(rpc_wake_up_status); ...@@ -35,7 +35,6 @@ EXPORT_SYMBOL(rpc_wake_up_status);
/* RPC client functions */ /* RPC client functions */
EXPORT_SYMBOL(rpc_clone_client); EXPORT_SYMBOL(rpc_clone_client);
EXPORT_SYMBOL(rpc_bind_new_program); EXPORT_SYMBOL(rpc_bind_new_program);
EXPORT_SYMBOL(rpc_destroy_client);
EXPORT_SYMBOL(rpc_shutdown_client); EXPORT_SYMBOL(rpc_shutdown_client);
EXPORT_SYMBOL(rpc_killall_tasks); EXPORT_SYMBOL(rpc_killall_tasks);
EXPORT_SYMBOL(rpc_call_sync); EXPORT_SYMBOL(rpc_call_sync);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment