diff mbox

[1/8] SUNRPC: ECONNREFUSED should cause a rebind.

Message ID 150304037184.30218.7244179303036576085.stgit@noble (mailing list archive)
State New, archived
Headers show

Commit Message

NeilBrown Aug. 18, 2017, 7:12 a.m. UTC
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>
---
 net/sunrpc/clnt.c |    8 ++++++++
 1 file changed, 8 insertions(+)



--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Chuck Lever III Aug. 18, 2017, 2:40 p.m. UTC | #1
> On Aug 18, 2017, at 3:12 AM, NeilBrown <neilb@suse.com> wrote:
> 
> 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.

I also reported this problem recently, and found a similar
(but rather lockd-centric) solution.

Reviewed-by: Chuck Lever <chuck.lever@oracle.com>


> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
> net/sunrpc/clnt.c |    8 ++++++++
> 1 file changed, 8 insertions(+)
> 
> diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
> index 2e49d1f892b7..69a9e5953744 100644
> --- a/net/sunrpc/clnt.c
> +++ b/net/sunrpc/clnt.c
> @@ -1903,6 +1903,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:
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
Chuck Lever



--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 2e49d1f892b7..69a9e5953744 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -1903,6 +1903,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: