linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: Anthony Iliopoulos <ailiop@suse.com>,
	Anna Schumaker <anna.schumaker@oracle.com>,
	Sasha Levin <sashal@kernel.org>,
	trondmy@kernel.org, anna@kernel.org, linux-nfs@vger.kernel.org
Subject: [PATCH AUTOSEL 6.17-5.4] NFSv4.1: fix mount hang after CREATE_SESSION failure
Date: Sat, 25 Oct 2025 11:57:32 -0400	[thread overview]
Message-ID: <20251025160905.3857885-221-sashal@kernel.org> (raw)
In-Reply-To: <20251025160905.3857885-1-sashal@kernel.org>

From: Anthony Iliopoulos <ailiop@suse.com>

[ Upstream commit bf75ad096820fee5da40e671ebb32de725a1c417 ]

When client initialization goes through server trunking discovery, it
schedules the state manager and then sleeps waiting for nfs_client
initialization completion.

The state manager can fail during state recovery, and specifically in
lease establishment as nfs41_init_clientid() will bail out in case of
errors returned from nfs4_proc_create_session(), without ever marking
the client ready. The session creation can fail for a variety of reasons
e.g. during backchannel parameter negotiation, with status -EINVAL.

The error status will propagate all the way to the nfs4_state_manager
but the client status will not be marked, and thus the mount process
will remain blocked waiting.

Fix it by adding -EINVAL error handling to nfs4_state_manager().

Signed-off-by: Anthony Iliopoulos <ailiop@suse.com>
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---

LLM Generated explanations, may be completely bogus:

YES
- Trunking discovery marks the client as `NFS_CS_SESSION_INITING`
  (`fs/nfs/nfs4client.c:391`) and the mount thread waits for
  `nfs_mark_client_ready()` to transition the state
  (`fs/nfs/client.c:376`). When `nfs4_proc_create_session()` aborts with
  `-EINVAL`—for example because the server rejects backchannel
  parameters in `nfs4_verify_back_channel_attrs()`
  (`fs/nfs/nfs4proc.c:9438`)—`nfs41_init_clientid()` returns before the
  ready-state update (`fs/nfs/nfs4state.c:332`), leaving the waiter
  blocked forever.
- The patch adds a dedicated `case -EINVAL` that forwards the failure to
  `nfs_mark_client_ready(clp, status)` (`fs/nfs/nfs4state.c:2747`,
  `fs/nfs/nfs4state.c:2748`), matching the existing handling of fatal
  network errors at `fs/nfs/nfs4state.c:2743`. This immediately wakes
  waiters so the mount fails cleanly instead of hanging.
- The bug is high-impact: affected clients hang indefinitely after
  CREATE_SESSION negotiation failures, preventing mount completion.
  Delivering the real error to user space satisfies the stable tree goal
  of fixing serious user-visible regressions.
- Risk is low: the change is limited to a single switch arm, introduces
  no new code paths on success, and relies on long-standing semantics
  that allow marking the client ready with negative states
  (`fs/nfs/client.c:458`).

- Next step: queue this fix for all supported stable NFSv4.1 branches so
  mounts no longer stall on CREATE_SESSION negotiation failures.

 fs/nfs/nfs4state.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index 7612e977e80b5..01179f7de3225 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -2744,6 +2744,9 @@ static void nfs4_state_manager(struct nfs_client *clp)
 	case -ENETUNREACH:
 		nfs_mark_client_ready(clp, -EIO);
 		break;
+	case -EINVAL:
+		nfs_mark_client_ready(clp, status);
+		break;
 	default:
 		ssleep(1);
 		break;
-- 
2.51.0


  parent reply	other threads:[~2025-10-25 16:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20251025160905.3857885-1-sashal@kernel.org>
2025-10-25 15:55 ` [PATCH AUTOSEL 6.17-5.4] nfs4_setup_readdir(): insufficient locking for ->d_parent->d_inode dereferencing Sasha Levin
2025-10-25 15:57 ` Sasha Levin [this message]
2025-10-25 15:59 ` [PATCH AUTOSEL 6.17-5.4] NFSv4: handle ERR_GRACE on delegation recalls Sasha Levin

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=20251025160905.3857885-221-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=ailiop@suse.com \
    --cc=anna.schumaker@oracle.com \
    --cc=anna@kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=patches@lists.linux.dev \
    --cc=stable@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).