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;