OSDN Git Service

NFSv4: Fix deadlock between nfs4_evict_inode() and nfs4_opendata_get_inode()
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Tue, 1 Jun 2021 15:10:05 +0000 (11:10 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 16 Jun 2021 09:55:01 +0000 (11:55 +0200)
commitf7d2172db8c91336937ada950c697f1e7ba48e7e
tree73bb9c1556ee3d438171de8dc67a971ec05902fd
parent4b380a7d84ef2ce3f4f5bec5d8706ed937ac6502
NFSv4: Fix deadlock between nfs4_evict_inode() and nfs4_opendata_get_inode()

[ Upstream commit dfe1fe75e00e4c724ede7b9e593f6f680e446c5f ]

If the inode is being evicted, but has to return a delegation first,
then it can cause a deadlock in the corner case where the server reboots
before the delegreturn completes, but while the call to iget5_locked() in
nfs4_opendata_get_inode() is waiting for the inode free to complete.
Since the open call still holds a session slot, the reboot recovery
cannot proceed.

In order to break the logjam, we can turn the delegation return into a
privileged operation for the case where we're evicting the inode. We
know that in that case, there can be no other state recovery operation
that conflicts.

Reported-by: zhangxiaoxu (A) <zhangxiaoxu5@huawei.com>
Fixes: 5fcdfacc01f3 ("NFSv4: Return delegations synchronously in evict_inode")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/nfs/nfs4_fs.h
fs/nfs/nfs4proc.c