diff mbox series

[1/2] NFSv4: Handle fatal ENETDOWN and ENETUNREACH errors

Message ID 756e03b4405f80344f98a695f49e50dd3a1caca0.1743930506.git.trond.myklebust@hammerspace.com (mailing list archive)
State New
Headers show
Series Two more places that need to handle ENETDOWN/ENETUNREACH | expand

Commit Message

Trond Myklebust April 6, 2025, 9:11 a.m. UTC
From: Trond Myklebust <trond.myklebust@hammerspace.com>

Ensure that the NFSv4 error handling code recognises the
RPC_TASK_NETUNREACH_FATAL flag, and handles the ENETDOWN and ENETUNREACH
errors accordingly.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
 fs/nfs/nfs4proc.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Jeff Layton April 6, 2025, 1:08 p.m. UTC | #1
On Sun, 2025-04-06 at 11:11 +0200, trondmy@kernel.org wrote:
> From: Trond Myklebust <trond.myklebust@hammerspace.com>
> 
> Ensure that the NFSv4 error handling code recognises the
> RPC_TASK_NETUNREACH_FATAL flag, and handles the ENETDOWN and ENETUNREACH
> errors accordingly.
> 
> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
> ---
>  fs/nfs/nfs4proc.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
> index da97f87ecaa9..f862c862b3a3 100644
> --- a/fs/nfs/nfs4proc.c
> +++ b/fs/nfs/nfs4proc.c
> @@ -671,6 +671,15 @@ nfs4_async_handle_exception(struct rpc_task *task, struct nfs_server *server,
>  	struct nfs_client *clp = server->nfs_client;
>  	int ret;
>  
> +	if ((task->tk_rpc_status == -ENETDOWN ||
> +	     task->tk_rpc_status == -ENETUNREACH) &&
> +	    task->tk_flags & RPC_TASK_NETUNREACH_FATAL) {
> +		exception->retry = 0;
> +		exception->recovering = 0;
> +		exception->retry = 0;

Why set exception->retry twice?

> +		return -EIO;
> +	}
> +
>  	ret = nfs4_do_handle_exception(server, errorcode, exception);
>  	if (exception->delay) {
>  		int ret2 = nfs4_exception_should_retrans(server, exception);

Other than that, this looks sane.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Trond Myklebust April 6, 2025, 3:28 p.m. UTC | #2
On Sun, 2025-04-06 at 09:08 -0400, Jeff Layton wrote:
> On Sun, 2025-04-06 at 11:11 +0200, trondmy@kernel.org wrote:
> > From: Trond Myklebust <trond.myklebust@hammerspace.com>
> > 
> > Ensure that the NFSv4 error handling code recognises the
> > RPC_TASK_NETUNREACH_FATAL flag, and handles the ENETDOWN and
> > ENETUNREACH
> > errors accordingly.
> > 
> > Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
> > ---
> >  fs/nfs/nfs4proc.c | 9 +++++++++
> >  1 file changed, 9 insertions(+)
> > 
> > diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
> > index da97f87ecaa9..f862c862b3a3 100644
> > --- a/fs/nfs/nfs4proc.c
> > +++ b/fs/nfs/nfs4proc.c
> > @@ -671,6 +671,15 @@ nfs4_async_handle_exception(struct rpc_task
> > *task, struct nfs_server *server,
> >  	struct nfs_client *clp = server->nfs_client;
> >  	int ret;
> >  
> > +	if ((task->tk_rpc_status == -ENETDOWN ||
> > +	     task->tk_rpc_status == -ENETUNREACH) &&
> > +	    task->tk_flags & RPC_TASK_NETUNREACH_FATAL) {
> > +		exception->retry = 0;
> > +		exception->recovering = 0;
> > +		exception->retry = 0;
> 
> Why set exception->retry twice?

Oops. That last one is supposed to be exception->delay = 0

Thanks for noticing!

> 
> > +		return -EIO;
> > +	}
> > +
> >  	ret = nfs4_do_handle_exception(server, errorcode,
> > exception);
> >  	if (exception->delay) {
> >  		int ret2 = nfs4_exception_should_retrans(server,
> > exception);
> 
> Other than that, this looks sane.
> 
> Reviewed-by: Jeff Layton <jlayton@kernel.org>
diff mbox series

Patch

diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index da97f87ecaa9..f862c862b3a3 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -671,6 +671,15 @@  nfs4_async_handle_exception(struct rpc_task *task, struct nfs_server *server,
 	struct nfs_client *clp = server->nfs_client;
 	int ret;
 
+	if ((task->tk_rpc_status == -ENETDOWN ||
+	     task->tk_rpc_status == -ENETUNREACH) &&
+	    task->tk_flags & RPC_TASK_NETUNREACH_FATAL) {
+		exception->retry = 0;
+		exception->recovering = 0;
+		exception->retry = 0;
+		return -EIO;
+	}
+
 	ret = nfs4_do_handle_exception(server, errorcode, exception);
 	if (exception->delay) {
 		int ret2 = nfs4_exception_should_retrans(server, exception);