Commit e5dc76b9 authored by Bob Peterson's avatar Bob Peterson Committed by Steven Whitehouse

GFS2: Eliminate redundant calls to may_grant

Function add_to_queue was checking may_grant for the passed-in
holder for every iteration of its gh2 loop. Now it only checks it
once at the beginning to see if a try lock is futile.
Signed-off-by: default avatarBob Peterson <rpeterso@redhat.com>
Signed-off-by: default avatarSteven Whitehouse <swhiteho@redhat.com>
parent 81e1d450
...@@ -954,7 +954,7 @@ __acquires(&gl->gl_spin) ...@@ -954,7 +954,7 @@ __acquires(&gl->gl_spin)
struct gfs2_sbd *sdp = gl->gl_sbd; struct gfs2_sbd *sdp = gl->gl_sbd;
struct list_head *insert_pt = NULL; struct list_head *insert_pt = NULL;
struct gfs2_holder *gh2; struct gfs2_holder *gh2;
int try_lock = 0; int try_futile = 0;
BUG_ON(gh->gh_owner_pid == NULL); BUG_ON(gh->gh_owner_pid == NULL);
if (test_and_set_bit(HIF_WAIT, &gh->gh_iflags)) if (test_and_set_bit(HIF_WAIT, &gh->gh_iflags))
...@@ -962,7 +962,7 @@ __acquires(&gl->gl_spin) ...@@ -962,7 +962,7 @@ __acquires(&gl->gl_spin)
if (gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB)) { if (gh->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB)) {
if (test_bit(GLF_LOCK, &gl->gl_flags)) if (test_bit(GLF_LOCK, &gl->gl_flags))
try_lock = 1; try_futile = !may_grant(gl, gh);
if (test_bit(GLF_INVALIDATE_IN_PROGRESS, &gl->gl_flags)) if (test_bit(GLF_INVALIDATE_IN_PROGRESS, &gl->gl_flags))
goto fail; goto fail;
} }
...@@ -971,9 +971,8 @@ __acquires(&gl->gl_spin) ...@@ -971,9 +971,8 @@ __acquires(&gl->gl_spin)
if (unlikely(gh2->gh_owner_pid == gh->gh_owner_pid && if (unlikely(gh2->gh_owner_pid == gh->gh_owner_pid &&
(gh->gh_gl->gl_ops->go_type != LM_TYPE_FLOCK))) (gh->gh_gl->gl_ops->go_type != LM_TYPE_FLOCK)))
goto trap_recursive; goto trap_recursive;
if (try_lock && if (try_futile &&
!(gh2->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB)) && !(gh2->gh_flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB))) {
!may_grant(gl, gh)) {
fail: fail:
gh->gh_error = GLR_TRYFAILED; gh->gh_error = GLR_TRYFAILED;
gfs2_holder_wake(gh); gfs2_holder_wake(gh);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment