]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
gfs2: Use TRY lock in gfs2_inode_lookup for UNLINKED inodes
authorBob Peterson <rpeterso@redhat.com>
Mon, 22 Aug 2022 16:30:12 +0000 (11:30 -0500)
committerAndreas Gruenbacher <agruenba@redhat.com>
Thu, 25 Aug 2022 13:25:16 +0000 (15:25 +0200)
commitc412a97cf6c5253fcf4ae5545be5775b2417d61b
treedabfdeee2cb23ec7efeeedffcaeccf5e22c3cd2c
parent1c23f9e627a7b412978b4e852793c5e3c3efc555
gfs2: Use TRY lock in gfs2_inode_lookup for UNLINKED inodes

Before this patch, delete_work_func() would check for the GLF_DEMOTE
flag on the iopen glock and if set, it would perform special processing.
However, there was a race whereby the GLF_DEMOTE flag could be set by
another process after the check. Then when it called
gfs2_lookup_by_inum() which calls gfs2_inode_lookup(), it tried to lock
the iopen glock in SH mode, but the GLF_DEMOTE flag prevented the
request from being granted. But the iopen glock could never be demoted
because that happens when the inode is evicted, and the evict was never
completed because of the failed lookup.

To fix that, change function gfs2_inode_lookup() so that when
GFS2_BLKST_UNLINKED inodes are searched, it uses the LM_FLAG_TRY flag
for the iopen glock.  If the locking request fails, fail
gfs2_inode_lookup() with -EAGAIN so that delete_work_func() can retry
the operation later.

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