Skip to contentSkip to conversation

Ensure that ENETUNREACH terminates state recovery

PATCH Superseded [email protected] 4 participants 16 messages Mar 25, 2025

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

v2 cover Ensure that ENETUNREACH terminates state recovery

From: Trond Myklebust <[email protected]>

With the recent patch series that caused containerised mounts which return ENETUNREACH or ENETDOWN errors to report fatal errors, we also want to ensure that the state manager thread also triggers fatal errors in the processes or threads that are waiting for recovery to complete.

---
v2:
- Return EIO instead of ENETUNREACH in nfs4_wait_clnt_recover()

Trond Myklebust (4):
SUNRPC: rpcbind should never reset the port to the value '0'
SUNRPC: rpc_clnt_set_transport() must not change the autobind setting
NFSv4: clp->cl_cons_state < 0 signifies an invalid nfs_client
NFSv4: Treat ENETUNREACH errors as fatal for state recovery

 fs/nfs/nfs4state.c     | 14 +++++++++++---
 net/sunrpc/clnt.c      |  3 ---
 net/sunrpc/rpcb_clnt.c |  5 +++--
 3 files changed, 14 insertions(+), 8 deletions(-)
Signature · 1 line
2.49.0
author maintainer
#1 lore raw

PATCH v2 1/4 SUNRPC: rpcbind should never reset the port to the value '0'

From: Trond Myklebust <[email protected]>

If we already had a valid port number for the RPC service, then we should not allow the rpcbind client to set it to the invalid value '0'.

---
 net/sunrpc/rpcb_clnt.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
net/sunrpc/rpcb_clnt.c +3 -2
index 102c3818bc54..53bcca365fb1 100644
@@ -820,9 +820,10 @@ static void rpcb_getport_done(struct rpc_task *child, void *data)
 	}
 
 	trace_rpcb_setport(child, map->r_status, map->r_port);
