diff mbox series

[2/2] NFSv4/pnfs: Layoutreturn on close must handle fatal networking errors

Message ID cdb06dc8d5ab3e65db78a78a9ac5969453efe0b5.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>

If we have a fatal ENETDOWN or ENETUNREACH error, then the layoutreturn
on close code should also handle that as fatal, and free the layouts.

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

Comments

Jeff Layton April 6, 2025, 1:16 p.m. UTC | #1
On Sun, 2025-04-06 at 11:11 +0200, trondmy@kernel.org wrote:
> From: Trond Myklebust <trond.myklebust@hammerspace.com>
> 
> If we have a fatal ENETDOWN or ENETUNREACH error, then the layoutreturn
> on close code should also handle that as fatal, and free the layouts.
> 
> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
> ---
>  fs/nfs/pnfs.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
> index 5f582713bf05..3554046b5bfc 100644
> --- a/fs/nfs/pnfs.c
> +++ b/fs/nfs/pnfs.c
> @@ -1659,8 +1659,16 @@ int pnfs_roc_done(struct rpc_task *task, struct nfs4_layoutreturn_args **argpp,
>  		break;
>  	case -NFS4ERR_NOMATCHING_LAYOUT:
>  		/* Was there an RPC level error? If not, retry */
> -		if (task->tk_rpc_status == 0)
> +		if (task->tk_rpc_status == 0) {
> +			if ((task->tk_rpc_status == -ENETDOWN ||
> +			     task->tk_rpc_status == -ENETUNREACH) &&
> +			    task->tk_flags & RPC_TASK_NETUNREACH_FATAL) {

You already checked that task->tk_rpc_status is 0, so the inside if
statement will never be true. I think you probably want to get rid if
the outside 

     if (task->tk_rpc_status == 0)

condition?

> +				*ret = 0;
> +				(*respp)->lrs_present = 0;
> +				retval = -EIO;
> +			}
>  			break;
> +		}
>  		/* If the call was not sent, let caller handle it */
>  		if (!RPC_WAS_SENT(task))
>  			return 0;
Trond Myklebust April 6, 2025, 3:29 p.m. UTC | #2
On Sun, 2025-04-06 at 09:16 -0400, Jeff Layton wrote:
> On Sun, 2025-04-06 at 11:11 +0200, trondmy@kernel.org wrote:
> > From: Trond Myklebust <trond.myklebust@hammerspace.com>
> > 
> > If we have a fatal ENETDOWN or ENETUNREACH error, then the
> > layoutreturn
> > on close code should also handle that as fatal, and free the
> > layouts.
> > 
> > Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
> > ---
> >  fs/nfs/pnfs.c | 10 +++++++++-
> >  1 file changed, 9 insertions(+), 1 deletion(-)
> > 
> > diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
> > index 5f582713bf05..3554046b5bfc 100644
> > --- a/fs/nfs/pnfs.c
> > +++ b/fs/nfs/pnfs.c
> > @@ -1659,8 +1659,16 @@ int pnfs_roc_done(struct rpc_task *task,
> > struct nfs4_layoutreturn_args **argpp,
> >  		break;
> >  	case -NFS4ERR_NOMATCHING_LAYOUT:
> >  		/* Was there an RPC level error? If not, retry */
> > -		if (task->tk_rpc_status == 0)
> > +		if (task->tk_rpc_status == 0) {
> > +			if ((task->tk_rpc_status == -ENETDOWN ||
> > +			     task->tk_rpc_status == -ENETUNREACH)
> > &&
> > +			    task->tk_flags &
> > RPC_TASK_NETUNREACH_FATAL) {
> 
> You already checked that task->tk_rpc_status is 0, so the inside if
> statement will never be true. I think you probably want to get rid if
> the outside 
> 
>      if (task->tk_rpc_status == 0)
> 
> condition?

Sorry... Jet lagged in Switzerland.
Let me move that out of the == 0 and before the !SENT...

> 
> > +				*ret = 0;
> > +				(*respp)->lrs_present = 0;
> > +				retval = -EIO;
> > +			}
> >  			break;
> > +		}
> >  		/* If the call was not sent, let caller handle it
> > */
> >  		if (!RPC_WAS_SENT(task))
> >  			return 0;
>
diff mbox series

Patch

diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 5f582713bf05..3554046b5bfc 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -1659,8 +1659,16 @@  int pnfs_roc_done(struct rpc_task *task, struct nfs4_layoutreturn_args **argpp,
 		break;
 	case -NFS4ERR_NOMATCHING_LAYOUT:
 		/* Was there an RPC level error? If not, retry */
-		if (task->tk_rpc_status == 0)
+		if (task->tk_rpc_status == 0) {
+			if ((task->tk_rpc_status == -ENETDOWN ||
+			     task->tk_rpc_status == -ENETUNREACH) &&
+			    task->tk_flags & RPC_TASK_NETUNREACH_FATAL) {
+				*ret = 0;
+				(*respp)->lrs_present = 0;
+				retval = -EIO;
+			}
 			break;
+		}
 		/* If the call was not sent, let caller handle it */
 		if (!RPC_WAS_SENT(task))
 			return 0;