Skip to content

Commit 97236ad

Browse files
author
Andreas Gruenbacher
committed
gfs2: Avoid dequeuing GL_ASYNC glock holders twice
When a locking request fails, the associated glock holder is automatically dequeued from the list of active and waiting holders. For GL_ASYNC locking requests, this will obviously happen asynchronously and it can race with attempts to cancel that locking request via gfs2_glock_dq(). Therefore, don't forget to check if a locking request has already been dequeued in gfs2_glock_dq(). Signed-off-by: Andreas Gruenbacher <[email protected]>
1 parent 4ad0208 commit 97236ad

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

fs/gfs2/glock.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1707,6 +1707,13 @@ void gfs2_glock_dq(struct gfs2_holder *gh)
17071707
struct gfs2_glock *gl = gh->gh_gl;
17081708

17091709
spin_lock(&gl->gl_lockref.lock);
1710+
if (!gfs2_holder_queued(gh)) {
1711+
/*
1712+
* May have already been dequeued because the locking request
1713+
* was GL_ASYNC and it has failed in the meantime.
1714+
*/
1715+
goto out;
1716+
}
17101717
if (list_is_first(&gh->gh_list, &gl->gl_holders) &&
17111718
!test_bit(HIF_HOLDER, &gh->gh_iflags)) {
17121719
spin_unlock(&gl->gl_lockref.lock);
@@ -1716,6 +1723,7 @@ void gfs2_glock_dq(struct gfs2_holder *gh)
17161723
}
17171724

17181725
__gfs2_glock_dq(gh);
1726+
out:
17191727
spin_unlock(&gl->gl_lockref.lock);
17201728
}
17211729

0 commit comments

Comments
 (0)