kernel-hacking-2024-linux-s.../net/sunrpc
NeilBrown 447383d2ba NFSD/sunrpc: avoid deadlock on TCP connection due to memory pressure.
Since we enabled auto-tuning for sunrpc TCP connections we do not
guarantee that there is enough write-space on each connection to
queue a reply.

If memory pressure causes the window to shrink too small, the request
throttling in sunrpc/svc will not accept any requests so no more requests
will be handled.  Even when pressure decreases the window will not
grow again until data is sent on the connection.
This means we get a deadlock:  no requests will be handled until there
is more space, and no space will be allocated until a request is
handled.

This can be simulated by modifying svc_tcp_has_wspace to inflate the
number of byte required and removing the 'svc_sock_setbufsize' calls
in svc_setup_socket.

I found that multiplying by 16 was enough to make the requirement
exceed the default allocation.  With this modification in place:
   mount -o vers=3,proto=tcp 127.0.0.1:/home /mnt
would block and eventually time out because the nfs server could not
accept any requests.

This patch relaxes the request throttling to always allow at least one
request through per connection.  It does this by checking both
  sk_stream_min_wspace() and xprt->xpt_reserved
are zero.
The first is zero when the TCP transmit queue is empty.
The second is zero when there are no RPC requests being processed.
When both of these are zero the socket is idle and so one more
request can safely be allowed through.

Applying this patch allows the above mount command to succeed cleanly.
Tracing shows that the allocated write buffer space quickly grows and
after a few requests are handled, the extra tests are no longer needed
to permit further requests to be processed.

The main purpose of request throttling is to handle the case when one
client is slow at collecting replies and the send queue gets full of
replies that the client hasn't acknowledged (at the TCP level) yet.
As we only change behaviour when the send queue is empty this main
purpose is still preserved.

Reported-by: Ben Myers <bpm@sgi.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
2013-08-01 08:39:16 -04:00
..
auth_gss Merge branch 'for-3.11' of git://linux-nfs.org/~bfields/linux 2013-07-11 10:17:13 -07:00
xprtrdma Merge branch 'for-3.11' of git://linux-nfs.org/~bfields/linux 2013-07-17 13:43:55 -07:00
addr.c sunrpc: move address copy/cmp/convert routines and prototypes from clnt.h to addr.h 2013-02-05 09:41:14 -05:00
auth.c SUNRPC: Don't recognize RPC_AUTH_MAXFLAVOR 2013-04-04 17:01:00 -04:00
auth_generic.c sunrpc: Convert kuids and kgids to uids and gids for printing 2013-02-13 06:15:19 -08:00
auth_null.c
auth_unix.c sunrpc: Properly encode kuids and kgids in RPC_AUTH_UNIX credentials 2013-02-13 06:15:24 -08:00
backchannel_rqst.c SUNRPC: remove two BUG_ON asserts 2012-11-04 14:43:41 -05:00
bc_svc.c SUNRPC: remove BUG_ON from bc_send 2012-11-04 14:43:41 -05:00
cache.c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2013-07-14 11:42:26 -07:00
clnt.c SUNRPC: Fix another issue with rpc_client_register() 2013-07-15 10:15:54 -04:00
Kconfig Merge branch 'rpcsec_gss-from_cel' into linux-next 2013-04-23 15:40:40 -04:00
Makefile
netns.h SUNRPC: Convert auth_gss pipe detection to work in namespaces 2013-05-16 06:17:54 -07:00
rpc_pipe.c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2013-07-14 11:42:26 -07:00
rpcb_clnt.c sunrpc: move address copy/cmp/convert routines and prototypes from clnt.h to addr.h 2013-02-05 09:41:14 -05:00
sched.c NFS client updates for Linux 3.11 2013-07-09 12:09:43 -07:00
socklib.c
stats.c procfs: new helper - PDE_DATA(inode) 2013-04-09 14:13:32 -04:00
sunrpc.h
sunrpc_syms.c
svc.c drivers: avoid parsing names as kthread_run() format strings 2013-07-03 16:07:41 -07:00
svc_xprt.c svcrpc: fix rpc server shutdown races 2013-02-17 10:53:51 -05:00
svcauth.c hlist: drop the node parameter from iterators 2013-02-27 19:10:24 -08:00
svcauth_unix.c svcrpc: fix failures to handle -1 uid's 2013-07-08 17:27:23 -04:00
svcsock.c NFSD/sunrpc: avoid deadlock on TCP connection due to memory pressure. 2013-08-01 08:39:16 -04:00
sysctl.c net: Convert uses of typedef ctl_table to struct ctl_table 2013-06-13 02:36:09 -07:00
timer.c
xdr.c sunrpc: trim off trailing checksum before returning decrypted or integrity authenticated buffer 2013-02-08 15:19:10 -05:00
xprt.c SUNRPC: allow disabling idle timeout 2013-04-26 11:41:26 -04:00
xprtsock.c Merge branch 'for-3.11' of git://linux-nfs.org/~bfields/linux 2013-07-11 10:17:13 -07:00