aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-12-18 12:36:34 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2012-12-18 12:36:34 -0500
commit2d4dce0070448bcb5ccd04553a4be4635417f565 (patch)
tree300915d2df0b8f28072d090c21d8ac084cd5f6c0 /net
parentea88eeac0cb8328014b53d80ca631e8dc0dc18dc (diff)
parentcd6c5968582a273561464fe6b1e8cc8214be02df (diff)
Merge tag 'nfs-for-3.8-1' of git://git.linux-nfs.org/projects/trondmy/linux-nfs
Pull NFS client updates from Trond Myklebust: "Features include: - Full audit of BUG_ON asserts in the NFS, SUNRPC and lockd client code. Remove altogether where possible, and replace with WARN_ON_ONCE and appropriate error returns where not. - NFSv4.1 client adds session dynamic slot table management. There is matching server side code that has been submitted to Bruce for consideration. Together, this code allows the server to dynamically manage the amount of memory it allocates to the duplicate request cache for each client. It will constantly resize those caches to reserve more memory for clients that are hot while shrinking caches for those that are quiescent. In addition, there are assorted bugfixes for the generic NFS write code, fixes to deal with the drop_nlink() warnings, and yet another fix for NFSv4 getacl." * tag 'nfs-for-3.8-1' of git://git.linux-nfs.org/projects/trondmy/linux-nfs: (106 commits) SUNRPC: continue run over clients list on PipeFS event instead of break NFS: Don't use SetPageError in the NFS writeback code SUNRPC: variable 'svsk' is unused in function bc_send_request SUNRPC: Handle ECONNREFUSED in xs_local_setup_socket NFSv4.1: Deal effectively with interrupted RPC calls. NFSv4.1: Move the RPC timestamp out of the slot. NFSv4.1: Try to deal with NFS4ERR_SEQ_MISORDERED. NFS: nfs_lookup_revalidate should not trust an inode with i_nlink == 0 NFS: Fix calls to drop_nlink() NFS: Ensure that we always drop inodes that have been marked as stale nfs: Remove unused list nfs4_clientid_list nfs: Remove duplicate function declaration in internal.h NFS: avoid NULL dereference in nfs_destroy_server SUNRPC handle EKEYEXPIRED in call_refreshresult SUNRPC set gss gc_expiry to full lifetime nfs: fix page dirtying in NFS DIO read codepath nfs: don't zero out the rest of the page if we hit the EOF on a DIO READ NFSv4.1: Be conservative about the client highest slotid NFSv4.1: Handle NFS4ERR_BADSLOT errors correctly nfs: don't extend writes to cover entire page if pagecache is invalid ...
Diffstat (limited to 'net')
-rw-r--r--net/sunrpc/auth_gss/auth_gss.c17
-rw-r--r--net/sunrpc/backchannel_rqst.c9
-rw-r--r--net/sunrpc/bc_svc.c2
-rw-r--r--net/sunrpc/cache.c4
-rw-r--r--net/sunrpc/clnt.c48
-rw-r--r--net/sunrpc/rpc_pipe.c9
-rw-r--r--net/sunrpc/rpcb_clnt.c5
-rw-r--r--net/sunrpc/sched.c71
-rw-r--r--net/sunrpc/svc.c12
-rw-r--r--net/sunrpc/svc_xprt.c11
-rw-r--r--net/sunrpc/svcsock.c6
-rw-r--r--net/sunrpc/xdr.c5
-rw-r--r--net/sunrpc/xprtsock.c19
13 files changed, 144 insertions, 74 deletions
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
index 909dc0c31aa..6e5c824b040 100644
--- a/net/sunrpc/auth_gss/auth_gss.c
+++ b/net/sunrpc/auth_gss/auth_gss.c
@@ -192,17 +192,23 @@ gss_fill_context(const void *p, const void *end, struct gss_cl_ctx *ctx, struct
192 const void *q; 192 const void *q;
193 unsigned int seclen; 193 unsigned int seclen;
194 unsigned int timeout; 194 unsigned int timeout;
195 unsigned long now = jiffies;
195 u32 window_size; 196 u32 window_size;
196 int ret; 197 int ret;
197 198
198 /* First unsigned int gives the lifetime (in seconds) of the cred */ 199 /* First unsigned int gives the remaining lifetime in seconds of the
200 * credential - e.g. the remaining TGT lifetime for Kerberos or
201 * the -t value passed to GSSD.
202 */
199 p = simple_get_bytes(p, end, &timeout, sizeof(timeout)); 203 p = simple_get_bytes(p, end, &timeout, sizeof(timeout));
200 if (IS_ERR(p)) 204 if (IS_ERR(p))
201 goto err; 205 goto err;
202 if (timeout == 0) 206 if (timeout == 0)
203 timeout = GSSD_MIN_TIMEOUT; 207 timeout = GSSD_MIN_TIMEOUT;
204 ctx->gc_expiry = jiffies + (unsigned long)timeout * HZ * 3 / 4; 208 ctx->gc_expiry = now + ((unsigned long)timeout * HZ);
205 /* Sequence number window. Determines the maximum number of simultaneous requests */ 209 /* Sequence number window. Determines the maximum number of
210 * simultaneous requests
211 */
206 p = simple_get_bytes(p, end, &window_size, sizeof(window_size)); 212 p = simple_get_bytes(p, end, &window_size, sizeof(window_size));
207 if (IS_ERR(p)) 213 if (IS_ERR(p))
208 goto err; 214 goto err;
@@ -237,9 +243,12 @@ gss_fill_context(const void *p, const void *end, struct gss_cl_ctx *ctx, struct
237 p = ERR_PTR(ret); 243 p = ERR_PTR(ret);
238 goto err; 244 goto err;
239 } 245 }
246 dprintk("RPC: %s Success. gc_expiry %lu now %lu timeout %u\n",
247 __func__, ctx->gc_expiry, now, timeout);
240 return q; 248 return q;
241err: 249err:
242 dprintk("RPC: %s returning %ld\n", __func__, -PTR_ERR(p)); 250 dprintk("RPC: %s returns %ld gc_expiry %lu now %lu timeout %u\n",
251 __func__, -PTR_ERR(p), ctx->gc_expiry, now, timeout);
243 return p; 252 return p;
244} 253}
245 254
diff --git a/net/sunrpc/backchannel_rqst.c b/net/sunrpc/backchannel_rqst.c
index a9c0bbccad6..890a29912d5 100644
--- a/net/sunrpc/backchannel_rqst.c
+++ b/net/sunrpc/backchannel_rqst.c
@@ -59,7 +59,7 @@ static void xprt_free_allocation(struct rpc_rqst *req)
59 struct xdr_buf *xbufp; 59 struct xdr_buf *xbufp;
60 60
61 dprintk("RPC: free allocations for req= %p\n", req); 61 dprintk("RPC: free allocations for req= %p\n", req);
62 BUG_ON(test_bit(RPC_BC_PA_IN_USE, &req->rq_bc_pa_state)); 62 WARN_ON_ONCE(test_bit(RPC_BC_PA_IN_USE, &req->rq_bc_pa_state));
63 xbufp = &req->rq_private_buf; 63 xbufp = &req->rq_private_buf;
64 free_page((unsigned long)xbufp->head[0].iov_base); 64 free_page((unsigned long)xbufp->head[0].iov_base);
65 xbufp = &req->rq_snd_buf; 65 xbufp = &req->rq_snd_buf;
@@ -191,7 +191,9 @@ void xprt_destroy_backchannel(struct rpc_xprt *xprt, unsigned int max_reqs)
191 191
192 dprintk("RPC: destroy backchannel transport\n"); 192 dprintk("RPC: destroy backchannel transport\n");
193 193
194 BUG_ON(max_reqs == 0); 194 if (max_reqs == 0)
195 goto out;
196
195 spin_lock_bh(&xprt->bc_pa_lock); 197 spin_lock_bh(&xprt->bc_pa_lock);
196 xprt_dec_alloc_count(xprt, max_reqs); 198 xprt_dec_alloc_count(xprt, max_reqs);
197 list_for_each_entry_safe(req, tmp, &xprt->bc_pa_list, rq_bc_pa_list) { 199 list_for_each_entry_safe(req, tmp, &xprt->bc_pa_list, rq_bc_pa_list) {
@@ -202,6 +204,7 @@ void xprt_destroy_backchannel(struct rpc_xprt *xprt, unsigned int max_reqs)
202 } 204 }
203 spin_unlock_bh(&xprt->bc_pa_lock); 205 spin_unlock_bh(&xprt->bc_pa_lock);
204 206
207out:
205 dprintk("RPC: backchannel list empty= %s\n", 208 dprintk("RPC: backchannel list empty= %s\n",
206 list_empty(&xprt->bc_pa_list) ? "true" : "false"); 209 list_empty(&xprt->bc_pa_list) ? "true" : "false");
207} 210}
@@ -255,7 +258,7 @@ void xprt_free_bc_request(struct rpc_rqst *req)
255 dprintk("RPC: free backchannel req=%p\n", req); 258 dprintk("RPC: free backchannel req=%p\n", req);
256 259
257 smp_mb__before_clear_bit(); 260 smp_mb__before_clear_bit();
258 BUG_ON(!test_bit(RPC_BC_PA_IN_USE, &req->rq_bc_pa_state)); 261 WARN_ON_ONCE(!test_bit(RPC_BC_PA_IN_USE, &req->rq_bc_pa_state));
259 clear_bit(RPC_BC_PA_IN_USE, &req->rq_bc_pa_state); 262 clear_bit(RPC_BC_PA_IN_USE, &req->rq_bc_pa_state);
260 smp_mb__after_clear_bit(); 263 smp_mb__after_clear_bit();
261 264
diff --git a/net/sunrpc/bc_svc.c b/net/sunrpc/bc_svc.c
index 0b2eb388cbd..15c7a8a1c24 100644
--- a/net/sunrpc/bc_svc.c
+++ b/net/sunrpc/bc_svc.c
@@ -53,7 +53,7 @@ int bc_send(struct rpc_rqst *req)
53 if (IS_ERR(task)) 53 if (IS_ERR(task))
54 ret = PTR_ERR(task); 54 ret = PTR_ERR(task);
55 else { 55 else {
56 BUG_ON(atomic_read(&task->tk_count) != 1); 56 WARN_ON_ONCE(atomic_read(&task->tk_count) != 1);
57 ret = task->tk_status; 57 ret = task->tk_status;
58 rpc_put_task(task); 58 rpc_put_task(task);
59 } 59 }
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index fc2f7aa4dca..9afa4393c21 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -775,11 +775,11 @@ static ssize_t cache_read(struct file *filp, char __user *buf, size_t count,
775 if (rp->q.list.next == &cd->queue) { 775 if (rp->q.list.next == &cd->queue) {
776 spin_unlock(&queue_lock); 776 spin_unlock(&queue_lock);
777 mutex_unlock(&inode->i_mutex); 777 mutex_unlock(&inode->i_mutex);
778 BUG_ON(rp->offset); 778 WARN_ON_ONCE(rp->offset);
779 return 0; 779 return 0;
780 } 780 }
781 rq = container_of(rp->q.list.next, struct cache_request, q.list); 781 rq = container_of(rp->q.list.next, struct cache_request, q.list);
782 BUG_ON(rq->q.reader); 782 WARN_ON_ONCE(rq->q.reader);
783 if (rp->offset == 0) 783 if (rp->offset == 0)
784 rq->readers++; 784 rq->readers++;
785 spin_unlock(&queue_lock); 785 spin_unlock(&queue_lock);
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index cdc7564b451..822f020fa7f 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;
diff --git a/net/sunrpc/rpc_pipe.c b/net/sunrpc/rpc_pipe.c
index 80f5dd23417..fd10981ea79 100644
--- a/net/sunrpc/rpc_pipe.c
+++ b/net/sunrpc/rpc_pipe.c
@@ -1093,7 +1093,7 @@ void rpc_put_sb_net(const struct net *net)
1093{ 1093{
1094 struct sunrpc_net *sn = net_generic(net, sunrpc_net_id); 1094 struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
1095 1095
1096 BUG_ON(sn->pipefs_sb == NULL); 1096 WARN_ON(sn->pipefs_sb == NULL);
1097 mutex_unlock(&sn->pipefs_sb_lock); 1097 mutex_unlock(&sn->pipefs_sb_lock);
1098} 1098}
1099EXPORT_SYMBOL_GPL(rpc_put_sb_net); 1099EXPORT_SYMBOL_GPL(rpc_put_sb_net);
@@ -1152,14 +1152,19 @@ static void rpc_kill_sb(struct super_block *sb)
1152 struct sunrpc_net *sn = net_generic(net, sunrpc_net_id); 1152 struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);
1153 1153
1154 mutex_lock(&sn->pipefs_sb_lock); 1154 mutex_lock(&sn->pipefs_sb_lock);
1155 if (sn->pipefs_sb != sb) {
1156 mutex_unlock(&sn->pipefs_sb_lock);
1157 goto out;
1158 }
1155 sn->pipefs_sb = NULL; 1159 sn->pipefs_sb = NULL;
1156 mutex_unlock(&sn->pipefs_sb_lock); 1160 mutex_unlock(&sn->pipefs_sb_lock);
1157 put_net(net);
1158 dprintk("RPC: sending pipefs UMOUNT notification for net %p%s\n", 1161 dprintk("RPC: sending pipefs UMOUNT notification for net %p%s\n",
1159 net, NET_NAME(net)); 1162 net, NET_NAME(net));
1160 blocking_notifier_call_chain(&rpc_pipefs_notifier_list, 1163 blocking_notifier_call_chain(&rpc_pipefs_notifier_list,
1161 RPC_PIPEFS_UMOUNT, 1164 RPC_PIPEFS_UMOUNT,
1162 sb); 1165 sb);
1166 put_net(net);
1167out:
1163 kill_litter_super(sb); 1168 kill_litter_super(sb);
1164} 1169}
1165 1170
diff --git a/net/sunrpc/rpcb_clnt.c b/net/sunrpc/rpcb_clnt.c
index a70acae496e..411f332de0b 100644
--- a/net/sunrpc/rpcb_clnt.c
+++ b/net/sunrpc/rpcb_clnt.c
@@ -884,7 +884,10 @@ static void encode_rpcb_string(struct xdr_stream *xdr, const char *string,
884 u32 len; 884 u32 len;
885 885
886 len = strlen(string); 886 len = strlen(string);
887 BUG_ON(len > maxstrlen); 887 WARN_ON_ONCE(len > maxstrlen);
888 if (len > maxstrlen)
889 /* truncate and hope for the best */
890 len = maxstrlen;
888 p = xdr_reserve_space(xdr, 4 + len); 891 p = xdr_reserve_space(xdr, 4 + len);
889 xdr_encode_opaque(p, string, len); 892 xdr_encode_opaque(p, string, len);
890} 893}
diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
index 6357fcb00c7..d17a704aaf5 100644
--- a/net/sunrpc/sched.c
+++ b/net/sunrpc/sched.c
@@ -98,6 +98,23 @@ __rpc_add_timer(struct rpc_wait_queue *queue, struct rpc_task *task)
98 list_add(&task->u.tk_wait.timer_list, &queue->timer_list.list); 98 list_add(&task->u.tk_wait.timer_list, &queue->timer_list.list);
99} 99}
100 100
101static void rpc_set_waitqueue_priority(struct rpc_wait_queue *queue, int priority)
102{
103 queue->priority = priority;
104}
105
106static void rpc_set_waitqueue_owner(struct rpc_wait_queue *queue, pid_t pid)
107{
108 queue->owner = pid;
109 queue->nr = RPC_BATCH_COUNT;
110}
111
112static void rpc_reset_waitqueue_priority(struct rpc_wait_queue *queue)
113{
114 rpc_set_waitqueue_priority(queue, queue->maxpriority);
115 rpc_set_waitqueue_owner(queue, 0);
116}
117
101/* 118/*
102 * Add new request to a priority queue. 119 * Add new request to a priority queue.
103 */ 120 */
@@ -109,9 +126,11 @@ static void __rpc_add_wait_queue_priority(struct rpc_wait_queue *queue,
109 struct rpc_task *t; 126 struct rpc_task *t;
110 127
111 INIT_LIST_HEAD(&task->u.tk_wait.links); 128 INIT_LIST_HEAD(&task->u.tk_wait.links);
112 q = &queue->tasks[queue_priority];
113 if (unlikely(queue_priority > queue->maxpriority)) 129 if (unlikely(queue_priority > queue->maxpriority))
114 q = &queue->tasks[queue->maxpriority]; 130 queue_priority = queue->maxpriority;
131 if (queue_priority > queue->priority)
132 rpc_set_waitqueue_priority(queue, queue_priority);
133 q = &queue->tasks[queue_priority];
115 list_for_each_entry(t, q, u.tk_wait.list) { 134 list_for_each_entry(t, q, u.tk_wait.list) {
116 if (t->tk_owner == task->tk_owner) { 135 if (t->tk_owner == task->tk_owner) {
117 list_add_tail(&task->u.tk_wait.list, &t->u.tk_wait.links); 136 list_add_tail(&task->u.tk_wait.list, &t->u.tk_wait.links);
@@ -133,7 +152,9 @@ static void __rpc_add_wait_queue(struct rpc_wait_queue *queue,
133 struct rpc_task *task, 152 struct rpc_task *task,
134 unsigned char queue_priority) 153 unsigned char queue_priority)
135{ 154{
136 BUG_ON (RPC_IS_QUEUED(task)); 155 WARN_ON_ONCE(RPC_IS_QUEUED(task));
156 if (RPC_IS_QUEUED(task))
157 return;
137 158
138 if (RPC_IS_PRIORITY(queue)) 159 if (RPC_IS_PRIORITY(queue))
139 __rpc_add_wait_queue_priority(queue, task, queue_priority); 160 __rpc_add_wait_queue_priority(queue, task, queue_priority);
@@ -178,24 +199,6 @@ static void __rpc_remove_wait_queue(struct rpc_wait_queue *queue, struct rpc_tas
178 task->tk_pid, queue, rpc_qname(queue)); 199 task->tk_pid, queue, rpc_qname(queue));
179} 200}
180 201
181static inline void rpc_set_waitqueue_priority(struct rpc_wait_queue *queue, int priority)
182{
183 queue->priority = priority;
184 queue->count = 1 << (priority * 2);
185}
186
187static inline void rpc_set_waitqueue_owner(struct rpc_wait_queue *queue, pid_t pid)
188{
189 queue->owner = pid;
190 queue->nr = RPC_BATCH_COUNT;
191}
192
193static inline void rpc_reset_waitqueue_priority(struct rpc_wait_queue *queue)
194{
195 rpc_set_waitqueue_priority(queue, queue->maxpriority);
196 rpc_set_waitqueue_owner(queue, 0);
197}
198
199static void __rpc_init_priority_wait_queue(struct rpc_wait_queue *queue, const char *qname, unsigned char nr_queues) 202static void __rpc_init_priority_wait_queue(struct rpc_wait_queue *queue, const char *qname, unsigned char nr_queues)
200{ 203{
201 int i; 204 int i;
@@ -334,7 +337,7 @@ static void __rpc_sleep_on_priority(struct rpc_wait_queue *q,
334 337
335 __rpc_add_wait_queue(q, task, queue_priority); 338 __rpc_add_wait_queue(q, task, queue_priority);
336 339
337 BUG_ON(task->tk_callback != NULL); 340 WARN_ON_ONCE(task->tk_callback != NULL);
338 task->tk_callback = action; 341 task->tk_callback = action;
339 __rpc_add_timer(q, task); 342 __rpc_add_timer(q, task);
340} 343}
@@ -343,7 +346,12 @@ void rpc_sleep_on(struct rpc_wait_queue *q, struct rpc_task *task,
343 rpc_action action) 346 rpc_action action)
344{ 347{
345 /* We shouldn't ever put an inactive task to sleep */ 348 /* We shouldn't ever put an inactive task to sleep */
346 BUG_ON(!RPC_IS_ACTIVATED(task)); 349 WARN_ON_ONCE(!RPC_IS_ACTIVATED(task));
350 if (!RPC_IS_ACTIVATED(task)) {
351 task->tk_status = -EIO;
352 rpc_put_task_async(task);
353 return;
354 }
347 355
348 /* 356 /*
349 * Protect the queue operations. 357 * Protect the queue operations.
@@ -358,7 +366,12 @@ void rpc_sleep_on_priority(struct rpc_wait_queue *q, struct rpc_task *task,
358 rpc_action action, int priority) 366 rpc_action action, int priority)
359{ 367{
360 /* We shouldn't ever put an inactive task to sleep */ 368 /* We shouldn't ever put an inactive task to sleep */
361 BUG_ON(!RPC_IS_ACTIVATED(task)); 369 WARN_ON_ONCE(!RPC_IS_ACTIVATED(task));
370 if (!RPC_IS_ACTIVATED(task)) {
371 task->tk_status = -EIO;
372 rpc_put_task_async(task);
373 return;
374 }
362 375
363 /* 376 /*
364 * Protect the queue operations. 377 * Protect the queue operations.
@@ -367,6 +380,7 @@ void rpc_sleep_on_priority(struct rpc_wait_queue *q, struct rpc_task *task,
367 __rpc_sleep_on_priority(q, task, action, priority - RPC_PRIORITY_LOW); 380 __rpc_sleep_on_priority(q, task, action, priority - RPC_PRIORITY_LOW);
368 spin_unlock_bh(&q->lock); 381 spin_unlock_bh(&q->lock);
369} 382}
383EXPORT_SYMBOL_GPL(rpc_sleep_on_priority);
370 384
371/** 385/**
372 * __rpc_do_wake_up_task - wake up a single rpc_task 386 * __rpc_do_wake_up_task - wake up a single rpc_task
@@ -451,8 +465,7 @@ static struct rpc_task *__rpc_find_next_queued_priority(struct rpc_wait_queue *q
451 /* 465 /*
452 * Check if we need to switch queues. 466 * Check if we need to switch queues.
453 */ 467 */
454 if (--queue->count) 468 goto new_owner;
455 goto new_owner;
456 } 469 }
457 470
458 /* 471 /*
@@ -697,7 +710,9 @@ static void __rpc_execute(struct rpc_task *task)
697 dprintk("RPC: %5u __rpc_execute flags=0x%x\n", 710 dprintk("RPC: %5u __rpc_execute flags=0x%x\n",
698 task->tk_pid, task->tk_flags); 711 task->tk_pid, task->tk_flags);
699 712
700 BUG_ON(RPC_IS_QUEUED(task)); 713 WARN_ON_ONCE(RPC_IS_QUEUED(task));
714 if (RPC_IS_QUEUED(task))
715 return;
701 716
702 for (;;) { 717 for (;;) {
703 void (*do_action)(struct rpc_task *); 718 void (*do_action)(struct rpc_task *);
@@ -981,7 +996,7 @@ static void rpc_release_task(struct rpc_task *task)
981{ 996{
982 dprintk("RPC: %5u release task\n", task->tk_pid); 997 dprintk("RPC: %5u release task\n", task->tk_pid);
983 998
984 BUG_ON (RPC_IS_QUEUED(task)); 999 WARN_ON_ONCE(RPC_IS_QUEUED(task));
985 1000
986 rpc_release_resources_task(task); 1001 rpc_release_resources_task(task);
987 1002
diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
index 3ee7461926d..dfa4ba69ff4 100644
--- a/net/sunrpc/svc.c
+++ b/net/sunrpc/svc.c
@@ -324,7 +324,9 @@ svc_pool_map_set_cpumask(struct task_struct *task, unsigned int pidx)
324 * The caller checks for sv_nrpools > 1, which 324 * The caller checks for sv_nrpools > 1, which
325 * implies that we've been initialized. 325 * implies that we've been initialized.
326 */ 326 */
327 BUG_ON(m->count == 0); 327 WARN_ON_ONCE(m->count == 0);
328 if (m->count == 0)
329 return;
328 330
329 switch (m->mode) { 331 switch (m->mode) {
330 case SVC_POOL_PERCPU: 332 case SVC_POOL_PERCPU:
@@ -585,7 +587,9 @@ svc_init_buffer(struct svc_rqst *rqstp, unsigned int size, int node)
585 * We assume one is at most one page 587 * We assume one is at most one page
586 */ 588 */
587 arghi = 0; 589 arghi = 0;
588 BUG_ON(pages > RPCSVC_MAXPAGES); 590 WARN_ON_ONCE(pages > RPCSVC_MAXPAGES);
591 if (pages > RPCSVC_MAXPAGES)
592 pages = RPCSVC_MAXPAGES;
589 while (pages) { 593 while (pages) {
590 struct page *p = alloc_pages_node(node, GFP_KERNEL, 0); 594 struct page *p = alloc_pages_node(node, GFP_KERNEL, 0);
591 if (!p) 595 if (!p)
@@ -946,7 +950,9 @@ int svc_register(const struct svc_serv *serv, struct net *net,
946 unsigned int i; 950 unsigned int i;
947 int error = 0; 951 int error = 0;
948 952
949 BUG_ON(proto == 0 && port == 0); 953 WARN_ON_ONCE(proto == 0 && port == 0);
954 if (proto == 0 && port == 0)
955 return -EINVAL;
950 956
951 for (progp = serv->sv_program; progp; progp = progp->pg_next) { 957 for (progp = serv->sv_program; progp; progp = progp->pg_next) {
952 for (i = 0; i < progp->pg_nvers; i++) { 958 for (i = 0; i < progp->pg_nvers; i++) {
diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c
index 194d865fae7..b8e47fac731 100644
--- a/net/sunrpc/svc_xprt.c
+++ b/net/sunrpc/svc_xprt.c
@@ -218,7 +218,9 @@ static struct svc_xprt *__svc_xpo_create(struct svc_xprt_class *xcl,
218 */ 218 */
219static void svc_xprt_received(struct svc_xprt *xprt) 219static void svc_xprt_received(struct svc_xprt *xprt)
220{ 220{
221 BUG_ON(!test_bit(XPT_BUSY, &xprt->xpt_flags)); 221 WARN_ON_ONCE(!test_bit(XPT_BUSY, &xprt->xpt_flags));
222 if (!test_bit(XPT_BUSY, &xprt->xpt_flags))
223 return;
222 /* As soon as we clear busy, the xprt could be closed and 224 /* As soon as we clear busy, the xprt could be closed and
223 * 'put', so we need a reference to call svc_xprt_enqueue with: 225 * 'put', so we need a reference to call svc_xprt_enqueue with:
224 */ 226 */
@@ -577,7 +579,10 @@ int svc_alloc_arg(struct svc_rqst *rqstp)
577 579
578 /* now allocate needed pages. If we get a failure, sleep briefly */ 580 /* now allocate needed pages. If we get a failure, sleep briefly */
579 pages = (serv->sv_max_mesg + PAGE_SIZE) / PAGE_SIZE; 581 pages = (serv->sv_max_mesg + PAGE_SIZE) / PAGE_SIZE;
580 BUG_ON(pages >= RPCSVC_MAXPAGES); 582 WARN_ON_ONCE(pages >= RPCSVC_MAXPAGES);
583 if (pages >= RPCSVC_MAXPAGES)
584 /* use as many pages as possible */
585 pages = RPCSVC_MAXPAGES - 1;
581 for (i = 0; i < pages ; i++) 586 for (i = 0; i < pages ; i++)
582 while (rqstp->rq_pages[i] == NULL) { 587 while (rqstp->rq_pages[i] == NULL) {
583 struct page *p = alloc_page(GFP_KERNEL); 588 struct page *p = alloc_page(GFP_KERNEL);
@@ -926,7 +931,7 @@ static void svc_delete_xprt(struct svc_xprt *xprt)
926 spin_lock_bh(&serv->sv_lock); 931 spin_lock_bh(&serv->sv_lock);
927 if (!test_and_set_bit(XPT_DETACHED, &xprt->xpt_flags)) 932 if (!test_and_set_bit(XPT_DETACHED, &xprt->xpt_flags))
928 list_del_init(&xprt->xpt_list); 933 list_del_init(&xprt->xpt_list);
929 BUG_ON(!list_empty(&xprt->xpt_ready)); 934 WARN_ON_ONCE(!list_empty(&xprt->xpt_ready));
930 if (test_bit(XPT_TEMP, &xprt->xpt_flags)) 935 if (test_bit(XPT_TEMP, &xprt->xpt_flags))
931 serv->sv_tmpcnt--; 936 serv->sv_tmpcnt--;
932 spin_unlock_bh(&serv->sv_lock); 937 spin_unlock_bh(&serv->sv_lock);
diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 03827cef1fa..cc3020d1678 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -84,7 +84,11 @@ static struct lock_class_key svc_slock_key[2];
84static void svc_reclassify_socket(struct socket *sock) 84static void svc_reclassify_socket(struct socket *sock)
85{ 85{
86 struct sock *sk = sock->sk; 86 struct sock *sk = sock->sk;
87 BUG_ON(sock_owned_by_user(sk)); 87
88 WARN_ON_ONCE(sock_owned_by_user(sk));
89 if (sock_owned_by_user(sk))
90 return;
91
88 switch (sk->sk_family) { 92 switch (sk->sk_family) {
89 case AF_INET: 93 case AF_INET:
90 sock_lock_init_class_and_name(sk, "slock-AF_INET-NFSD", 94 sock_lock_init_class_and_name(sk, "slock-AF_INET-NFSD",
diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
index 08f50afd5f2..56055632f15 100644
--- a/net/sunrpc/xdr.c
+++ b/net/sunrpc/xdr.c
@@ -318,7 +318,10 @@ xdr_shrink_bufhead(struct xdr_buf *buf, size_t len)
318 318
319 tail = buf->tail; 319 tail = buf->tail;
320 head = buf->head; 320 head = buf->head;
321 BUG_ON (len > head->iov_len); 321
322 WARN_ON_ONCE(len > head->iov_len);
323 if (len > head->iov_len)
324 len = head->iov_len;
322 325
323 /* Shift the tail first */ 326 /* Shift the tail first */
324 if (tail->iov_len != 0) { 327 if (tail->iov_len != 0) {
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 75853cabf4c..68b0a81c31d 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -1746,7 +1746,6 @@ static inline void xs_reclassify_socketu(struct socket *sock)
1746{ 1746{
1747 struct sock *sk = sock->sk; 1747 struct sock *sk = sock->sk;
1748 1748
1749 BUG_ON(sock_owned_by_user(sk));
1750 sock_lock_init_class_and_name(sk, "slock-AF_LOCAL-RPC", 1749 sock_lock_init_class_and_name(sk, "slock-AF_LOCAL-RPC",
1751 &xs_slock_key[1], "sk_lock-AF_LOCAL-RPC", &xs_key[1]); 1750 &xs_slock_key[1], "sk_lock-AF_LOCAL-RPC", &xs_key[1]);
1752} 1751}
@@ -1755,7 +1754,6 @@ static inline void xs_reclassify_socket4(struct socket *sock)
1755{ 1754{
1756 struct sock *sk = sock->sk; 1755 struct sock *sk = sock->sk;
1757 1756
1758 BUG_ON(sock_owned_by_user(sk));
1759 sock_lock_init_class_and_name(sk, "slock-AF_INET-RPC", 1757 sock_lock_init_class_and_name(sk, "slock-AF_INET-RPC",
1760 &xs_slock_key[0], "sk_lock-AF_INET-RPC", &xs_key[0]); 1758 &xs_slock_key[0], "sk_lock-AF_INET-RPC", &xs_key[0]);
1761} 1759}
@@ -1764,13 +1762,16 @@ static inline void xs_reclassify_socket6(struct socket *sock)
1764{ 1762{
1765 struct sock *sk = sock->sk; 1763 struct sock *sk = sock->sk;
1766 1764
1767 BUG_ON(sock_owned_by_user(sk));
1768 sock_lock_init_class_and_name(sk, "slock-AF_INET6-RPC", 1765 sock_lock_init_class_and_name(sk, "slock-AF_INET6-RPC",
1769 &xs_slock_key[1], "sk_lock-AF_INET6-RPC", &xs_key[1]); 1766 &xs_slock_key[1], "sk_lock-AF_INET6-RPC", &xs_key[1]);
1770} 1767}
1771 1768
1772static inline void xs_reclassify_socket(int family, struct socket *sock) 1769static inline void xs_reclassify_socket(int family, struct socket *sock)
1773{ 1770{
1771 WARN_ON_ONCE(sock_owned_by_user(sock->sk));
1772 if (sock_owned_by_user(sock->sk))
1773 return;
1774
1774 switch (family) { 1775 switch (family) {
1775 case AF_LOCAL: 1776 case AF_LOCAL:
1776 xs_reclassify_socketu(sock); 1777 xs_reclassify_socketu(sock);
@@ -1901,6 +1902,10 @@ static void xs_local_setup_socket(struct work_struct *work)
1901 dprintk("RPC: xprt %p: socket %s does not exist\n", 1902 dprintk("RPC: xprt %p: socket %s does not exist\n",
1902 xprt, xprt->address_strings[RPC_DISPLAY_ADDR]); 1903 xprt, xprt->address_strings[RPC_DISPLAY_ADDR]);
1903 break; 1904 break;
1905 case -ECONNREFUSED:
1906 dprintk("RPC: xprt %p: connection refused for %s\n",
1907 xprt, xprt->address_strings[RPC_DISPLAY_ADDR]);
1908 break;
1904 default: 1909 default:
1905 printk(KERN_ERR "%s: unhandled error (%d) connecting to %s\n", 1910 printk(KERN_ERR "%s: unhandled error (%d) connecting to %s\n",
1906 __func__, -status, 1911 __func__, -status,
@@ -2329,9 +2334,11 @@ static void *bc_malloc(struct rpc_task *task, size_t size)
2329 struct page *page; 2334 struct page *page;
2330 struct rpc_buffer *buf; 2335 struct rpc_buffer *buf;
2331 2336
2332 BUG_ON(size > PAGE_SIZE - sizeof(struct rpc_buffer)); 2337 WARN_ON_ONCE(size > PAGE_SIZE - sizeof(struct rpc_buffer));
2333 page = alloc_page(GFP_KERNEL); 2338 if (size > PAGE_SIZE - sizeof(struct rpc_buffer))
2339 return NULL;
2334 2340
2341 page = alloc_page(GFP_KERNEL);
2335 if (!page) 2342 if (!page)
2336 return NULL; 2343 return NULL;
2337 2344
@@ -2393,7 +2400,6 @@ static int bc_send_request(struct rpc_task *task)
2393{ 2400{
2394 struct rpc_rqst *req = task->tk_rqstp; 2401 struct rpc_rqst *req = task->tk_rqstp;
2395 struct svc_xprt *xprt; 2402 struct svc_xprt *xprt;
2396 struct svc_sock *svsk;
2397 u32 len; 2403 u32 len;
2398 2404
2399 dprintk("sending request with xid: %08x\n", ntohl(req->rq_xid)); 2405 dprintk("sending request with xid: %08x\n", ntohl(req->rq_xid));
@@ -2401,7 +2407,6 @@ static int bc_send_request(struct rpc_task *task)
2401 * Get the server socket associated with this callback xprt 2407 * Get the server socket associated with this callback xprt
2402 */ 2408 */
2403 xprt = req->rq_xprt->bc_xprt; 2409 xprt = req->rq_xprt->bc_xprt;
2404 svsk = container_of(xprt, struct svc_sock, sk_xprt);
2405 2410
2406 /* 2411 /*
2407 * Grab the mutex to serialize data as the connection is shared 2412 * Grab the mutex to serialize data as the connection is shared