Skip to content

Commit ffd1cf0

Browse files
author
Andreas Gruenbacher
committed
gfs2: Prevent inode creation race
When a request to evict an inode comes in over the network, we are trying to grab an inode reference via the iopen glock's gl_object pointer. There is a very small probability that by the time such a request comes in, inode creation hasn't completed and the I_NEW flag is still set. To deal with that, wait for the inode and then check if inode creation was successful. Signed-off-by: Andreas Gruenbacher <[email protected]>
1 parent c5b7a24 commit ffd1cf0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

fs/gfs2/glock.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,13 @@ static void gfs2_try_evict(struct gfs2_glock *gl)
982982
if (ip && !igrab(&ip->i_inode))
983983
ip = NULL;
984984
spin_unlock(&gl->gl_lockref.lock);
985+
if (ip) {
986+
wait_on_inode(&ip->i_inode);
987+
if (is_bad_inode(&ip->i_inode)) {
988+
iput(&ip->i_inode);
989+
ip = NULL;
990+
}
991+
}
985992
if (ip) {
986993
set_bit(GIF_DEFER_DELETE, &ip->i_flags);
987994
d_prune_aliases(&ip->i_inode);

0 commit comments

Comments
 (0)