Skip to contentSkip to conversation

GFS2: Don't try to end a non-existent transaction in unlink

Cluster-devel Bob Peterson 2 participants 2 messages Jan 29, 2018 1 message not in the archive GFS2 file system

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

Hi,

Before this patch, if function gfs2_unlink failed to get a valid transaction (for example, not enough journal blocks) it would go to label out_end_trans which did gfs2_trans_end. But if the trans_begin failed, there's no transaction to end, and trying to do so results in: kernel BUG at fs/gfs2/trans.c:117!

This patch changes the goto so that it does not try to end a non-existent transaction.

---
 fs/gfs2/inode.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
fs/gfs2/inode.c +2 -3
index 20281992d456..59e0560180ec 100644
@@ -1152,12 +1152,11 @@ static int gfs2_unlink(struct inode *dir, struct dentry *dentry)
 
 	error = gfs2_trans_begin(sdp, 2*RES_DINODE + 3*RES_LEAF + RES_RG_BIT, 0);
 	if (error)
-		goto out_end_trans;
+		goto out_gunlock;
 
 	error = gfs2_unlink_inode(dip, dentry);
-
-out_end_trans:
 	gfs2_trans_end(sdp);
+
 out_gunlock:
 	gfs2_glock_dq(ghs + 2);
 out_rgrp:
#2 lore raw
Quoted 25 lines · Bob Peterson

Hi,

Before this patch, if function gfs2_unlink failed to get a valid transaction (for example, not enough journal blocks) it would go to label out_end_trans which did gfs2_trans_end. But if the trans_begin failed, there's no transaction to end, and trying to do so results in: kernel BUG at fs/gfs2/trans.c:117!

This patch changes the goto so that it does not try to end a non-existent transaction.

---
 fs/gfs2/inode.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
fs/gfs2/inode.c +0 -1
index 20281992d456..59e0560180ec 100644
@@ -1152,12 +1152,11 @@ static int gfs2_unlink(struct inode *dir, struct dentry *dentry)
 
        error = gfs2_trans_begin(sdp, 2*RES_DINODE + 3*RES_LEAF + RES_RG_BIT, 0);
        if (error)
-               goto out_end_trans;

fs/gfs2/inode.c static int gfs2_unlink(struct inode *dir, struct dentry *dentry) · line 1162

Quoted 10 lines
fs/gfs2/inode.c +2 -2
+               goto out_gunlock;
 
        error = gfs2_unlink_inode(dip, dentry);
-
-out_end_trans:
        gfs2_trans_end(sdp);
+
 out_gunlock:
        gfs2_glock_dq(ghs + 2);
 out_rgrp:

Confirmed.

Thanks,
Andrea