NFS: avoid spurious warning of lost lock that is being unlocked.
authorNeilBrown <neilb@suse.de>
Sun, 9 Oct 2022 23:26:51 +0000 (10:26 +1100)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Tue, 6 Dec 2022 15:45:11 +0000 (10:45 -0500)
commitef8d98f20dfc79777d2b66a30926533225dc6efa
tree045d63568aabe0c9fb21918cbbe22035fe870fde
parent5559405df652008e56eee88872126fe4c451da67
NFS: avoid spurious warning of lost lock that is being unlocked.

When the NFSv4 state manager recovers state after a server restart, it
reports that locks have been lost if it finds any lock state for which
recovery hasn't been successful.  i.e. any for which
NFS_LOCK_INITIALIZED is not set.

However it only tries to recover locks that are still linked to
inode->i_flctx.  So if a lock has been removed from inode->i_flctx, but
the state for that lock has not yet been destroyed, then a spurious
warning results.

nfs4_proc_unlck() calls locks_lock_inode_wait() - which removes the lock
from ->i_flctx - before sending the unlock request to the server and
before the final nfs4_put_lock_state() is called.  This allows a window
in which a spurious warning can be produced.

So add a new flag NFS_LOCK_UNLOCKING which is set once the decision has
been made to unlock the lock.  This will prevent it from triggering any
warning.

Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
fs/nfs/nfs4_fs.h
fs/nfs/nfs4proc.c
fs/nfs/nfs4state.c