]> git.baikalelectronics.ru Git - kernel.git/commit
SUNRPC: Fix the batch tasks count wraparound.
authorZhang Xiaoxu <zhangxiaoxu5@huawei.com>
Sat, 26 Jun 2021 07:50:41 +0000 (15:50 +0800)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Mon, 28 Jun 2021 13:34:39 +0000 (09:34 -0400)
commitf459d5866ed7db0a029f1299cda82d7ba154993a
tree171c63b1fab9dc492a643c6142c96b230492bae2
parent7e927a1e5f4136611c173ee8d866e3700feab927
SUNRPC: Fix the batch tasks count wraparound.

The 'queue->nr' will wraparound from 0 to 255 when only current
priority queue has tasks. This maybe lead a deadlock same as commit
e4abb4a0415e ("NFSv4: Fix deadlock between nfs4_evict_inode()
and nfs4_opendata_get_inode()"):

Privileged delegreturn task is queued to privileged list because all
the slots are assigned. When non-privileged task complete and release
the slot, a non-privileged maybe picked out. It maybe allocate slot
failed when the session on draining.

If the 'queue->nr' has wraparound to 255, and no enough slot to
service it, then the privileged delegreturn will lost to wake up.

So we should avoid the wraparound on 'queue->nr'.

Reported-by: Hulk Robot <hulkci@huawei.com>
Fixes: 348fe89b656b ("NFSv4: Return delegations synchronously in evict_inode")
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Cc: stable@vger.kernel.org
Signed-off-by: Zhang Xiaoxu <zhangxiaoxu5@huawei.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
net/sunrpc/sched.c