aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/clnt.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/sunrpc/clnt.c')
-rw-r--r--net/sunrpc/clnt.c48
1 files changed, 30 insertions, 18 deletions
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index cdc7564b4512..822f020fa7f4 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -132,8 +132,10 @@ static struct dentry *rpc_setup_pipedir_sb(struct super_block *sb,
132 int error; 132 int error;
133 133
134 dir = rpc_d_lookup_sb(sb, dir_name); 134 dir = rpc_d_lookup_sb(sb, dir_name);
135 if (dir == NULL) 135 if (dir == NULL) {
136 pr_info("RPC: pipefs directory doesn't exist: %s\n", dir_name);
136 return dir; 137 return dir;
138 }
137 for (;;) { 139 for (;;) {
138 q.len = snprintf(name, sizeof(name), "clnt%x", (unsigned int)clntid++); 140 q.len = snprintf(name, sizeof(name), "clnt%x", (unsigned int)clntid++);
139 name[sizeof(name) - 1] = '\0'; 141 name[sizeof(name) - 1] = '\0';
@@ -192,7 +194,8 @@ static int __rpc_clnt_handle_event(struct rpc_clnt *clnt, unsigned long event,
192 case RPC_PIPEFS_MOUNT: 194 case RPC_PIPEFS_MOUNT:
193 dentry = rpc_setup_pipedir_sb(sb, clnt, 195 dentry = rpc_setup_pipedir_sb(sb, clnt,
194 clnt->cl_program->pipe_dir_name); 196 clnt->cl_program->pipe_dir_name);
195 BUG_ON(dentry == NULL); 197 if (!dentry)
198 return -ENOENT;
196 if (IS_ERR(dentry)) 199 if (IS_ERR(dentry))
197 return PTR_ERR(dentry); 200 return PTR_ERR(dentry);
198 clnt->cl_dentry = dentry; 201 clnt->cl_dentry = dentry;
@@ -234,7 +237,7 @@ static struct rpc_clnt *rpc_get_client_for_event(struct net *net, int event)
234 spin_lock(&sn->rpc_client_lock); 237 spin_lock(&sn->rpc_client_lock);
235 list_for_each_entry(clnt, &sn->all_clients, cl_clients) { 238 list_for_each_entry(clnt, &sn->all_clients, cl_clients) {
236 if (clnt->cl_program->pipe_dir_name == NULL) 239 if (clnt->cl_program->pipe_dir_name == NULL)
237 break; 240 continue;
238 if (rpc_clnt_skip_event(clnt, event)) 241 if (rpc_clnt_skip_event(clnt, event))
239 continue; 242 continue;
240 if (atomic_inc_not_zero(&clnt->cl_count) == 0) 243 if (atomic_inc_not_zero(&clnt->cl_count) == 0)
@@ -607,6 +610,13 @@ EXPORT_SYMBOL_GPL(rpc_killall_tasks);
607 */ 610 */
608void rpc_shutdown_client(struct rpc_clnt *clnt) 611void rpc_shutdown_client(struct rpc_clnt *clnt)
609{ 612{
613 /*
614 * To avoid deadlock, never call rpc_shutdown_client from a
615 * workqueue context!
616 */
617 WARN_ON_ONCE(current->flags & PF_WQ_WORKER);
618 might_sleep();
619
610 dprintk_rcu("RPC: shutting down %s client for %s\n", 620 dprintk_rcu("RPC: shutting down %s client for %s\n",
611 clnt->cl_protname, 621 clnt->cl_protname,
612 rcu_dereference(clnt->cl_xprt)->servername); 622 rcu_dereference(clnt->cl_xprt)->servername);
@@ -693,21 +703,19 @@ struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *old,
693 const struct rpc_program *program, 703 const struct rpc_program *program,
694 u32 vers) 704 u32 vers)
695{ 705{
706 struct rpc_create_args args = {
707 .program = program,
708 .prognumber = program->number,
709 .version = vers,
710 .authflavor = old->cl_auth->au_flavor,
711 .client_name = old->cl_principal,
712 };
696 struct rpc_clnt *clnt; 713 struct rpc_clnt *clnt;
697 const struct rpc_version *version;
698 int err; 714 int err;
699 715
700 BUG_ON(vers >= program->nrvers || !program->version[vers]); 716 clnt = __rpc_clone_client(&args, old);
701 version = program->version[vers];
702 clnt = rpc_clone_client(old);
703 if (IS_ERR(clnt)) 717 if (IS_ERR(clnt))
704 goto out; 718 goto out;
705 clnt->cl_procinfo = version->procs;
706 clnt->cl_maxproc = version->nrprocs;
707 clnt->cl_protname = program->name;
708 clnt->cl_prog = program->number;
709 clnt->cl_vers = version->number;
710 clnt->cl_stats = program->stats;
711 err = rpc_ping(clnt); 719 err = rpc_ping(clnt);
712 if (err != 0) { 720 if (err != 0) {
713 rpc_shutdown_client(clnt); 721 rpc_shutdown_client(clnt);
@@ -832,7 +840,12 @@ int rpc_call_sync(struct rpc_clnt *clnt, const struct rpc_message *msg, int flag
832 }; 840 };
833 int status; 841 int status;
834 842
835 BUG_ON(flags & RPC_TASK_ASYNC); 843 WARN_ON_ONCE(flags & RPC_TASK_ASYNC);
844 if (flags & RPC_TASK_ASYNC) {
845 rpc_release_calldata(task_setup_data.callback_ops,
846 task_setup_data.callback_data);
847 return -EINVAL;
848 }
836 849
837 task = rpc_run_task(&task_setup_data); 850 task = rpc_run_task(&task_setup_data);
838 if (IS_ERR(task)) 851 if (IS_ERR(task))
@@ -908,7 +921,7 @@ struct rpc_task *rpc_run_bc_task(struct rpc_rqst *req,
908 921
909 task->tk_action = call_bc_transmit; 922 task->tk_action = call_bc_transmit;
910 atomic_inc(&task->tk_count); 923 atomic_inc(&task->tk_count);
911 BUG_ON(atomic_read(&task->tk_count) != 2); 924 WARN_ON_ONCE(atomic_read(&task->tk_count) != 2);
912 rpc_execute(task); 925 rpc_execute(task);
913 926
914out: 927out:
@@ -1368,6 +1381,7 @@ call_refreshresult(struct rpc_task *task)
1368 return; 1381 return;
1369 case -ETIMEDOUT: 1382 case -ETIMEDOUT:
1370 rpc_delay(task, 3*HZ); 1383 rpc_delay(task, 3*HZ);
1384 case -EKEYEXPIRED:
1371 case -EAGAIN: 1385 case -EAGAIN:
1372 status = -EACCES; 1386 status = -EACCES;
1373 if (!task->tk_cred_retry) 1387 if (!task->tk_cred_retry)
@@ -1654,7 +1668,6 @@ call_transmit(struct rpc_task *task)
1654 task->tk_action = call_transmit_status; 1668 task->tk_action = call_transmit_status;
1655 /* Encode here so that rpcsec_gss can use correct sequence number. */ 1669 /* Encode here so that rpcsec_gss can use correct sequence number. */
1656 if (rpc_task_need_encode(task)) { 1670 if (rpc_task_need_encode(task)) {
1657 BUG_ON(task->tk_rqstp->rq_bytes_sent != 0);
1658 rpc_xdr_encode(task); 1671 rpc_xdr_encode(task);
1659 /* Did the encode result in an error condition? */ 1672 /* Did the encode result in an error condition? */
1660 if (task->tk_status != 0) { 1673 if (task->tk_status != 0) {
@@ -1738,7 +1751,6 @@ call_bc_transmit(struct rpc_task *task)
1738{ 1751{
1739 struct rpc_rqst *req = task->tk_rqstp; 1752 struct rpc_rqst *req = task->tk_rqstp;
1740 1753
1741 BUG_ON(task->tk_status != 0);
1742 task->tk_status = xprt_prepare_transmit(task); 1754 task->tk_status = xprt_prepare_transmit(task);
1743 if (task->tk_status == -EAGAIN) { 1755 if (task->tk_status == -EAGAIN) {
1744 /* 1756 /*
@@ -1785,7 +1797,7 @@ call_bc_transmit(struct rpc_task *task)
1785 * We were unable to reply and will have to drop the 1797 * We were unable to reply and will have to drop the
1786 * request. The server should reconnect and retransmit. 1798 * request. The server should reconnect and retransmit.
1787 */ 1799 */
1788 BUG_ON(task->tk_status == -EAGAIN); 1800 WARN_ON_ONCE(task->tk_status == -EAGAIN);
1789 printk(KERN_NOTICE "RPC: Could not send backchannel reply " 1801 printk(KERN_NOTICE "RPC: Could not send backchannel reply "
1790 "error: %d\n", task->tk_status); 1802 "error: %d\n", task->tk_status);
1791 break; 1803 break;