Skip to content

Commit d838605

Browse files
author
Andreas Gruenbacher
committed
gfs2: Check for empty queue in run_queue
In run_queue(), check if the queue of pending requests is empty instead of blindly assuming that it won't be. Signed-off-by: Andreas Gruenbacher <[email protected]>
1 parent 0360fac commit d838605

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

fs/gfs2/glock.c

+8-3
Original file line numberDiff line numberDiff line change
@@ -845,12 +845,13 @@ static void run_queue(struct gfs2_glock *gl, const int nonblock)
845845
__releases(&gl->gl_lockref.lock)
846846
__acquires(&gl->gl_lockref.lock)
847847
{
848-
struct gfs2_holder *gh = NULL;
848+
struct gfs2_holder *gh;
849849

850850
if (test_bit(GLF_LOCK, &gl->gl_flags))
851851
return;
852852
set_bit(GLF_LOCK, &gl->gl_flags);
853853

854+
/* While a demote is in progress, the GLF_LOCK flag must be set. */
854855
GLOCK_BUG_ON(gl, test_bit(GLF_DEMOTE_IN_PROGRESS, &gl->gl_flags));
855856

856857
if (test_bit(GLF_DEMOTE, &gl->gl_flags) &&
@@ -862,18 +863,22 @@ __acquires(&gl->gl_lockref.lock)
862863
set_bit(GLF_DEMOTE_IN_PROGRESS, &gl->gl_flags);
863864
GLOCK_BUG_ON(gl, gl->gl_demote_state == LM_ST_EXCLUSIVE);
864865
gl->gl_target = gl->gl_demote_state;
866+
do_xmote(gl, NULL, gl->gl_target);
867+
return;
865868
} else {
866869
if (test_bit(GLF_DEMOTE, &gl->gl_flags))
867870
gfs2_demote_wake(gl);
868871
if (do_promote(gl))
869872
goto out_unlock;
870873
gh = find_first_waiter(gl);
874+
if (!gh)
875+
goto out_unlock;
871876
gl->gl_target = gh->gh_state;
872877
if (!(gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB)))
873878
do_error(gl, 0); /* Fail queued try locks */
879+
do_xmote(gl, gh, gl->gl_target);
880+
return;
874881
}
875-
do_xmote(gl, gh, gl->gl_target);
876-
return;
877882

878883
out_sched:
879884
clear_bit(GLF_LOCK, &gl->gl_flags);

0 commit comments

Comments
 (0)