diff options
author | Andreas Gruenbacher <agruenba@redhat.com> | 2024-11-19 12:15:26 +0100 |
---|---|---|
committer | Andreas Gruenbacher <agruenba@redhat.com> | 2024-11-19 13:05:41 +0100 |
commit | ffd1cf0443a208b80e40100ed02892d2ec74c7e9 (patch) | |
tree | 612ad531303644fcfe19cf8e142a70609f965d28 /fs/gfs2/glock.c | |
parent | c5b7a2400edc458b22133d5e5394bea26eab1923 (diff) |
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 <agruenba@redhat.com>
Diffstat (limited to 'fs/gfs2/glock.c')
-rw-r--r-- | fs/gfs2/glock.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 46a6e97cd930..8db92a36194a 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -983,6 +983,13 @@ static void gfs2_try_evict(struct gfs2_glock *gl) ip = NULL; spin_unlock(&gl->gl_lockref.lock); if (ip) { + wait_on_inode(&ip->i_inode); + if (is_bad_inode(&ip->i_inode)) { + iput(&ip->i_inode); + ip = NULL; + } + } + if (ip) { set_bit(GIF_DEFER_DELETE, &ip->i_flags); d_prune_aliases(&ip->i_inode); iput(&ip->i_inode); |