gfs2: gfs2_evict_inode clarification

When function evict_should_delete() returns SHOULD_DEFER_EVICTION, gh is
never initialized, but that isn't obvious; if it did initialize gh and
then return SHOULD_DEFER_EVICTION, gfs2_evict_inode() would fail to
release it.  To clarify the code, change gfs2_evict_inode() to always
check if gh needs to be released, no matter what evict_should_delete()
returns.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
This commit is contained in:
Andreas Gruenbacher 2024-10-04 14:10:47 +02:00
parent 70cddf16cb
commit 03ff3781bf

View File

@ -1486,6 +1486,7 @@ static void gfs2_evict_inode(struct inode *inode)
enum evict_behavior behavior;
int ret;
gfs2_holder_mark_uninitialized(&gh);
if (inode->i_nlink || sb_rdonly(sb) || !ip->i_no_addr)
goto out;
@ -1497,7 +1498,6 @@ static void gfs2_evict_inode(struct inode *inode)
if (!sdp->sd_jdesc)
goto out;
gfs2_holder_mark_uninitialized(&gh);
behavior = evict_should_delete(inode, &gh);
if (behavior == EVICT_SHOULD_DEFER_DELETE &&
!test_bit(SDF_KILL, &sdp->sd_flags)) {
@ -1516,11 +1516,11 @@ static void gfs2_evict_inode(struct inode *inode)
if (gfs2_rs_active(&ip->i_res))
gfs2_rs_deltree(&ip->i_res);
if (gfs2_holder_initialized(&gh))
gfs2_glock_dq_uninit(&gh);
if (ret && ret != GLR_TRYFAILED && ret != -EROFS)
fs_warn(sdp, "gfs2_evict_inode: %d\n", ret);
out:
if (gfs2_holder_initialized(&gh))
gfs2_glock_dq_uninit(&gh);
truncate_inode_pages_final(&inode->i_data);
if (ip->i_qadata)
gfs2_assert_warn(sdp, ip->i_qadata->qa_ref == 0);