linux-stable/fs/dlm
Alexander Aring 12052dce77 dlm: fix missing lkb refcount handling
commit 1689c16913 upstream.

We always call hold_lkb(lkb) if we increment lkb->lkb_wait_count.
So, we always need to call unhold_lkb(lkb) if we decrement
lkb->lkb_wait_count. This patch will add missing unhold_lkb(lkb) if we
decrement lkb->lkb_wait_count. In case of setting lkb->lkb_wait_count to
zero we need to countdown until reaching zero and call unhold_lkb(lkb).
The waiters list unhold_lkb(lkb) can be removed because it's done for
the last lkb_wait_count decrement iteration as it's done in
_remove_from_waiters().

This issue was discovered by a dlm gfs2 test case which use excessively
dlm_unlock(LKF_CANCEL) feature. Probably the lkb->lkb_wait_count value
never reached above 1 if this feature isn't used and so it was not
discovered before.

The testcase ended in a rsb on the rsb keep data structure with a
refcount of 1 but no lkb was associated with it, which is itself
an invalid behaviour. A side effect of that was a condition in which
the dlm was sending remove messages in a looping behaviour. With this
patch that has not been reproduced.

Cc: stable@vger.kernel.org
Signed-off-by: Alexander Aring <aahringo@redhat.com>
Signed-off-by: David Teigland <teigland@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-06-09 10:30:45 +02:00
..
ast.c
ast.h
config.c
config.h
debug_fs.c
dir.c
dir.h
dlm_internal.h
Kconfig
lock.c
lock.h
lockspace.c
lockspace.h
lowcomms.c
lowcomms.h
lvb_table.h
main.c
Makefile
member.c
member.h
memory.c
memory.h
midcomms.c
midcomms.h
netlink.c
plock.c
rcom.c
rcom.h
recover.c
recover.h
recoverd.c
recoverd.h
requestqueue.c
requestqueue.h
user.c
user.h
util.c
util.h