diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-06 16:25:56 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-06 16:25:56 -0400 |
commit | a63856252d2112e7c452696037a86ceb12f47f80 (patch) | |
tree | b1ad03fe441349069f80e58de425b3f72af9e5b7 /net/sunrpc/svc_xprt.c | |
parent | b24241a09208874d5d770bee30791daae41ad762 (diff) | |
parent | 04826f43d4f0a4d56423eb8abb9f2ec9987df5b5 (diff) |
Merge branch 'for-2.6.30' of git://linux-nfs.org/~bfields/linux
* 'for-2.6.30' of git://linux-nfs.org/~bfields/linux: (81 commits)
nfsd41: define nfsd4_set_statp as noop for !CONFIG_NFSD_V4
nfsd41: define NFSD_DRC_SIZE_SHIFT in set_max_drc
nfsd41: Documentation/filesystems/nfs41-server.txt
nfsd41: CREATE_EXCLUSIVE4_1
nfsd41: SUPPATTR_EXCLCREAT attribute
nfsd41: support for 3-word long attribute bitmask
nfsd: dynamically skip encoded fattr bitmap in _nfsd4_verify
nfsd41: pass writable attrs mask to nfsd4_decode_fattr
nfsd41: provide support for minor version 1 at rpc level
nfsd41: control nfsv4.1 svc via /proc/fs/nfsd/versions
nfsd41: add OPEN4_SHARE_ACCESS_WANT nfs4_stateid bmap
nfsd41: access_valid
nfsd41: clientid handling
nfsd41: check encode size for sessions maxresponse cached
nfsd41: stateid handling
nfsd: pass nfsd4_compound_state* to nfs4_preprocess_{state,seq}id_op
nfsd41: destroy_session operation
nfsd41: non-page DRC for solo sequence responses
nfsd41: Add a create session replay cache
nfsd41: create_session operation
...
Diffstat (limited to 'net/sunrpc/svc_xprt.c')
-rw-r--r-- | net/sunrpc/svc_xprt.c | 127 |
1 files changed, 118 insertions, 9 deletions
diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c index 2819ee093f36..c200d92e57e4 100644 --- a/net/sunrpc/svc_xprt.c +++ b/net/sunrpc/svc_xprt.c | |||
@@ -14,6 +14,8 @@ | |||
14 | 14 | ||
15 | #define RPCDBG_FACILITY RPCDBG_SVCXPRT | 15 | #define RPCDBG_FACILITY RPCDBG_SVCXPRT |
16 | 16 | ||
17 | #define SVC_MAX_WAKING 5 | ||
18 | |||
17 | static struct svc_deferred_req *svc_deferred_dequeue(struct svc_xprt *xprt); | 19 | static struct svc_deferred_req *svc_deferred_dequeue(struct svc_xprt *xprt); |
18 | static int svc_deferred_recv(struct svc_rqst *rqstp); | 20 | static int svc_deferred_recv(struct svc_rqst *rqstp); |
19 | static struct cache_deferred_req *svc_defer(struct cache_req *req); | 21 | static struct cache_deferred_req *svc_defer(struct cache_req *req); |
@@ -301,6 +303,7 @@ void svc_xprt_enqueue(struct svc_xprt *xprt) | |||
301 | struct svc_pool *pool; | 303 | struct svc_pool *pool; |
302 | struct svc_rqst *rqstp; | 304 | struct svc_rqst *rqstp; |
303 | int cpu; | 305 | int cpu; |
306 | int thread_avail; | ||
304 | 307 | ||
305 | if (!(xprt->xpt_flags & | 308 | if (!(xprt->xpt_flags & |
306 | ((1<<XPT_CONN)|(1<<XPT_DATA)|(1<<XPT_CLOSE)|(1<<XPT_DEFERRED)))) | 309 | ((1<<XPT_CONN)|(1<<XPT_DATA)|(1<<XPT_CLOSE)|(1<<XPT_DEFERRED)))) |
@@ -312,18 +315,14 @@ void svc_xprt_enqueue(struct svc_xprt *xprt) | |||
312 | 315 | ||
313 | spin_lock_bh(&pool->sp_lock); | 316 | spin_lock_bh(&pool->sp_lock); |
314 | 317 | ||
315 | if (!list_empty(&pool->sp_threads) && | ||
316 | !list_empty(&pool->sp_sockets)) | ||
317 | printk(KERN_ERR | ||
318 | "svc_xprt_enqueue: " | ||
319 | "threads and transports both waiting??\n"); | ||
320 | |||
321 | if (test_bit(XPT_DEAD, &xprt->xpt_flags)) { | 318 | if (test_bit(XPT_DEAD, &xprt->xpt_flags)) { |
322 | /* Don't enqueue dead transports */ | 319 | /* Don't enqueue dead transports */ |
323 | dprintk("svc: transport %p is dead, not enqueued\n", xprt); | 320 | dprintk("svc: transport %p is dead, not enqueued\n", xprt); |
324 | goto out_unlock; | 321 | goto out_unlock; |
325 | } | 322 | } |
326 | 323 | ||
324 | pool->sp_stats.packets++; | ||
325 | |||
327 | /* Mark transport as busy. It will remain in this state until | 326 | /* Mark transport as busy. It will remain in this state until |
328 | * the provider calls svc_xprt_received. We update XPT_BUSY | 327 | * the provider calls svc_xprt_received. We update XPT_BUSY |
329 | * atomically because it also guards against trying to enqueue | 328 | * atomically because it also guards against trying to enqueue |
@@ -356,7 +355,15 @@ void svc_xprt_enqueue(struct svc_xprt *xprt) | |||
356 | } | 355 | } |
357 | 356 | ||
358 | process: | 357 | process: |
359 | if (!list_empty(&pool->sp_threads)) { | 358 | /* Work out whether threads are available */ |
359 | thread_avail = !list_empty(&pool->sp_threads); /* threads are asleep */ | ||
360 | if (pool->sp_nwaking >= SVC_MAX_WAKING) { | ||
361 | /* too many threads are runnable and trying to wake up */ | ||
362 | thread_avail = 0; | ||
363 | pool->sp_stats.overloads_avoided++; | ||
364 | } | ||
365 | |||
366 | if (thread_avail) { | ||
360 | rqstp = list_entry(pool->sp_threads.next, | 367 | rqstp = list_entry(pool->sp_threads.next, |
361 | struct svc_rqst, | 368 | struct svc_rqst, |
362 | rq_list); | 369 | rq_list); |
@@ -371,11 +378,15 @@ void svc_xprt_enqueue(struct svc_xprt *xprt) | |||
371 | svc_xprt_get(xprt); | 378 | svc_xprt_get(xprt); |
372 | rqstp->rq_reserved = serv->sv_max_mesg; | 379 | rqstp->rq_reserved = serv->sv_max_mesg; |
373 | atomic_add(rqstp->rq_reserved, &xprt->xpt_reserved); | 380 | atomic_add(rqstp->rq_reserved, &xprt->xpt_reserved); |
381 | rqstp->rq_waking = 1; | ||
382 | pool->sp_nwaking++; | ||
383 | pool->sp_stats.threads_woken++; | ||
374 | BUG_ON(xprt->xpt_pool != pool); | 384 | BUG_ON(xprt->xpt_pool != pool); |
375 | wake_up(&rqstp->rq_wait); | 385 | wake_up(&rqstp->rq_wait); |
376 | } else { | 386 | } else { |
377 | dprintk("svc: transport %p put into queue\n", xprt); | 387 | dprintk("svc: transport %p put into queue\n", xprt); |
378 | list_add_tail(&xprt->xpt_ready, &pool->sp_sockets); | 388 | list_add_tail(&xprt->xpt_ready, &pool->sp_sockets); |
389 | pool->sp_stats.sockets_queued++; | ||
379 | BUG_ON(xprt->xpt_pool != pool); | 390 | BUG_ON(xprt->xpt_pool != pool); |
380 | } | 391 | } |
381 | 392 | ||
@@ -588,6 +599,7 @@ int svc_recv(struct svc_rqst *rqstp, long timeout) | |||
588 | int pages; | 599 | int pages; |
589 | struct xdr_buf *arg; | 600 | struct xdr_buf *arg; |
590 | DECLARE_WAITQUEUE(wait, current); | 601 | DECLARE_WAITQUEUE(wait, current); |
602 | long time_left; | ||
591 | 603 | ||
592 | dprintk("svc: server %p waiting for data (to = %ld)\n", | 604 | dprintk("svc: server %p waiting for data (to = %ld)\n", |
593 | rqstp, timeout); | 605 | rqstp, timeout); |
@@ -636,6 +648,11 @@ int svc_recv(struct svc_rqst *rqstp, long timeout) | |||
636 | return -EINTR; | 648 | return -EINTR; |
637 | 649 | ||
638 | spin_lock_bh(&pool->sp_lock); | 650 | spin_lock_bh(&pool->sp_lock); |
651 | if (rqstp->rq_waking) { | ||
652 | rqstp->rq_waking = 0; | ||
653 | pool->sp_nwaking--; | ||
654 | BUG_ON(pool->sp_nwaking < 0); | ||
655 | } | ||
639 | xprt = svc_xprt_dequeue(pool); | 656 | xprt = svc_xprt_dequeue(pool); |
640 | if (xprt) { | 657 | if (xprt) { |
641 | rqstp->rq_xprt = xprt; | 658 | rqstp->rq_xprt = xprt; |
@@ -668,12 +685,14 @@ int svc_recv(struct svc_rqst *rqstp, long timeout) | |||
668 | add_wait_queue(&rqstp->rq_wait, &wait); | 685 | add_wait_queue(&rqstp->rq_wait, &wait); |
669 | spin_unlock_bh(&pool->sp_lock); | 686 | spin_unlock_bh(&pool->sp_lock); |
670 | 687 | ||
671 | schedule_timeout(timeout); | 688 | time_left = schedule_timeout(timeout); |
672 | 689 | ||
673 | try_to_freeze(); | 690 | try_to_freeze(); |
674 | 691 | ||
675 | spin_lock_bh(&pool->sp_lock); | 692 | spin_lock_bh(&pool->sp_lock); |
676 | remove_wait_queue(&rqstp->rq_wait, &wait); | 693 | remove_wait_queue(&rqstp->rq_wait, &wait); |
694 | if (!time_left) | ||
695 | pool->sp_stats.threads_timedout++; | ||
677 | 696 | ||
678 | xprt = rqstp->rq_xprt; | 697 | xprt = rqstp->rq_xprt; |
679 | if (!xprt) { | 698 | if (!xprt) { |
@@ -958,7 +977,7 @@ static struct cache_deferred_req *svc_defer(struct cache_req *req) | |||
958 | struct svc_rqst *rqstp = container_of(req, struct svc_rqst, rq_chandle); | 977 | struct svc_rqst *rqstp = container_of(req, struct svc_rqst, rq_chandle); |
959 | struct svc_deferred_req *dr; | 978 | struct svc_deferred_req *dr; |
960 | 979 | ||
961 | if (rqstp->rq_arg.page_len) | 980 | if (rqstp->rq_arg.page_len || !rqstp->rq_usedeferral) |
962 | return NULL; /* if more than a page, give up FIXME */ | 981 | return NULL; /* if more than a page, give up FIXME */ |
963 | if (rqstp->rq_deferred) { | 982 | if (rqstp->rq_deferred) { |
964 | dr = rqstp->rq_deferred; | 983 | dr = rqstp->rq_deferred; |
@@ -1112,3 +1131,93 @@ int svc_xprt_names(struct svc_serv *serv, char *buf, int buflen) | |||
1112 | return totlen; | 1131 | return totlen; |
1113 | } | 1132 | } |
1114 | EXPORT_SYMBOL_GPL(svc_xprt_names); | 1133 | EXPORT_SYMBOL_GPL(svc_xprt_names); |
1134 | |||
1135 | |||
1136 | /*----------------------------------------------------------------------------*/ | ||
1137 | |||
1138 | static void *svc_pool_stats_start(struct seq_file *m, loff_t *pos) | ||
1139 | { | ||
1140 | unsigned int pidx = (unsigned int)*pos; | ||
1141 | struct svc_serv *serv = m->private; | ||
1142 | |||
1143 | dprintk("svc_pool_stats_start, *pidx=%u\n", pidx); | ||
1144 | |||
1145 | lock_kernel(); | ||
1146 | /* bump up the pseudo refcount while traversing */ | ||
1147 | svc_get(serv); | ||
1148 | unlock_kernel(); | ||
1149 | |||
1150 | if (!pidx) | ||
1151 | return SEQ_START_TOKEN; | ||
1152 | return (pidx > serv->sv_nrpools ? NULL : &serv->sv_pools[pidx-1]); | ||
1153 | } | ||
1154 | |||
1155 | static void *svc_pool_stats_next(struct seq_file *m, void *p, loff_t *pos) | ||
1156 | { | ||
1157 | struct svc_pool *pool = p; | ||
1158 | struct svc_serv *serv = m->private; | ||
1159 | |||
1160 | dprintk("svc_pool_stats_next, *pos=%llu\n", *pos); | ||
1161 | |||
1162 | if (p == SEQ_START_TOKEN) { | ||
1163 | pool = &serv->sv_pools[0]; | ||
1164 | } else { | ||
1165 | unsigned int pidx = (pool - &serv->sv_pools[0]); | ||
1166 | if (pidx < serv->sv_nrpools-1) | ||
1167 | pool = &serv->sv_pools[pidx+1]; | ||
1168 | else | ||
1169 | pool = NULL; | ||
1170 | } | ||
1171 | ++*pos; | ||
1172 | return pool; | ||
1173 | } | ||
1174 | |||
1175 | static void svc_pool_stats_stop(struct seq_file *m, void *p) | ||
1176 | { | ||
1177 | struct svc_serv *serv = m->private; | ||
1178 | |||
1179 | lock_kernel(); | ||
1180 | /* this function really, really should have been called svc_put() */ | ||
1181 | svc_destroy(serv); | ||
1182 | unlock_kernel(); | ||
1183 | } | ||
1184 | |||
1185 | static int svc_pool_stats_show(struct seq_file *m, void *p) | ||
1186 | { | ||
1187 | struct svc_pool *pool = p; | ||
1188 | |||
1189 | if (p == SEQ_START_TOKEN) { | ||
1190 | seq_puts(m, "# pool packets-arrived sockets-enqueued threads-woken overloads-avoided threads-timedout\n"); | ||
1191 | return 0; | ||
1192 | } | ||
1193 | |||
1194 | seq_printf(m, "%u %lu %lu %lu %lu %lu\n", | ||
1195 | pool->sp_id, | ||
1196 | pool->sp_stats.packets, | ||
1197 | pool->sp_stats.sockets_queued, | ||
1198 | pool->sp_stats.threads_woken, | ||
1199 | pool->sp_stats.overloads_avoided, | ||
1200 | pool->sp_stats.threads_timedout); | ||
1201 | |||
1202 | return 0; | ||
1203 | } | ||
1204 | |||
1205 | static const struct seq_operations svc_pool_stats_seq_ops = { | ||
1206 | .start = svc_pool_stats_start, | ||
1207 | .next = svc_pool_stats_next, | ||
1208 | .stop = svc_pool_stats_stop, | ||
1209 | .show = svc_pool_stats_show, | ||
1210 | }; | ||
1211 | |||
1212 | int svc_pool_stats_open(struct svc_serv *serv, struct file *file) | ||
1213 | { | ||
1214 | int err; | ||
1215 | |||
1216 | err = seq_open(file, &svc_pool_stats_seq_ops); | ||
1217 | if (!err) | ||
1218 | ((struct seq_file *) file->private_data)->private = serv; | ||
1219 | return err; | ||
1220 | } | ||
1221 | EXPORT_SYMBOL(svc_pool_stats_open); | ||
1222 | |||
1223 | /*----------------------------------------------------------------------------*/ | ||