Skip to content

Commit 53ce754

Browse files
Andreas Gruenbachergregkh
authored andcommitted
gfs2: Check for empty queue in run_queue
[ Upstream commit d838605 ] 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 <agruenba@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent ff11cd6 commit 53ce754

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

fs/gfs2/glock.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -843,12 +843,13 @@ static void run_queue(struct gfs2_glock *gl, const int nonblock)
843843
__releases(&gl->gl_lockref.lock)
844844
__acquires(&gl->gl_lockref.lock)
845845
{
846-
struct gfs2_holder *gh = NULL;
846+
struct gfs2_holder *gh;
847847

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

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

854855
if (test_bit(GLF_DEMOTE, &gl->gl_flags) &&
@@ -860,18 +861,22 @@ __acquires(&gl->gl_lockref.lock)
860861
set_bit(GLF_DEMOTE_IN_PROGRESS, &gl->gl_flags);
861862
GLOCK_BUG_ON(gl, gl->gl_demote_state == LM_ST_EXCLUSIVE);
862863
gl->gl_target = gl->gl_demote_state;
864+
do_xmote(gl, NULL, gl->gl_target);
865+
return;
863866
} else {
864867
if (test_bit(GLF_DEMOTE, &gl->gl_flags))
865868
gfs2_demote_wake(gl);
866869
if (do_promote(gl))
867870
goto out_unlock;
868871
gh = find_first_waiter(gl);
872+
if (!gh)
873+
goto out_unlock;
869874
gl->gl_target = gh->gh_state;
870875
if (!(gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB)))
871876
do_error(gl, 0); /* Fail queued try locks */
877+
do_xmote(gl, gh, gl->gl_target);
878+
return;
872879
}
873-
do_xmote(gl, gh, gl->gl_target);
874-
return;
875880

876881
out_sched:
877882
clear_bit(GLF_LOCK, &gl->gl_flags);

0 commit comments

Comments
 (0)