]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
SUNRPC: ECONNREFUSED should cause a rebind.
authorNeilBrown <neilb@suse.com>
Fri, 18 Aug 2017 07:12:51 +0000 (17:12 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 10 Nov 2020 09:22:11 +0000 (10:22 +0100)
commit fd01b2597941d9c17980222999b0721648b383b8 upstream.

If you
 - mount and NFSv3 filesystem
 - do some file locking which requires the server
   to make a GRANT call back
 - unmount
 - mount again and do the same locking

then the second attempt at locking suffers a 30 second delay.
Unmounting and remounting causes lockd to stop and restart,
which causes it to bind to a new port.
The server still thinks the old port is valid and gets ECONNREFUSED
when trying to contact it.
ECONNREFUSED should be seen as a hard error that is not worth
retrying.  Rebinding is the only reasonable response.

This patch forces a rebind if that makes sense.

Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Cc: Calum Mackay <calum.mackay@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/sunrpc/clnt.c

index f28aeb2cfd32874c3a1cce4720564003b94fdff5..cc308f7a2c02792e141300f567f2cb35f8901351 100644 (file)
@@ -1826,6 +1826,14 @@ call_connect_status(struct rpc_task *task)
        task->tk_status = 0;
        switch (status) {
        case -ECONNREFUSED:
+               /* A positive refusal suggests a rebind is needed. */
+               if (RPC_IS_SOFTCONN(task))
+                       break;
+               if (clnt->cl_autobind) {
+                       rpc_force_rebind(clnt);
+                       task->tk_action = call_bind;
+                       return;
+               }
        case -ECONNRESET:
        case -ECONNABORTED:
        case -ENETUNREACH: