From: Jeff Layton <jlayton@kernel.org>
To: trondmy@kernel.org, linux-nfs@vger.kernel.org
Subject: Re: [PATCH 2/2] NFS: Don't allow waiting for exiting tasks
Date: Fri, 28 Mar 2025 14:23:37 -0400 [thread overview]
Message-ID: <da4e69fa55fd3ef9739383ead6774f84ac903c07.camel@kernel.org> (raw)
In-Reply-To: <f12bc922d95858ffea1649d64767f342e1a190fd.1743183579.git.trond.myklebust@hammerspace.com>
On Fri, 2025-03-28 at 13:40 -0400, trondmy@kernel.org wrote:
> From: Trond Myklebust <trond.myklebust@hammerspace.com>
>
> Once a task calls exit_signals() it can no longer be signalled. So do
> not allow it to do killable waits.
>
> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
> ---
> fs/nfs/inode.c | 2 ++
> fs/nfs/internal.h | 5 +++++
> fs/nfs/nfs3proc.c | 2 +-
> fs/nfs/nfs4proc.c | 9 +++++++--
> 4 files changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
> index 1aa67fca69b2..119e447758b9 100644
> --- a/fs/nfs/inode.c
> +++ b/fs/nfs/inode.c
> @@ -74,6 +74,8 @@ nfs_fattr_to_ino_t(struct nfs_fattr *fattr)
>
> int nfs_wait_bit_killable(struct wait_bit_key *key, int mode)
> {
> + if (unlikely(nfs_current_task_exiting()))
> + return -EINTR;
> schedule();
> if (signal_pending_state(mode, current))
> return -ERESTARTSYS;
> diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
> index fae2c7ae4acc..2133b3c20bad 100644
> --- a/fs/nfs/internal.h
> +++ b/fs/nfs/internal.h
> @@ -912,6 +912,11 @@ static inline u32 nfs_stateid_hash(nfs4_stateid *stateid)
> }
> #endif
>
> +static inline bool nfs_current_task_exiting(void)
> +{
> + return (current->flags & PF_EXITING) != 0;
> +}
> +
> static inline bool nfs_error_is_fatal(int err)
> {
> switch (err) {
> diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c
> index 0c3bc98cd999..c1736dbb92b6 100644
> --- a/fs/nfs/nfs3proc.c
> +++ b/fs/nfs/nfs3proc.c
> @@ -39,7 +39,7 @@ nfs3_rpc_wrapper(struct rpc_clnt *clnt, struct rpc_message *msg, int flags)
> __set_current_state(TASK_KILLABLE|TASK_FREEZABLE_UNSAFE);
> schedule_timeout(NFS_JUKEBOX_RETRY_TIME);
> res = -ERESTARTSYS;
> - } while (!fatal_signal_pending(current));
> + } while (!fatal_signal_pending(current) && !nfs_current_task_exiting());
> return res;
> }
>
> diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
> index 50be54e0f578..da97f87ecaa9 100644
> --- a/fs/nfs/nfs4proc.c
> +++ b/fs/nfs/nfs4proc.c
> @@ -446,6 +446,8 @@ static int nfs4_delay_killable(long *timeout)
> {
> might_sleep();
>
> + if (unlikely(nfs_current_task_exiting()))
> + return -EINTR;
> __set_current_state(TASK_KILLABLE|TASK_FREEZABLE_UNSAFE);
> schedule_timeout(nfs4_update_delay(timeout));
> if (!__fatal_signal_pending(current))
> @@ -457,6 +459,8 @@ static int nfs4_delay_interruptible(long *timeout)
> {
> might_sleep();
>
> + if (unlikely(nfs_current_task_exiting()))
> + return -EINTR;
> __set_current_state(TASK_INTERRUPTIBLE|TASK_FREEZABLE_UNSAFE);
> schedule_timeout(nfs4_update_delay(timeout));
> if (!signal_pending(current))
> @@ -1777,7 +1781,8 @@ static void nfs_set_open_stateid_locked(struct nfs4_state *state,
> rcu_read_unlock();
> trace_nfs4_open_stateid_update_wait(state->inode, stateid, 0);
>
> - if (!fatal_signal_pending(current)) {
> + if (!fatal_signal_pending(current) &&
> + !nfs_current_task_exiting()) {
> if (schedule_timeout(5*HZ) == 0)
> status = -EAGAIN;
> else
> @@ -3581,7 +3586,7 @@ static bool nfs4_refresh_open_old_stateid(nfs4_stateid *dst,
> write_sequnlock(&state->seqlock);
> trace_nfs4_close_stateid_update_wait(state->inode, dst, 0);
>
> - if (fatal_signal_pending(current))
> + if (fatal_signal_pending(current) || nfs_current_task_exiting())
> status = -EINTR;
> else
> if (schedule_timeout(5*HZ) != 0)
Reviewed-by: Jeff Layton <jlayton@kernel.org>
next prev parent reply other threads:[~2025-03-28 18:23 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-28 17:40 [PATCH 1/2] SUNRPC: Don't allow waiting for exiting tasks trondmy
2025-03-28 17:40 ` [PATCH 2/2] NFS: " trondmy
2025-03-28 18:23 ` Jeff Layton [this message]
2025-03-28 17:53 ` [PATCH 1/2] SUNRPC: " Jeff Layton
2025-03-28 18:00 ` Trond Myklebust
2025-03-28 18:09 ` Jeff Layton
2025-03-28 19:36 ` Trond Myklebust
2025-04-08 10:31 ` Mark Brown
2025-07-23 7:02 ` Harshvardhan Jha
2025-07-23 8:07 ` NeilBrown
2025-07-25 11:59 ` Harshvardhan Jha
2025-07-27 4:50 ` NeilBrown
2025-07-28 8:07 ` Harshvardhan Jha
2025-07-28 9:34 ` NeilBrown
2025-08-04 7:45 ` Harshvardhan Jha
2025-08-06 5:47 ` Harshvardhan Jha
2025-08-19 10:06 ` Harshvardhan Jha
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=da4e69fa55fd3ef9739383ead6774f84ac903c07.camel@kernel.org \
--to=jlayton@kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=trondmy@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).