gfs2: Make glock lru list scanning safer
authorAndreas Gruenbacher <agruenba@redhat.com>
Sat, 10 Dec 2022 01:21:32 +0000 (02:21 +0100)
committerAndreas Gruenbacher <agruenba@redhat.com>
Tue, 31 Jan 2023 21:40:24 +0000 (22:40 +0100)
commit228804a35caa7edae4a81049281e7f106dea1ad1
treec1705faf952d80a9fcb6682accb0ebdbdb666148
parent8fb8f70ec71eb5ca51ecbfc2303523ff836648db
gfs2: Make glock lru list scanning safer

In __gfs2_glock_put(), remove the glock from the lru list *after*
dropping the glock lock.  This prevents deadlocks against
gfs2_scan_glock_lru().

In gfs2_scan_glock_lru(), make sure that the glock's reference count is
zero before moving the glock to the dispose list.  This skips glocks
that are marked dead as well as glocks that are still in use.
Additionally, switch to spin_trylock() as we already do in
gfs2_dispose_glock_lru(); this alone would also be enough to prevent
deadlocks against __gfs2_glock_put().

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
fs/gfs2/glock.c