Skip to content

Commit 5e33199

Browse files
author
Andreas Gruenbacher
committed
gfs2: run_queue cleanup
In run_queue(), instead of always setting the GLF_LOCK flag, only set it when the flag is actually needed. This avoids having to undo the flag setting later. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
1 parent 11d763f commit 5e33199

1 file changed

Lines changed: 7 additions & 13 deletions

File tree

fs/gfs2/glock.c

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -753,13 +753,10 @@ __acquires(&gl->gl_lockref.lock)
753753

754754
if (test_bit(GLF_LOCK, &gl->gl_flags))
755755
return;
756-
set_bit(GLF_LOCK, &gl->gl_flags);
757756

758757
/*
759-
* The GLF_DEMOTE_IN_PROGRESS flag is only set intermittently during
760-
* locking operations. We have just started a locking operation by
761-
* setting the GLF_LOCK flag, so the GLF_DEMOTE_IN_PROGRESS flag must
762-
* be cleared.
758+
* The GLF_DEMOTE_IN_PROGRESS flag must only be set when the GLF_LOCK
759+
* flag is set as well.
763760
*/
764761
GLOCK_BUG_ON(gl, test_bit(GLF_DEMOTE_IN_PROGRESS, &gl->gl_flags));
765762

@@ -770,39 +767,36 @@ __acquires(&gl->gl_lockref.lock)
770767
}
771768

772769
if (find_first_holder(gl))
773-
goto out_unlock;
770+
return;
774771
if (nonblock)
775772
goto out_sched;
776773
set_bit(GLF_DEMOTE_IN_PROGRESS, &gl->gl_flags);
777774
GLOCK_BUG_ON(gl, gl->gl_demote_state == LM_ST_EXCLUSIVE);
778775
gl->gl_target = gl->gl_demote_state;
776+
set_bit(GLF_LOCK, &gl->gl_flags);
779777
do_xmote(gl, NULL, gl->gl_target);
780778
return;
781779
}
782780

783781
promote:
784782
do_promote(gl);
785783
if (find_first_holder(gl))
786-
goto out_unlock;
784+
return;
787785
gh = find_first_waiter(gl);
788786
if (!gh)
789-
goto out_unlock;
787+
return;
790788
if (nonblock)
791789
goto out_sched;
792790
gl->gl_target = gh->gh_state;
793791
if (!(gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB)))
794792
do_error(gl, 0); /* Fail queued try locks */
793+
set_bit(GLF_LOCK, &gl->gl_flags);
795794
do_xmote(gl, gh, gl->gl_target);
796795
return;
797796

798797
out_sched:
799-
clear_bit(GLF_LOCK, &gl->gl_flags);
800798
gl->gl_lockref.count++;
801799
gfs2_glock_queue_work(gl, 0);
802-
return;
803-
804-
out_unlock:
805-
clear_bit(GLF_LOCK, &gl->gl_flags);
806800
}
807801

808802
/**

0 commit comments

Comments
 (0)