-	xprt->ops->set_port(xprt, map->r_port);
-	if (map->r_port)
+	if (map->r_port) {
+		xprt->ops->set_port(xprt, map->r_port);
 		xprt_set_bound(xprt);
+	}
 }
 
 /*
Signature · 1 line
2.49.0
maintainer Reviewed-by on v2 1/4
#2 lore raw

Re: [PATCH v2 1/4] SUNRPC: rpcbind should never reset the port to the value '0'

Quoted 17 lines · On Tue, 2025-03-25 at 12:17 -0400, [email protected] wrote:

From: Trond Myklebust <[email protected]>

If we already had a valid port number for the RPC service, then we should not allow the rpcbind client to set it to the invalid value '0'.

---
 net/sunrpc/rpcb_clnt.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
net/sunrpc/rpcb_clnt.c +0 -0
index 102c3818bc54..53bcca365fb1 100644
@@ -820,9 +820,10 @@ static void rpcb_getport_done(struct rpc_task *child, void *data)
 	}
 

net/sunrpc/rpcb_clnt.c static void rpcb_getport_done(struct rpc_task *child, void *data) · line 829

Quoted 10 lines
net/sunrpc/rpcb_clnt.c +3 -2
 	trace_rpcb_setport(child, map->r_status, map->r_port);
-	xprt->ops->set_port(xprt, map->r_port);
-	if (map->r_port)
+	if (map->r_port) {
+		xprt->ops->set_port(xprt, map->r_port);
 		xprt_set_bound(xprt);
+	}
 }
 
 /*
author maintainer
#3 lore raw

PATCH v2 2/4 SUNRPC: rpc_clnt_set_transport() must not change the autobind setting

In reply to [email protected]

From: Trond Myklebust <[email protected]>

The autobind setting was supposed to be determined in rpc_create(), since commit c2866763b402 ("SUNRPC: use sockaddr + size when creating remote transport endpoints").

---
 net/sunrpc/clnt.c | 3 ---
 1 file changed, 3 deletions(-)
net/sunrpc/clnt.c +0 -3
index 1cfaf93ceec1..6f75862d9782 100644
@@ -270,9 +270,6 @@ static struct rpc_xprt *rpc_clnt_set_transport(struct rpc_clnt *clnt,
 	old = rcu_dereference_protected(clnt->cl_xprt,
 			lockdep_is_held(&clnt->cl_lock));
 
-	if (!xprt_bound(xprt))
-		clnt->cl_autobind = 1;
-
 	clnt->cl_timeout = timeout;
 	rcu_assign_pointer(clnt->cl_xprt, xprt);
 	spin_unlock(&clnt->cl_lock);
Signature · 1 line
2.49.0
maintainer Reviewed-by on v2 2/4
#4 lore raw

Re: [PATCH v2 2/4] SUNRPC: rpc_clnt_set_transport() must not change the autobind setting

Quoted 6 lines · On Tue, 2025-03-25 at 12:17 -0400, [email protected] wrote:

From: Trond Myklebust <[email protected]>

The autobind setting was supposed to be determined in rpc_create(), since commit c2866763b402 ("SUNRPC: use sockaddr + size when creating remote transport endpoints").

Should this have:

Fixes c2866763b402 ("SUNRPC: use sockaddr + size when creating remote transport endpoints")

?

Though I guess that commit is old enough that maybe it doesn't matter.

Quoted 10 lines
---
 net/sunrpc/clnt.c | 3 ---
 1 file changed, 3 deletions(-)
net/sunrpc/clnt.c +0 -0
index 1cfaf93ceec1..6f75862d9782 100644

net/sunrpc/clnt.c static struct rpc_xprt *rpc_clnt_set_transport(struct rpc_clnt *clnt, · line 275

Quoted 9 lines
net/sunrpc/clnt.c +0 -3
@@ -270,9 +270,6 @@ static struct rpc_xprt *rpc_clnt_set_transport(struct rpc_clnt *clnt,
 	old = rcu_dereference_protected(clnt->cl_xprt,
 			lockdep_is_held(&clnt->cl_lock));
 
-	if (!xprt_bound(xprt))
-		clnt->cl_autobind = 1;
-
 	clnt->cl_timeout = timeout;
 	rcu_assign_pointer(clnt->cl_xprt, xprt);
 	spin_unlock(&clnt->cl_lock);
author maintainer
#5 lore raw

PATCH v2 3/4 NFSv4: clp->cl_cons_state < 0 signifies an invalid nfs_client

In reply to [email protected]

From: Trond Myklebust <[email protected]>

If someone calls nfs_mark_client_ready(clp, status) with a negative value for status, then that should signal that the nfs_client is no longer valid.

---
 fs/nfs/nfs4state.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfs/nfs4state.c +2 -2
index 542cdf71229f..738eb2789266 100644
@@ -1198,7 +1198,7 @@ void nfs4_schedule_state_manager(struct nfs_client *clp)
 	struct rpc_clnt *clnt = clp->cl_rpcclient;
 	bool swapon = false;
 
-	if (clnt->cl_shutdown)
+	if (clnt->cl_shutdown || clp->cl_cons_state < 0)
 		return;
 
 	set_bit(NFS4CLNT_RUN_MANAGER, &clp->cl_state);
@@ -1403,7 +1403,7 @@ int nfs4_schedule_stateid_recovery(const struct nfs_server *server, struct nfs4_
 	dprintk("%s: scheduling stateid recovery for server %s\n", __func__,
 			clp->cl_hostname);
 	nfs4_schedule_state_manager(clp);
-	return 0;
+	return clp->cl_cons_state < 0 ? clp->cl_cons_state : 0;
 }
 EXPORT_SYMBOL_GPL(nfs4_schedule_stateid_recovery);
 
Signature · 1 line
2.49.0
maintainer
#6 lore raw

Re: [PATCH v2 3/4] NFSv4: clp->cl_cons_state < 0 signifies an invalid nfs_client

Quoted 16 lines · On Tue, 2025-03-25 at 12:17 -0400, [email protected] wrote:

From: Trond Myklebust <[email protected]>

If someone calls nfs_mark_client_ready(clp, status) with a negative value for status, then that should signal that the nfs_client is no longer valid.

---
 fs/nfs/nfs4state.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/nfs/nfs4state.c +0 -0
index 542cdf71229f..738eb2789266 100644

fs/nfs/nfs4state.c void nfs4_schedule_state_manager(struct nfs_client *clp) · line 1201

Quoted 5 lines
fs/nfs/nfs4state.c +1 -1
@@ -1198,7 +1198,7 @@ void nfs4_schedule_state_manager(struct nfs_client *clp)
 	struct rpc_clnt *clnt = clp->cl_rpcclient;
 	bool swapon = false;
 
-	if (clnt->cl_shutdown)
+	if (clnt->cl_shutdown || clp->cl_cons_state < 0)

Would it be simpler to just set cl_shutdown when this occurs instead of having to check cl_cons_state as well?

Quoted 12 lines
fs/nfs/nfs4state.c +1 -1
 		return;
 
 	set_bit(NFS4CLNT_RUN_MANAGER, &clp->cl_state);
@@ -1403,7 +1403,7 @@ int nfs4_schedule_stateid_recovery(const struct nfs_server *server, struct nfs4_
 	dprintk("%s: scheduling stateid recovery for server %s\n", __func__,
 			clp->cl_hostname);
 	nfs4_schedule_state_manager(clp);
-	return 0;
+	return clp->cl_cons_state < 0 ? clp->cl_cons_state : 0;
 }
 EXPORT_SYMBOL_GPL(nfs4_schedule_stateid_recovery);
 
Signature · 1 line
Jeff Layton <[email protected]>
#7 lore raw

Re: [PATCH v2 3/4] NFSv4: clp->cl_cons_state < 0 signifies an invalid nfs_client

Quoted 12 lines · Jeff Layton
Quoted 11 lines · On Tue, 2025-03-25 at 12:17 -0400, [email protected] wrote:

From: Trond Myklebust <[email protected]>

If someone calls nfs_mark_client_ready(clp, status) with a negative value for status, then that should signal that the nfs_client is no longer valid.

---
 fs/nfs/nfs4state.c | 4 ++--

 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 15 lines

fs/nfs/nfs4state.c void nfs4_schedule_state_manager(struct nfs_client *clp) · line 1201

Quoted 11 lines
fs/nfs/nfs4state.c +0 -0
index 542cdf71229f..738eb2789266 100644
@@ -1198,7 +1198,7 @@ void nfs4_schedule_state_manager(struct
 nfs_client *clp)
  	struct rpc_clnt *clnt = clp->cl_rpcclient;
  	bool swapon = false;

fs/nfs/nfs4state.c +1 -1
-	if (clnt->cl_shutdown)
+	if (clnt->cl_shutdown || clp->cl_cons_state < 0)

Would it be simpler to just set cl_shutdown when this occurs instead of
having to check cl_cons_state as well?

Do we need the check for clnt->cl_shutdown at all here? I'd expect any caller of this function to already hold a reference to the client, which means that the RPC client should still be up.

I'm a little suspicious of the check in nfs41_sequence_call_done() too.

Quoted 16 lines
Quoted 15 lines

  return;

  set_bit(NFS4CLNT_RUN_MANAGER, &clp->cl_state);

fs/nfs/nfs4state.c +0 -0
@@ -1403,7 +1403,7 @@ int nfs4_schedule_stateid_recovery(const

struct nfs_server *server, struct nfs4_
  dprintk("%s: scheduling stateid recovery for server %s\n", __func__,
  clp->cl_hostname); nfs4_schedule_state_manager(clp);

fs/nfs/nfs4state.c +1 -1
-	return 0;
+	return clp->cl_cons_state < 0 ? clp->cl_cons_state : 0;

 } EXPORT_SYMBOL_GPL(nfs4_schedule_stateid_recovery);

Signature · 3 lines
Trond Myklebust
Linux NFS client maintainer, Hammerspace
[email protected]
maintainer
#8 lore raw

Re: [PATCH v2 3/4] NFSv4: clp->cl_cons_state < 0 signifies an invalid nfs_client

Quoted 29 lines · Trond Myklebust
Quoted 12 lines · Jeff Layton
Quoted 11 lines · On Tue, 2025-03-25 at 12:17 -0400, [email protected] wrote:

From: Trond Myklebust <[email protected]>

If someone calls nfs_mark_client_ready(clp, status) with a negative value for status, then that should signal that the nfs_client is no longer valid.

---
 fs/nfs/nfs4state.c | 4 ++--

 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 15 lines

fs/nfs/nfs4state.c void nfs4_schedule_state_manager(struct nfs_client *clp) · line 1201

Quoted 11 lines
fs/nfs/nfs4state.c +0 -0
index 542cdf71229f..738eb2789266 100644
@@ -1198,7 +1198,7 @@ void nfs4_schedule_state_manager(struct
 nfs_client *clp)
  	struct rpc_clnt *clnt = clp->cl_rpcclient;
  	bool swapon = false;

fs/nfs/nfs4state.c +1 -1
-	if (clnt->cl_shutdown)
+	if (clnt->cl_shutdown || clp->cl_cons_state < 0)

Would it be simpler to just set cl_shutdown when this occurs instead of
having to check cl_cons_state as well?

Quoted 3 lines

Do we need the check for clnt->cl_shutdown at all here? I'd expect any caller of this function to already hold a reference to the client, which means that the RPC client should still be up.

Not necessarily? Just because you hold a reference to the rpc_clnt doesn't mean that it's still up, AFAIU.

For instance, if you end up using the "shutdown" file in sysfs, any RPC still in flight will hold a reference to the client. Writing to "shutdown" will set cl_shutdown to 1 and then cancel all the RPCs, but there is at least a window of time where we have an elevated refcount but the client is no longer valid.

Quoted 3 lines

I'm a little suspicious of the check in nfs41_sequence_call_done() too.

Me too. I think this is probably an indicator that we need to carefully audit how cl_shutdown is used and clarify what it means. Luckily there are only a handful of places that reference it:

The call_start check is fine I thinkhhuhdljkfjltkuddjrig, though maybe we should add cl_shutdown checks in later states? The other places that check it come from this commit:

6ad477a69ad8 NFSv4: Clean up some shutdown loops

Should we convert both of those checks to look at clp->cl_cons_state instead?

Quoted 23 lines
Quoted 16 lines
Quoted 15 lines

  return;

  set_bit(NFS4CLNT_RUN_MANAGER, &clp->cl_state);

fs/nfs/nfs4state.c +0 -0
@@ -1403,7 +1403,7 @@ int nfs4_schedule_stateid_recovery(const

struct nfs_server *server, struct nfs4_
  dprintk("%s: scheduling stateid recovery for server %s\n", __func__,
  clp->cl_hostname); nfs4_schedule_state_manager(clp);

fs/nfs/nfs4state.c +1 -1
-	return 0;
+	return clp->cl_cons_state < 0 ? clp->cl_cons_state : 0;

 } EXPORT_SYMBOL_GPL(nfs4_schedule_stateid_recovery);

Signature · 3 lines
Trond Myklebust
Linux NFS client maintainer, Hammerspace
[email protected]
Signature · 1 line
Jeff Layton <[email protected]>
#9 lore raw

Re: [PATCH v2 3/4] NFSv4: clp->cl_cons_state < 0 signifies an invalid nfs_client

Quoted 42 lines · Jeff Layton
Quoted 33 lines · Trond Myklebust
Quoted 15 lines · Jeff Layton
Quoted 14 lines · On Tue, 2025-03-25 at 12:17 -0400, [email protected] wrote:

From: Trond Myklebust <[email protected]>

If someone calls nfs_mark_client_ready(clp, status) with a negative
value for status, then that should signal that the nfs_client is no
longer valid.

Signed-off-by: Trond Myklebust
<[email protected]>
---
 fs/nfs/nfs4state.c | 4 ++--

 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 16 lines

fs/nfs/nfs4state.c void nfs4_schedule_state_manager(struct nfs_client *clp) · line 1201

Quoted 11 lines
fs/nfs/nfs4state.c +0 -0
index 542cdf71229f..738eb2789266 100644
@@ -1198,7 +1198,7 @@ void nfs4_schedule_state_manager(struct
 nfs_client *clp)
  	struct rpc_clnt *clnt = clp->cl_rpcclient;
  	bool swapon = false;

fs/nfs/nfs4state.c +1 -1
-	if (clnt->cl_shutdown)
+	if (clnt->cl_shutdown || clp->cl_cons_state < 0)

Would it be simpler to just set cl_shutdown when this occurs instead
of
having to check cl_cons_state as well?

Quoted 4 lines

Do we need the check for clnt->cl_shutdown at all here? I'd expect any
caller of this function to already hold a reference to the client, which means that the RPC client should still be up.

Not necessarily? Just because you hold a reference to the rpc_clnt doesn't mean that it's still up, AFAIU.

Quoted 7 lines

For instance, if you end up using the "shutdown" file in sysfs, any RPC
still in flight will hold a reference to the client. Writing to "shutdown" will set cl_shutdown to 1 and then cancel all the RPCs, but
there is at least a window of time where we have an elevated refcount but the client is no longer valid.

The shutdown of the nfs_client RPC client happens in nfs_free_client().

Oh wait... Crap... Why is a per-nfs_server function like shutdown_store() reaching into the nfs_client? That's borked and needs to be fixed.

Quoted 19 lines
Quoted 6 lines

I'm a little suspicious of the check in nfs41_sequence_call_done() too.

Me too. I think this is probably an indicator that we need to carefully
audit how cl_shutdown is used and clarify what it means. Luckily there
are only a handful of places that reference it:

The call_start check is fine I thinkhhuhdljkfjltkuddjrig, though maybe
we should add cl_shutdown checks in later states? The other places that
check it come from this commit:

Quoted 4 lines

    6ad477a69ad8 NFSv4: Clean up some shutdown loops

Should we convert both of those checks to look at clp->cl_cons_state instead?

Yes.

Quoted 27 lines
Quoted 26 lines
Quoted 19 lines
Quoted 18 lines

  return;

  set_bit(NFS4CLNT_RUN_MANAGER, &clp->cl_state);

fs/nfs/nfs4state.c +0 -0
@@ -1403,7 +1403,7 @@ int nfs4_schedule_stateid_recovery(const

struct nfs_server *server, struct nfs4_ dprintk("%s: scheduling stateid recovery for server %s\n",
__func__,
  clp->cl_hostname); nfs4_schedule_state_manager(clp);

fs/nfs/nfs4state.c +1 -1
-	return 0;
+	return clp->cl_cons_state < 0 ? clp->cl_cons_state :

0;
 } EXPORT_SYMBOL_GPL(nfs4_schedule_stateid_recovery);

Signature · 3 lines
Trond Myklebust
Linux NFS client maintainer, Hammerspace
[email protected]
Signature · 6 lines
Trond Myklebust 
CTO, Hammerspace Inc 
1900 S Norfolk St, Suite 350 - #45 
San Mateo, CA 94403 
​
www.hammerspace.com
author maintainer
#10 lore raw

PATCH v2 4/4 NFSv4: Treat ENETUNREACH errors as fatal for state recovery

In reply to [email protected]

From: Trond Myklebust <[email protected]>

If a containerised process is killed and causes an ENETUNREACH or ENETDOWN error to be propagated to the state manager, then mark the nfs_client as being dead so that we don't loop in functions that are expecting recovery to succeed.

---
 fs/nfs/nfs4state.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
fs/nfs/nfs4state.c +9 -1
index 738eb2789266..14ba3f96e6fc 100644
@@ -2739,7 +2739,15 @@ static void nfs4_state_manager(struct nfs_client *clp)
 	pr_warn_ratelimited("NFS: state manager%s%s failed on NFSv4 server %s"
 			" with error %d\n", section_sep, section,
 			clp->cl_hostname, -status);
-	ssleep(1);
+	switch (status) {
+	case -ENETDOWN:
+	case -ENETUNREACH:
+		nfs_mark_client_ready(clp, -EIO);
+		break;
+	default:
+		ssleep(1);
+		break;
+	}
 out_drain:
 	memalloc_nofs_restore(memflags);
 	nfs4_end_drain_session(clp);
Signature · 1 line
2.49.0
maintainer
#11 lore raw

Re: [PATCH v2 4/4] NFSv4: Treat ENETUNREACH errors as fatal for state recovery

Quoted 17 lines · On Tue, 2025-03-25 at 12:17 -0400, [email protected] wrote:

From: Trond Myklebust <[email protected]>

If a containerised process is killed and causes an ENETUNREACH or ENETDOWN error to be propagated to the state manager, then mark the nfs_client as being dead so that we don't loop in functions that are expecting recovery to succeed.

---
 fs/nfs/nfs4state.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
fs/nfs/nfs4state.c +0 -0
index 738eb2789266..14ba3f96e6fc 100644

fs/nfs/nfs4state.c static void nfs4_state_manager(struct nfs_client *clp) · line 2746

Quoted 9 lines
fs/nfs/nfs4state.c +5 -1
@@ -2739,7 +2739,15 @@ static void nfs4_state_manager(struct nfs_client *clp)
 	pr_warn_ratelimited("NFS: state manager%s%s failed on NFSv4 server %s"
 			" with error %d\n", section_sep, section,
 			clp->cl_hostname, -status);
-	ssleep(1);
+	switch (status) {
+	case -ENETDOWN:
+	case -ENETUNREACH:
+		nfs_mark_client_ready(clp, -EIO);
+		break;

Should this be conditional on clnt->cl_netunreach_fatal being true?

Quoted 7 lines
fs/nfs/nfs4state.c +4 -0
+	default:
+		ssleep(1);
+		break;
+	}
 out_drain:
 	memalloc_nofs_restore(memflags);
 	nfs4_end_drain_session(clp);
Signature · 1 line
Jeff Layton <[email protected]>
#12 lore raw

Re: [PATCH v2 4/4] NFSv4: Treat ENETUNREACH errors as fatal for state recovery

Quoted 24 lines · Jeff Layton
Quoted 23 lines · On Tue, 2025-03-25 at 12:17 -0400, [email protected] wrote:

From: Trond Myklebust <[email protected]>

If a containerised process is killed and causes an ENETUNREACH or ENETDOWN error to be propagated to the state manager, then mark the nfs_client as being dead so that we don't loop in functions that are
expecting recovery to succeed.

---
 fs/nfs/nfs4state.c | 10 +++++++++-

 1 file changed, 9 insertions(+), 1 deletion(-)
fs/nfs/nfs4state.c +0 -0
index 738eb2789266..14ba3f96e6fc 100644
@@ -2739,7 +2739,15 @@ static void nfs4_state_manager(struct
 nfs_client *clp)

  pr_warn_ratelimited("NFS: state manager%s%s failed on NFSv4 server %s"
  " with error %d\n", section_sep, section, clp->cl_hostname, -status);

Quoted 8 lines

fs/nfs/nfs4state.c static void nfs4_state_manager(struct nfs_client *clp) · line 2746

Quoted 6 lines
fs/nfs/nfs4state.c +5 -1
-	ssleep(1);
+	switch (status) {
+	case -ENETDOWN:
+	case -ENETUNREACH:
+		nfs_mark_client_ready(clp, -EIO);
+		break;

Should this be conditional on clnt->cl_netunreach_fatal being true?

I should hope not. We shouldn't ever be seeing these errors here if it is false.

Quoted 9 lines

Quoted 7 lines
fs/nfs/nfs4state.c +4 -0
+	default:
+		ssleep(1);
+		break;
+	}

 out_drain:
  memalloc_nofs_restore(memflags);
  nfs4_end_drain_session(clp);

Signature · 3 lines
Trond Myklebust
Linux NFS client maintainer, Hammerspace
[email protected]
maintainer Reviewed-by
#13 lore raw

Re: [PATCH v2 4/4] NFSv4: Treat ENETUNREACH errors as fatal for state recovery

Quoted 34 lines · Trond Myklebust
Quoted 24 lines · Jeff Layton
Quoted 23 lines · On Tue, 2025-03-25 at 12:17 -0400, [email protected] wrote:

From: Trond Myklebust <[email protected]>

If a containerised process is killed and causes an ENETUNREACH or ENETDOWN error to be propagated to the state manager, then mark the nfs_client as being dead so that we don't loop in functions that are
expecting recovery to succeed.

---
 fs/nfs/nfs4state.c | 10 +++++++++-

 1 file changed, 9 insertions(+), 1 deletion(-)
fs/nfs/nfs4state.c +0 -0
index 738eb2789266..14ba3f96e6fc 100644
@@ -2739,7 +2739,15 @@ static void nfs4_state_manager(struct
 nfs_client *clp)

  pr_warn_ratelimited("NFS: state manager%s%s failed on NFSv4 server %s"
  " with error %d\n", section_sep, section, clp->cl_hostname, -status);

Quoted 8 lines

fs/nfs/nfs4state.c static void nfs4_state_manager(struct nfs_client *clp) · line 2746

Quoted 6 lines
fs/nfs/nfs4state.c +5 -1
-	ssleep(1);
+	switch (status) {
+	case -ENETDOWN:
+	case -ENETUNREACH:
+		nfs_mark_client_ready(clp, -EIO);
+		break;

Should this be conditional on clnt->cl_netunreach_fatal being true?

Quoted 3 lines

I should hope not. We shouldn't ever be seeing these errors here if it is false.

Oh right, the only way that these errors bubble up from sunrpc layer is if this option is enabled. You can add:

#14 lore raw

Concerns about ENETUNREACH patch series Re: [PATCH v2 0/4] Ensure that ENETUNREACH terminates state recovery

In reply to [email protected]
Quoted 18 lines · On Tue, 25 Mar 2025 at 17:19, <[email protected]> wrote:

From: Trond Myklebust <[email protected]>

With the recent patch series that caused containerised mounts which return ENETUNREACH or ENETDOWN errors to report fatal errors, we also want to ensure that the state manager thread also triggers fatal errors in the processes or threads that are waiting for recovery to complete.

---
v2:
- Return EIO instead of ENETUNREACH in nfs4_wait_clnt_recover()

Trond Myklebust (4):
SUNRPC: rpcbind should never reset the port to the value '0'
SUNRPC: rpc_clnt_set_transport() must not change the autobind setting
NFSv4: clp->cl_cons_state < 0 signifies an invalid nfs_client
NFSv4: Treat ENETUNREACH errors as fatal for state recovery

Quoted 4 lines
 fs/nfs/nfs4state.c     | 14 +++++++++++---
 net/sunrpc/clnt.c      |  3 ---
 net/sunrpc/rpcb_clnt.c |  5 +++--
 3 files changed, 14 insertions(+), 8 deletions(-)

1. Can this "ENETUNREACH or ENETDOWN are fatal" feature be turned off?

2. We have concerns about this feature - what will happen if a switch or router gets rebooted? What will happen if you unplug your laptop? What will happen if you enable/disable your VPN software on a machine or container? What will happen if you switch WIFIs on your laptop?

All these scenarios will trigger a temporary ENETUNREACH or ENETDOWN, and should NOT be fatal for mounts or containers.

Lionel

#15 lore raw

Re: Concerns about ENETUNREACH patch series Re: [PATCH v2 0/4] Ensure that ENETUNREACH terminates state recovery

Quoted 31 lines · Lionel Cons
Quoted 22 lines · On Tue, 25 Mar 2025 at 17:19, <[email protected]> wrote:

From: Trond Myklebust <[email protected]>

With the recent patch series that caused containerised mounts which return ENETUNREACH or ENETDOWN errors to report fatal errors, we also
want to ensure that the state manager thread also triggers fatal errors
in the processes or threads that are waiting for recovery to complete.

---
v2:
 - Return EIO instead of ENETUNREACH in nfs4_wait_clnt_recover()

Trond Myklebust (4):
  SUNRPC: rpcbind should never reset the port to the value '0'
  SUNRPC: rpc_clnt_set_transport() must not change the autobind setting
  NFSv4: clp->cl_cons_state < 0 signifies an invalid nfs_client
  NFSv4: Treat ENETUNREACH errors as fatal for state recovery

Quoted 4 lines

 fs/nfs/nfs4state.c     | 14 +++++++++++---
 net/sunrpc/clnt.c      |  3 ---
 net/sunrpc/rpcb_clnt.c |  5 +++--

 3 files changed, 14 insertions(+), 8 deletions(-)

1. Can this "ENETUNREACH or ENETDOWN are fatal" feature be turned off?

Quoted 7 lines

2. We have concerns about this feature - what will happen if a switch or router gets rebooted? What will happen if you unplug your laptop? What will happen if you enable/disable your VPN software on a machine or container? What will happen if you switch WIFIs on your laptop?

All these scenarios will trigger a temporary ENETUNREACH or ENETDOWN, and should NOT be fatal for mounts or containers.

TL;DR: Yes, you can turn it off using a mount option, but we preserve the existing hard mount behaviour unless you are actually mounting in a container.

See the description in the first series of patches:
https://lore.kernel.org/linux-nfs/[email protected]/T/#mf3df4516c5fcb0ef22c1c1c6f5433535f4d4805a

Signature · 3 lines
Trond Myklebust
Linux NFS client maintainer, Hammerspace
[email protected]