Skip to content

Commit df5db5f

Browse files
committed
gfs2: Don't demote a glock until its revokes are written
Before this patch, run_queue would demote glocks based on whether there are any more holders. But if the glock has pending revokes that haven't been written to the media, giving up the glock might end in file system corruption if the revokes never get written due to io errors, node crashes and fences, etc. In that case, another node will replay the metadata blocks associated with the glock, but because the revoke was never written, it could replay that block even though the glock had since been granted to another node who might have made changes. This patch changes the logic in run_queue so that it never demotes a glock until its count of pending revokes reaches zero. Signed-off-by: Bob Peterson <[email protected]> Reviewed-by: Andreas Gruenbacher <[email protected]>
1 parent 2ca0c2f commit df5db5f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

fs/gfs2/glock.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,9 @@ __acquires(&gl->gl_lockref.lock)
710710
goto out_unlock;
711711
if (nonblock)
712712
goto out_sched;
713+
smp_mb();
714+
if (atomic_read(&gl->gl_revokes) != 0)
715+
goto out_sched;
713716
set_bit(GLF_DEMOTE_IN_PROGRESS, &gl->gl_flags);
714717
GLOCK_BUG_ON(gl, gl->gl_demote_state == LM_ST_EXCLUSIVE);
715718
gl->gl_target = gl->gl_demote_state;

0 commit comments

Comments
 (0)