Skip to content

Commit 0bd2f6b

Browse files
chuckleverAnna Schumaker
authored andcommitted
SUNRPC: Prevent hang on NFS mount with xprtsec=[m]tls
Engineers at Hammerspace noticed that sometimes mounting with "xprtsec=tls" hangs for a minute or so, and then times out, even when the NFS server is reachable and responsive. kTLS shuts off data_ready callbacks if strp->msg_ready is set to mitigate data_ready callbacks when a full TLS record is not yet ready to be read from the socket. Normally msg_ready is clear when the first TLS record arrives on a socket. However, I observed that sometimes tls_setsockopt() sets strp->msg_ready, and that prevents forward progress because tls_data_ready() becomes a no-op. Moreover, Jakub says: "If there's a full record queued at the time when [tlshd] passes the socket back to the kernel, it's up to the reader to read the already queued data out." So SunRPC cannot expect a data_ready call when ingress data is already waiting. Add an explicit poll after SunRPC's upper transport is set up to pick up any data that arrived after the TLS handshake but before transport set-up is complete. Reported-by: Steve Sears <[email protected]> Suggested-by: Jakub Kacinski <[email protected]> Fixes: 75eb6af ("SUNRPC: Add a TCP-with-TLS RPC transport class") Tested-by: Mike Snitzer <[email protected]> Reviewed-by: Mike Snitzer <[email protected]> Cc: [email protected] Signed-off-by: Chuck Lever <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent dd862da commit 0bd2f6b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

net/sunrpc/xprtsock.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2740,6 +2740,11 @@ static void xs_tcp_tls_setup_socket(struct work_struct *work)
27402740
}
27412741
rpc_shutdown_client(lower_clnt);
27422742

2743+
/* Check for ingress data that arrived before the socket's
2744+
* ->data_ready callback was set up.
2745+
*/
2746+
xs_poll_check_readable(upper_transport);
2747+
27432748
out_unlock:
27442749
current_restore_flags(pflags, PF_MEMALLOC);
27452750
upper_transport->clnt = NULL;

0 commit comments

Comments
 (0)