Skip to contentSkip to conversation

gfs2: Flush glock work queue on inode lookup / create

PATCH New Andreas Gruenbacher 1 participant 1 message Oct 21, 2024 GFS2 file system

lore
Share & tools
lore

Andreas Gruenbacher

author maintainer
#0 lore raw

PATCH 1/1 gfs2: Flush glock work queue on inode lookup / create

When an inode is looked up or created, the corresponding inode glock may be in the glock cache already. In that case, the inode glock is either unlocked already, or a delayed demote request to state LM_ST_UNLOCKED from the last user of that glock must still be queued.

gfs2_inode_lookup() and gfs2_create_inode() can only deal with unlocked inode glocks, so the latter case is a problem for them. To ensure that we don't end up in that case, flush the glock work before reusing a glock. (This will have no effect in the case of new glocks.)

---
 fs/gfs2/inode.c | 4 ++++
 1 file changed, 4 insertions(+)
fs/gfs2/inode.c +4 -0
index 6fbbaaad1cd0..3396ef72413e 100644
@@ -136,6 +136,8 @@ struct inode *gfs2_inode_lookup(struct super_block *sb, unsigned int type,
 				       &ip->i_gl);
 		if (unlikely(error))
 			goto fail;
+		/* Ensure that the glock is unlocked. */
+		flush_delayed_work(&ip->i_gl->gl_work);
 
 		error = gfs2_glock_get(sdp, no_addr, &gfs2_iopen_glops, CREATE,
 				       &io_gl);
@@ -745,6 +747,8 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
 	error = gfs2_glock_get(sdp, ip->i_no_addr, &gfs2_inode_glops, CREATE, &ip->i_gl);
 	if (error)
 		goto fail_free_inode;
+	/* Ensure that the glock is unlocked. */
+	flush_delayed_work(&ip->i_gl->gl_work);
 
 	error = gfs2_glock_get(sdp, ip->i_no_addr, &gfs2_iopen_glops, CREATE, &io_gl);
 	if (error)
Signature · 1 line
2.46.2