* [PATCH v2 0/2] Two more places that need to handle ENETDOWN/ENETUNREACH
@ 2025-04-06 15:45 trondmy
2025-04-06 15:45 ` [PATCH v2 1/2] NFSv4: Handle fatal ENETDOWN and ENETUNREACH errors trondmy
2025-04-06 15:45 ` [PATCH v2 2/2] NFSv4/pnfs: Layoutreturn on close must handle fatal networking errors trondmy
0 siblings, 2 replies; 5+ messages in thread
From: trondmy @ 2025-04-06 15:45 UTC (permalink / raw)
To: Omar Sandoval; +Cc: Jeff Layton, Chris Mason, linux-nfs
From: Trond Myklebust <trond.myklebust@hammerspace.com>
Omar Sandoval reports seeing layouts that are leaked when a container is
shut down uncleanly.
---
v2:
- Fix issues reported by Jeff Layton
Trond Myklebust (2):
NFSv4: Handle fatal ENETDOWN and ENETUNREACH errors
NFSv4/pnfs: Layoutreturn on close must handle fatal networking errors
fs/nfs/nfs4proc.c | 9 +++++++++
fs/nfs/pnfs.c | 12 ++++++++++++
2 files changed, 21 insertions(+)
--
2.49.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 1/2] NFSv4: Handle fatal ENETDOWN and ENETUNREACH errors
2025-04-06 15:45 [PATCH v2 0/2] Two more places that need to handle ENETDOWN/ENETUNREACH trondmy
@ 2025-04-06 15:45 ` trondmy
2025-04-06 15:54 ` Jeff Layton
2025-04-06 15:45 ` [PATCH v2 2/2] NFSv4/pnfs: Layoutreturn on close must handle fatal networking errors trondmy
1 sibling, 1 reply; 5+ messages in thread
From: trondmy @ 2025-04-06 15:45 UTC (permalink / raw)
To: Omar Sandoval; +Cc: Jeff Layton, Chris Mason, linux-nfs
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..01417e3099e3 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->delay = 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);
--
2.49.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH v2 1/2] NFSv4: Handle fatal ENETDOWN and ENETUNREACH errors
2025-04-06 15:45 ` [PATCH v2 1/2] NFSv4: Handle fatal ENETDOWN and ENETUNREACH errors trondmy
@ 2025-04-06 15:54 ` Jeff Layton
0 siblings, 0 replies; 5+ messages in thread
From: Jeff Layton @ 2025-04-06 15:54 UTC (permalink / raw)
To: trondmy, Omar Sandoval; +Cc: Chris Mason, linux-nfs
On Sun, 2025-04-06 at 17:45 +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..01417e3099e3 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) {
We're sprinkling the above conditional in quite a few places now. It
would be nice to turn the above if statement into a helper function.
Something like this maybe?
static inline bool netunreach_fatal(struct rpc_task *task)
{
return (task->tk_rpc_status == -ENETDOWN || task->tk_rpc_status == -ENETUNREACH) && (task->tk_flags & RPC_TASK_NETUNREACH_FATAL);
}
> + exception->delay = 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);
Patch looks good though.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2 2/2] NFSv4/pnfs: Layoutreturn on close must handle fatal networking errors
2025-04-06 15:45 [PATCH v2 0/2] Two more places that need to handle ENETDOWN/ENETUNREACH trondmy
2025-04-06 15:45 ` [PATCH v2 1/2] NFSv4: Handle fatal ENETDOWN and ENETUNREACH errors trondmy
@ 2025-04-06 15:45 ` trondmy
2025-04-06 15:54 ` Jeff Layton
1 sibling, 1 reply; 5+ messages in thread
From: trondmy @ 2025-04-06 15:45 UTC (permalink / raw)
To: Omar Sandoval; +Cc: Jeff Layton, Chris Mason, linux-nfs
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 | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
index 5f582713bf05..10fdd065a61c 100644
--- a/fs/nfs/pnfs.c
+++ b/fs/nfs/pnfs.c
@@ -1661,6 +1661,18 @@ int pnfs_roc_done(struct rpc_task *task, struct nfs4_layoutreturn_args **argpp,
/* Was there an RPC level error? If not, retry */
if (task->tk_rpc_status == 0)
break;
+ /*
+ * Is there a fatal network level error?
+ * If so release the layout, but flag the error.
+ */
+ 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;
--
2.49.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH v2 2/2] NFSv4/pnfs: Layoutreturn on close must handle fatal networking errors
2025-04-06 15:45 ` [PATCH v2 2/2] NFSv4/pnfs: Layoutreturn on close must handle fatal networking errors trondmy
@ 2025-04-06 15:54 ` Jeff Layton
0 siblings, 0 replies; 5+ messages in thread
From: Jeff Layton @ 2025-04-06 15:54 UTC (permalink / raw)
To: trondmy, Omar Sandoval; +Cc: Chris Mason, linux-nfs
On Sun, 2025-04-06 at 17:45 +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 | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
> index 5f582713bf05..10fdd065a61c 100644
> --- a/fs/nfs/pnfs.c
> +++ b/fs/nfs/pnfs.c
> @@ -1661,6 +1661,18 @@ int pnfs_roc_done(struct rpc_task *task, struct nfs4_layoutreturn_args **argpp,
> /* Was there an RPC level error? If not, retry */
> if (task->tk_rpc_status == 0)
> break;
> + /*
> + * Is there a fatal network level error?
> + * If so release the layout, but flag the error.
> + */
> + 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;
Reviewed-by: Jeff Layton <jlayton@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-04-06 15:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-06 15:45 [PATCH v2 0/2] Two more places that need to handle ENETDOWN/ENETUNREACH trondmy
2025-04-06 15:45 ` [PATCH v2 1/2] NFSv4: Handle fatal ENETDOWN and ENETUNREACH errors trondmy
2025-04-06 15:54 ` Jeff Layton
2025-04-06 15:45 ` [PATCH v2 2/2] NFSv4/pnfs: Layoutreturn on close must handle fatal networking errors trondmy
2025-04-06 15:54 ` Jeff Layton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox