diff options
author | J. Bruce Fields <bfields@redhat.com> | 2012-08-17 17:31:53 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2012-08-20 18:39:19 -0400 |
commit | d10f27a750312ed5638c876e4bd6aa83664cccd8 (patch) | |
tree | 9d6c68a078bc5129080177829d531d2686ea4e2a /net/sunrpc/svc_xprt.c | |
parent | f06f00a24d76e168ecb38d352126fd203937b601 (diff) |
svcrpc: fix svc_xprt_enqueue/svc_recv busy-looping
The rpc server tries to ensure that there will be room to send a reply
before it receives a request.
It does this by tracking, in xpt_reserved, an upper bound on the total
size of the replies that is has already committed to for the socket.
Currently it is adding in the estimate for a new reply *before* it
checks whether there is space available. If it finds that there is not
space, it then subtracts the estimate back out.
This may lead the subsequent svc_xprt_enqueue to decide that there is
space after all.
The results is a svc_recv() that will repeatedly return -EAGAIN, causing
server threads to loop without doing any actual work.
Cc: stable@vger.kernel.org
Reported-by: Michael Tokarev <mjt@tls.msk.ru>
Tested-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'net/sunrpc/svc_xprt.c')
-rw-r--r-- | net/sunrpc/svc_xprt.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c index 0d693a89434f..bac973a31367 100644 --- a/net/sunrpc/svc_xprt.c +++ b/net/sunrpc/svc_xprt.c | |||
@@ -316,7 +316,6 @@ static bool svc_xprt_has_something_to_do(struct svc_xprt *xprt) | |||
316 | */ | 316 | */ |
317 | void svc_xprt_enqueue(struct svc_xprt *xprt) | 317 | void svc_xprt_enqueue(struct svc_xprt *xprt) |
318 | { | 318 | { |
319 | struct svc_serv *serv = xprt->xpt_server; | ||
320 | struct svc_pool *pool; | 319 | struct svc_pool *pool; |
321 | struct svc_rqst *rqstp; | 320 | struct svc_rqst *rqstp; |
322 | int cpu; | 321 | int cpu; |
@@ -362,8 +361,6 @@ void svc_xprt_enqueue(struct svc_xprt *xprt) | |||
362 | rqstp, rqstp->rq_xprt); | 361 | rqstp, rqstp->rq_xprt); |
363 | rqstp->rq_xprt = xprt; | 362 | rqstp->rq_xprt = xprt; |
364 | svc_xprt_get(xprt); | 363 | svc_xprt_get(xprt); |
365 | rqstp->rq_reserved = serv->sv_max_mesg; | ||
366 | atomic_add(rqstp->rq_reserved, &xprt->xpt_reserved); | ||
367 | pool->sp_stats.threads_woken++; | 364 | pool->sp_stats.threads_woken++; |
368 | wake_up(&rqstp->rq_wait); | 365 | wake_up(&rqstp->rq_wait); |
369 | } else { | 366 | } else { |
@@ -640,8 +637,6 @@ int svc_recv(struct svc_rqst *rqstp, long timeout) | |||
640 | if (xprt) { | 637 | if (xprt) { |
641 | rqstp->rq_xprt = xprt; | 638 | rqstp->rq_xprt = xprt; |
642 | svc_xprt_get(xprt); | 639 | svc_xprt_get(xprt); |
643 | rqstp->rq_reserved = serv->sv_max_mesg; | ||
644 | atomic_add(rqstp->rq_reserved, &xprt->xpt_reserved); | ||
645 | 640 | ||
646 | /* As there is a shortage of threads and this request | 641 | /* As there is a shortage of threads and this request |
647 | * had to be queued, don't allow the thread to wait so | 642 | * had to be queued, don't allow the thread to wait so |
@@ -738,6 +733,8 @@ int svc_recv(struct svc_rqst *rqstp, long timeout) | |||
738 | else | 733 | else |
739 | len = xprt->xpt_ops->xpo_recvfrom(rqstp); | 734 | len = xprt->xpt_ops->xpo_recvfrom(rqstp); |
740 | dprintk("svc: got len=%d\n", len); | 735 | dprintk("svc: got len=%d\n", len); |
736 | rqstp->rq_reserved = serv->sv_max_mesg; | ||
737 | atomic_add(rqstp->rq_reserved, &xprt->xpt_reserved); | ||
741 | } | 738 | } |
742 | svc_xprt_received(xprt); | 739 | svc_xprt_received(xprt); |
743 | 740 | ||