Linux NFS development
 help / color / mirror / Atom feed
* [PATCH] sunrpc: don't fail immediately in rpc_wait_bit_killable()
@ 2025-08-19 21:38 NeilBrown
  2025-08-28 12:42 ` Harshvardhan Jha
  0 siblings, 1 reply; 7+ messages in thread
From: NeilBrown @ 2025-08-19 21:38 UTC (permalink / raw)
  To: Trond Myklebust, Anna Schumaker; +Cc: Harshvardhan Jha, Mark Brown, linux-nfs


rpc_wait_bit_killable() is called when it is appropriate for a fatal
signal to abort the wait.

If it is called late during process exit after exit_signals() is called
(and when PF_EXITING is set), it cannot receive a fatal signal so
waiting indefinitely is not safe.

However aborting immediately, as it currently does, is not ideal as it
mean that the related NFS request cannot succeed, even if the network
and server are working properly.

One of the causes of filesystem IO when PF_EXITING is set is
acct_process() which may access the process accounting file.  For a
NFS-root configuration, this can be accessed over NFS.

In this configuration LTP test "acct02" fails.

Though waiting indefinitely is not appropriate, aborting immediately is
also not desirable.  This patch aims for a middle ground of waiting at
most 5 seconds.  This should be enough when NFS service is working, but
not so much as to delay process exit excessively when NFS service is not
functioning.

Reported-by: Mark Brown <broonie@kernel.org>
Reported-and-tested-by: Harshvardhan Jha <harshvardhan.j.jha@oracle.com>
Link: https://lore.kernel.org/linux-nfs/7d4d57b0-39a3-49f1-8ada-60364743e3b4@sirena.org.uk/
Fixes: 14e41b16e8cb ("SUNRPC: Don't allow waiting for exiting tasks")
Signed-off-by: NeilBrown <neil@brown.name>
---
 net/sunrpc/sched.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
index 73bc39281ef5..92f39e828fbe 100644
--- a/net/sunrpc/sched.c
+++ b/net/sunrpc/sched.c
@@ -276,11 +276,15 @@ EXPORT_SYMBOL_GPL(rpc_destroy_wait_queue);
 
 static int rpc_wait_bit_killable(struct wait_bit_key *key, int mode)
 {
-	if (unlikely(current->flags & PF_EXITING))
-		return -EINTR;
-	schedule();
-	if (signal_pending_state(mode, current))
-		return -ERESTARTSYS;
+	if (unlikely(current->flags & PF_EXITING)) {
+		/* Cannot be killed by a signal, so don't wait indefinitely */
+		if (schedule_timeout(5 * HZ) == 0)
+			return -EINTR;
+	} else {
+		schedule();
+		if (signal_pending_state(mode, current))
+			return -ERESTARTSYS;
+	}
 	return 0;
 }
 
-- 
2.50.0.107.gf914562f5916.dirty


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-09-05 23:16 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-19 21:38 [PATCH] sunrpc: don't fail immediately in rpc_wait_bit_killable() NeilBrown
2025-08-28 12:42 ` Harshvardhan Jha
2025-08-28 13:10   ` Trond Myklebust
2025-08-29  1:04     ` NeilBrown
2025-09-05 19:38   ` Trond Myklebust
2025-09-05 22:45     ` NeilBrown
2025-09-05 23:16       ` Trond Myklebust

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox