]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
NFSv4: ensure the open stateid seqid doesn't go backwards
authorScott Mayhew <smayhew@redhat.com>
Mon, 3 Nov 2025 15:44:15 +0000 (10:44 -0500)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Sun, 23 Nov 2025 20:10:08 +0000 (15:10 -0500)
commit2e47c3cc64b44b0b06cd68c2801db92ff143f2b2
tree47c1959c833c8ecf08b56406f7f1db5ed7f8cea2
parent0f900f11002ff52391fc2aa4a75e59f26ed1c242
NFSv4: ensure the open stateid seqid doesn't go backwards

We have observed an NFSv4 client receiving a LOCK reply with a status of
NFS4ERR_OLD_STATEID and subsequently retrying the LOCK request with an
earlier seqid value in the stateid.  As this was for a new lockowner,
that would imply that nfs_set_open_stateid_locked() had updated the open
stateid seqid with an earlier value.

Looking at nfs_set_open_stateid_locked(), if the incoming seqid is out
of sequence, the task will sleep on the state->waitq for up to 5
seconds.  If the task waits for the full 5 seconds, then after finishing
the wait it'll update the open stateid seqid with whatever value the
incoming seqid has.  If there are multiple waiters in this scenario,
then the last one to perform said update may not be the one with the
highest seqid.

Add a check to ensure that the seqid can only be incremented, and add a
tracepoint to indicate when old seqids are skipped.

Signed-off-by: Scott Mayhew <smayhew@redhat.com>
Reviewed-by: Benjamin Coddington <bcodding@hammerspace.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
fs/nfs/nfs4proc.c
fs/nfs/nfs4trace.h