Skip to content

Commit 0e1c02e

Browse files
cdmackaygregkh
authored andcommitted
lockd: don't use interval-based rebinding over TCP
[ Upstream commit 9b82d88 ] NLM uses an interval-based rebinding, i.e. it clears the transport's binding under certain conditions if more than 60 seconds have elapsed since the connection was last bound. This rebinding is not necessary for an autobind RPC client over a connection-oriented protocol like TCP. It can also cause problems: it is possible for nlm_bind_host() to clear XPRT_BOUND whilst a connection worker is in the middle of trying to reconnect, after it had already been checked in xprt_connect(). When the connection worker notices that XPRT_BOUND has been cleared under it, in xs_tcp_finish_connecting(), that results in: xs_tcp_setup_socket: connect returned unhandled error -107 Worse, it's possible that the two can get into lockstep, resulting in the same behaviour repeated indefinitely, with the above error every 300 seconds, without ever recovering, and the connection never being established. This has been seen in practice, with a large number of NLM client tasks, following a server restart. The existing callers of nlm_bind_host & nlm_rebind_host should not need to force the rebind, for TCP, so restrict the interval-based rebinding to UDP only. For TCP, we will still rebind when needed, e.g. on timeout, and connection error (including closure), since connection-related errors on an existing connection, ECONNREFUSED when trying to connect, and rpc_check_timeout(), already unconditionally clear XPRT_BOUND. To avoid having to add the fix, and explanation, to both nlm_bind_host() and nlm_rebind_host(), remove the duplicate code from the former, and have it call the latter. Drop the dprintk, which adds no value over a trace. Signed-off-by: Calum Mackay <calum.mackay@oracle.com> Fixes: 35f5a42 ("SUNRPC: new interface to force an RPC rebind") Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 7941ee4 commit 0e1c02e

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

‎fs/lockd/host.c‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -439,12 +439,7 @@ nlm_bind_host(struct nlm_host *host)
439439
* RPC rebind is required
440440
*/
441441
if ((clnt = host->h_rpcclnt) != NULL) {
442-
if (time_after_eq(jiffies, host->h_nextrebind)) {
443-
rpc_force_rebind(clnt);
444-
host->h_nextrebind = jiffies + NLM_HOST_REBIND;
445-
dprintk("lockd: next rebind in %lu jiffies\n",
446-
host->h_nextrebind - jiffies);
447-
}
442+
nlm_rebind_host(host);
448443
} else {
449444
unsigned long increment = nlmsvc_timeout;
450445
struct rpc_timeout timeparms = {
@@ -494,13 +489,20 @@ nlm_bind_host(struct nlm_host *host)
494489
return clnt;
495490
}
496491

497-
/*
498-
* Force a portmap lookup of the remote lockd port
492+
/**
493+
* nlm_rebind_host - If needed, force a portmap lookup of the peer's lockd port
494+
* @host: NLM host handle for peer
495+
*
496+
* This is not needed when using a connection-oriented protocol, such as TCP.
497+
* The existing autobind mechanism is sufficient to force a rebind when
498+
* required, e.g. on connection state transitions.
499499
*/
500500
void
501501
nlm_rebind_host(struct nlm_host *host)
502502
{
503-
dprintk("lockd: rebind host %s\n", host->h_name);
503+
if (host->h_proto != IPPROTO_UDP)
504+
return;
505+
504506
if (host->h_rpcclnt && time_after_eq(jiffies, host->h_nextrebind)) {
505507
rpc_force_rebind(host->h_rpcclnt);
506508
host->h_nextrebind = jiffies + NLM_HOST_REBIND;

0 commit comments

Comments
 (0)