Skip to contentSkip to conversation

Two more places that need to handle ENETDOWN/ENETUNREACH

PATCH In review [email protected] 2 participants 5 messages Apr 6, 2025

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

v2 cover Two more places that need to handle ENETDOWN/ENETUNREACH

From: Trond Myklebust <[email protected]>

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(+)
Signature · 1 line
2.49.0
author maintainer
#1 lore raw

PATCH v2 1/2 NFSv4: Handle fatal ENETDOWN and ENETUNREACH errors

From: Trond Myklebust <[email protected]>

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

---
 fs/nfs/nfs4proc.c | 9 +++++++++
 1 file changed, 9 insertions(+)
fs/nfs/nfs4proc.c +9 -0
index da97f87ecaa9..01417e3099e3 100644
@@ -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);
Signature · 1 line
2.49.0
author maintainer
#3 lore raw

PATCH v2 2/2 NFSv4/pnfs: Layoutreturn on close must handle fatal networking errors

In reply to [email protected]

From: Trond Myklebust <[email protected]>

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.

---
 fs/nfs/pnfs.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
fs/nfs/pnfs.c +12 -0
index 5f582713bf05..10fdd065a61c 100644
@@ -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;
Signature · 1 line
2.49.0
maintainer Reviewed-by on v2 1/2
#2 lore raw

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

In reply to [email protected]
Quoted 16 lines · On Sun, 2025-04-06 at 17:45 +0200, [email protected] wrote:

From: Trond Myklebust <[email protected]>

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

---
 fs/nfs/nfs4proc.c | 9 +++++++++
 1 file changed, 9 insertions(+)
fs/nfs/nfs4proc.c +0 -0
index da97f87ecaa9..01417e3099e3 100644

fs/nfs/nfs4proc.c nfs4_async_handle_exception(struct rpc_task *task, struct nfs_server *server, · line 676

Quoted 6 lines
fs/nfs/nfs4proc.c +3 -0
@@ -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);
}

fs/nfs/nfs4proc.c nfs4_async_handle_exception(struct rpc_task *task, struct nfs_server *server, · line 685

Quoted 9 lines
fs/nfs/nfs4proc.c +6 -0
+		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.

maintainer Reviewed-by on v2 2/2
#4 lore raw

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

In reply to [email protected]
Quoted 23 lines · On Sun, 2025-04-06 at 17:45 +0200, [email protected] wrote:

From: Trond Myklebust <[email protected]>

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.

---
 fs/nfs/pnfs.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
fs/nfs/pnfs.c +5 -0
index 5f582713bf05..10fdd065a61c 100644
@@ -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 ||

fs/nfs/pnfs.c int pnfs_roc_done(struct rpc_task *task, struct nfs4_layoutreturn_args **argpp, · line 1678

Quoted 10 lines
fs/nfs/pnfs.c +7 -0
+		     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;