Skip to contentSkip to conversation

gfs2: if finish_open returns error, clean up iopen glock mess

PATCH New Bob Peterson 2 participants 2 messages Nov 15, 2019 GFS2 file system

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 gfs2: if finish_open returns error, clean up iopen glock mess

Hi,

Just noticed (and fixed) the redundant clear_bit. Sorry.
---
Before this patch, if anything went wrong in function gfs2_create_inode it would goto fail_gunlock3 and clean up the iopen glock it had just created and locked. However, if function finish_open returns an error it did not. That meant subsequent attempts to create the file were seen as glock recursion errors on the iopen glock.

This patch adds additional checking for an error from finish_open and cleans up the iopen glock appropriately.

---
 fs/gfs2/inode.c | 5 +++++
 1 file changed, 5 insertions(+)
fs/gfs2/inode.c +5 -0
index dcb5d363f9b9..36eb223b185e 100644
@@ -772,6 +772,11 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
 	gfs2_glock_dq_uninit(ghs);
 	gfs2_glock_dq_uninit(ghs + 1);
 	clear_bit(GLF_INODE_CREATING, &io_gl->gl_flags);
+	if (error) {
+		glock_clear_object(io_gl, ip);
+		gfs2_glock_dq_uninit(&ip->i_iopen_gh);
+		gfs2_glock_put(io_gl);
+	}
 	return error;
 
 fail_gunlock3:
#1 lore raw

PATCH v2 1/1 gfs2: if finish_open returns error, clean up iopen glock mess

Bob,

Quoted 23 lines · Bob Peterson

Just noticed (and fixed) the redundant clear_bit. Sorry.
---
Before this patch, if anything went wrong in function gfs2_create_inode it would goto fail_gunlock3 and clean up the iopen glock it had just created and locked. However, if function finish_open returns an error it did not. That meant subsequent attempts to create the file were seen as glock recursion errors on the iopen glock.

This patch adds additional checking for an error from finish_open and cleans up the iopen glock appropriately.

---
 fs/gfs2/inode.c | 5 +++++
 1 file changed, 5 insertions(+)
fs/gfs2/inode.c +0 -0
index dcb5d363f9b9..36eb223b185e 100644
@@ -772,6 +772,11 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
        gfs2_glock_dq_uninit(ghs);

fs/gfs2/inode.c static int gfs2_create_inode(struct inode *dir, struct dentry *dentry, · line 782

Quoted 10 lines
fs/gfs2/inode.c +5 -0
        gfs2_glock_dq_uninit(ghs + 1);
        clear_bit(GLF_INODE_CREATING, &io_gl->gl_flags);
+       if (error) {
+               glock_clear_object(io_gl, ip);
+               gfs2_glock_dq_uninit(&ip->i_iopen_gh);
+               gfs2_glock_put(io_gl);
+       }
        return error;
 
 fail_gunlock3:

this doesn't look quite right. In gfs2_create_inode, the call to d_instantiate is supposed to be the "point of no return": after that, the vfs should be calling .evict_inode once the inode goes away. So it looks more like gfs2_evict_inode isn't cleaning things up properly to me. I need to investigate further.

Thanks,
Andreas