gfs2: further simplify do_promote
This patch further simplifies function do_promote by eliminating some redundant code in favor of using a lock_released flag. This is just prep work for a future patch. Signed-off-by: Bob Peterson <rpeterso@redhat.com> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
This commit is contained in:
committed by
Andreas Gruenbacher
parent
17a6eceeb1
commit
60d8bae9d1
@@ -487,12 +487,14 @@ __acquires(&gl->gl_lockref.lock)
|
|||||||
const struct gfs2_glock_operations *glops = gl->gl_ops;
|
const struct gfs2_glock_operations *glops = gl->gl_ops;
|
||||||
struct gfs2_holder *gh, *tmp, *first_gh;
|
struct gfs2_holder *gh, *tmp, *first_gh;
|
||||||
bool incompat_holders_demoted = false;
|
bool incompat_holders_demoted = false;
|
||||||
|
bool lock_released;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
restart:
|
restart:
|
||||||
first_gh = find_first_strong_holder(gl);
|
first_gh = find_first_strong_holder(gl);
|
||||||
list_for_each_entry_safe(gh, tmp, &gl->gl_holders, gh_list) {
|
list_for_each_entry_safe(gh, tmp, &gl->gl_holders, gh_list) {
|
||||||
if (!test_bit(HIF_WAIT, &gh->gh_iflags))
|
lock_released = false;
|
||||||
|
if (test_bit(HIF_HOLDER, &gh->gh_iflags))
|
||||||
continue;
|
continue;
|
||||||
if (!may_grant(gl, first_gh, gh)) {
|
if (!may_grant(gl, first_gh, gh)) {
|
||||||
/*
|
/*
|
||||||
@@ -511,10 +513,9 @@ restart:
|
|||||||
first_gh = gh;
|
first_gh = gh;
|
||||||
}
|
}
|
||||||
if (gh->gh_list.prev == &gl->gl_holders &&
|
if (gh->gh_list.prev == &gl->gl_holders &&
|
||||||
glops->go_instantiate) {
|
!(gh->gh_flags & GL_SKIP) && glops->go_instantiate) {
|
||||||
if (!(gh->gh_flags & GL_SKIP)) {
|
lock_released = true;
|
||||||
spin_unlock(&gl->gl_lockref.lock);
|
spin_unlock(&gl->gl_lockref.lock);
|
||||||
/* FIXME: eliminate this eventually */
|
|
||||||
ret = glops->go_instantiate(gh);
|
ret = glops->go_instantiate(gh);
|
||||||
spin_lock(&gl->gl_lockref.lock);
|
spin_lock(&gl->gl_lockref.lock);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
@@ -530,12 +531,14 @@ restart:
|
|||||||
set_bit(HIF_HOLDER, &gh->gh_iflags);
|
set_bit(HIF_HOLDER, &gh->gh_iflags);
|
||||||
trace_gfs2_promote(gh);
|
trace_gfs2_promote(gh);
|
||||||
gfs2_holder_wake(gh);
|
gfs2_holder_wake(gh);
|
||||||
|
/*
|
||||||
|
* If we released the gl_lockref.lock the holders list may have
|
||||||
|
* changed. For that reason, we start again at the start of
|
||||||
|
* the holders queue.
|
||||||
|
*/
|
||||||
|
if (lock_released)
|
||||||
goto restart;
|
goto restart;
|
||||||
}
|
}
|
||||||
set_bit(HIF_HOLDER, &gh->gh_iflags);
|
|
||||||
trace_gfs2_promote(gh);
|
|
||||||
gfs2_holder_wake(gh);
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user