svcrpc: fix svc_xprt_enqueue/svc_recv busy-looping
authorJ. Bruce Fields <bfields@redhat.com>
Fri, 17 Aug 2012 21:31:53 +0000 (17:31 -0400)
committerBen Hutchings <ben@decadent.org.uk>
Wed, 12 Sep 2012 02:37:23 +0000 (03:37 +0100)
commit9d16d84d61a215bfce9a342cb4eb7347dae3e4c3
tree45eaa3c46b97ca4962e422bf0d98aef5db5d4a1f
parent1057f77016b40d967d8527349ebb881311017df7
svcrpc: fix svc_xprt_enqueue/svc_recv busy-looping

commit d10f27a750312ed5638c876e4bd6aa83664cccd8 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: Michael Tokarev <mjt@tls.msk.ru>
Tested-by: Michael Tokarev <mjt@tls.msk.ru>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
net/sunrpc/svc_xprt.c