Skip to contentSkip to conversation

gfs2: fix glock reference problem in gfs2_trans_add_unrevoke

PATCH New Bob Peterson 1 participant 1 message Nov 14, 2019 1 message not in the archive GFS2 file system

lore
Share & tools
lore
#1 lore raw

PATCH 1/1 gfs2: fix glock reference problem in gfs2_trans_add_unrevoke

In reply to a message not in the archive

Hi,

Patch 9287c6452d2 fixed a situation in which gfs2 could use a glock after it had been freed. To fix that, it temporarily added a new glock reference by calling gfs2_glock_hold in function gfs2_add_revoke. However, if the bd element was removed by gfs2_trans_add_unrevoke it failed to drop the additional reference.

This patch adds logic to gfs2_trans_add_unrevoke so that it can properly drop the additional glock reference.

Fixes 9287c6452d2b1f24ea8e84bd3cf6f3c6f267f712
Cc stable at vger.kernel.org # v5.2+
---
 fs/gfs2/trans.c | 5 +++++
 1 file changed, 5 insertions(+)
fs/gfs2/trans.c +5 -0
index 35e3059255fe..0eb3c5198c2b 100644
@@ -262,6 +262,11 @@ void gfs2_trans_remove_revoke(struct gfs2_sbd *sdp, u64 blkno, unsigned int len)
 			list_del_init(&bd->bd_list);
 			gfs2_assert_withdraw(sdp, sdp->sd_log_num_revoke);
 			sdp->sd_log_num_revoke--;
+			if (bd->bd_gl &&
+			    atomic_dec_return(&bd->bd_gl->gl_revokes) == 0) {
+				clear_bit(GLF_LFLUSH, &bd->bd_gl->gl_flags);
+				gfs2_glock_queue_put(bd->bd_gl);
+			}
 			kmem_cache_free(gfs2_bufdata_cachep, bd);
 			tr->tr_num_revoke--;
 			if (--n == 0)