summaryrefslogtreecommitdiff
path: root/fs/gfs2/glock.c
diff options
context:
space:
mode:
authorBob Peterson <rpeterso@redhat.com>2021-10-06 07:35:04 -0500
committerAndreas Gruenbacher <agruenba@redhat.com>2021-10-25 08:42:19 +0200
commit17a6eceeb1c54a0a4af5b03ccc1de7ab824408bc (patch)
treebfb25fba798beee2616deab77d179b52743f61c1 /fs/gfs2/glock.c
parentd74d0ce5bcd61a1cadb8e6ae3ec23c29b2288b37 (diff)
downloadlinux-riscv-17a6eceeb1c54a0a4af5b03ccc1de7ab824408bc.tar.gz
linux-riscv-17a6eceeb1c54a0a4af5b03ccc1de7ab824408bc.tar.bz2
linux-riscv-17a6eceeb1c54a0a4af5b03ccc1de7ab824408bc.zip
gfs2: re-factor function do_promote
This patch simply re-factors function do_promote to reduce the indents. The logic should be unchanged. This makes future patches more readable. Signed-off-by: Bob Peterson <rpeterso@redhat.com> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Diffstat (limited to 'fs/gfs2/glock.c')
-rw-r--r--fs/gfs2/glock.c71
1 files changed, 35 insertions, 36 deletions
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index a5e197423460..f9aebeba7454 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -494,48 +494,47 @@ restart:
list_for_each_entry_safe(gh, tmp, &gl->gl_holders, gh_list) {
if (!test_bit(HIF_WAIT, &gh->gh_iflags))
continue;
- if (may_grant(gl, first_gh, gh)) {
- if (!incompat_holders_demoted) {
- demote_incompat_holders(gl, first_gh);
- incompat_holders_demoted = true;
- first_gh = gh;
- }
- if (gh->gh_list.prev == &gl->gl_holders &&
- glops->go_instantiate) {
- if (!(gh->gh_flags & GL_SKIP)) {
- spin_unlock(&gl->gl_lockref.lock);
- /* FIXME: eliminate this eventually */
- ret = glops->go_instantiate(gh);
- spin_lock(&gl->gl_lockref.lock);
- if (ret) {
- if (ret == 1)
- return 2;
- gh->gh_error = ret;
- list_del_init(&gh->gh_list);
- trace_gfs2_glock_queue(gh, 0);
- gfs2_holder_wake(gh);
- goto restart;
- }
+ if (!may_grant(gl, first_gh, gh)) {
+ /*
+ * If we get here, it means we may not grant this holder for
+ * some reason. If this holder is the head of the list, it
+ * means we have a blocked holder at the head, so return 1.
+ */
+ if (gh->gh_list.prev == &gl->gl_holders)
+ return 1;
+ do_error(gl, 0);
+ break;
+ }
+ if (!incompat_holders_demoted) {
+ demote_incompat_holders(gl, first_gh);
+ incompat_holders_demoted = true;
+ first_gh = gh;
+ }
+ if (gh->gh_list.prev == &gl->gl_holders &&
+ glops->go_instantiate) {
+ if (!(gh->gh_flags & GL_SKIP)) {
+ spin_unlock(&gl->gl_lockref.lock);
+ /* FIXME: eliminate this eventually */
+ ret = glops->go_instantiate(gh);
+ spin_lock(&gl->gl_lockref.lock);
+ if (ret) {
+ if (ret == 1)
+ return 2;
+ gh->gh_error = ret;
+ list_del_init(&gh->gh_list);
+ trace_gfs2_glock_queue(gh, 0);
+ gfs2_holder_wake(gh);
+ goto restart;
}
- set_bit(HIF_HOLDER, &gh->gh_iflags);
- trace_gfs2_promote(gh);
- gfs2_holder_wake(gh);
- goto restart;
}
set_bit(HIF_HOLDER, &gh->gh_iflags);
trace_gfs2_promote(gh);
gfs2_holder_wake(gh);
- continue;
+ goto restart;
}
- /*
- * If we get here, it means we may not grant this holder for
- * some reason. If this holder is the head of the list, it
- * means we have a blocked holder at the head, so return 1.
- */
- if (gh->gh_list.prev == &gl->gl_holders)
- return 1;
- do_error(gl, 0);
- break;
+ set_bit(HIF_HOLDER, &gh->gh_iflags);
+ trace_gfs2_promote(gh);
+ gfs2_holder_wake(gh);
}
return 0;
}