Commit 70d79ae6 authored by J. Bruce Fields's avatar J. Bruce Fields Committed by Willy Tarreau

svcrpc: fix svc_xprt_enqueue/svc_recv busy-looping

commit d10f27a7 upstream.

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.
Reported-by: default avatarMichael Tokarev <mjt@tls.msk.ru>
Tested-by: default avatarMichael Tokarev <mjt@tls.msk.ru>
Signed-off-by: default avatarJ. Bruce Fields <bfields@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarWilly Tarreau <w@1wt.eu>
parent 14f4f45a
...@@ -304,7 +304,6 @@ static void svc_thread_dequeue(struct svc_pool *pool, struct svc_rqst *rqstp) ...@@ -304,7 +304,6 @@ static void svc_thread_dequeue(struct svc_pool *pool, struct svc_rqst *rqstp)
*/ */
void svc_xprt_enqueue(struct svc_xprt *xprt) void svc_xprt_enqueue(struct svc_xprt *xprt)
{ {
struct svc_serv *serv = xprt->xpt_server;
struct svc_pool *pool; struct svc_pool *pool;
struct svc_rqst *rqstp; struct svc_rqst *rqstp;
int cpu; int cpu;
...@@ -381,8 +380,6 @@ void svc_xprt_enqueue(struct svc_xprt *xprt) ...@@ -381,8 +380,6 @@ void svc_xprt_enqueue(struct svc_xprt *xprt)
rqstp, rqstp->rq_xprt); rqstp, rqstp->rq_xprt);
rqstp->rq_xprt = xprt; rqstp->rq_xprt = xprt;
svc_xprt_get(xprt); svc_xprt_get(xprt);
rqstp->rq_reserved = serv->sv_max_mesg;
atomic_add(rqstp->rq_reserved, &xprt->xpt_reserved);
rqstp->rq_waking = 1; rqstp->rq_waking = 1;
pool->sp_nwaking++; pool->sp_nwaking++;
pool->sp_stats.threads_woken++; pool->sp_stats.threads_woken++;
...@@ -667,8 +664,6 @@ int svc_recv(struct svc_rqst *rqstp, long timeout) ...@@ -667,8 +664,6 @@ int svc_recv(struct svc_rqst *rqstp, long timeout)
if (xprt) { if (xprt) {
rqstp->rq_xprt = xprt; rqstp->rq_xprt = xprt;
svc_xprt_get(xprt); svc_xprt_get(xprt);
rqstp->rq_reserved = serv->sv_max_mesg;
atomic_add(rqstp->rq_reserved, &xprt->xpt_reserved);
} else { } else {
/* No data pending. Go to sleep */ /* No data pending. Go to sleep */
svc_thread_enqueue(pool, rqstp); svc_thread_enqueue(pool, rqstp);
...@@ -758,6 +753,8 @@ int svc_recv(struct svc_rqst *rqstp, long timeout) ...@@ -758,6 +753,8 @@ int svc_recv(struct svc_rqst *rqstp, long timeout)
} else } else
len = xprt->xpt_ops->xpo_recvfrom(rqstp); len = xprt->xpt_ops->xpo_recvfrom(rqstp);
dprintk("svc: got len=%d\n", len); dprintk("svc: got len=%d\n", len);
rqstp->rq_reserved = serv->sv_max_mesg;
atomic_add(rqstp->rq_reserved, &xprt->xpt_reserved);
} }
/* No data, incomplete (TCP) read, or accept() */ /* No data, incomplete (TCP) read, or accept() */
......
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