Skip to content

Commit 2045364

Browse files
author
Andreas Gruenbacher
committed
gfs2: Simplify do_promote
While not immediately obvious, do_promote() returns whether or not there are any active holders in the queue. But the function description is confusing, and this information is easy to come by for callers anyway, so turn do_promote() into a void function. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> Reviewed-by: Andrew Price <anprice@redhat.com>
1 parent bddb53b commit 2045364

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

fs/gfs2/glock.c

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -481,11 +481,9 @@ int gfs2_instantiate(struct gfs2_holder *gh)
481481
/**
482482
* do_promote - promote as many requests as possible on the current queue
483483
* @gl: The glock
484-
*
485-
* Returns true on success (i.e., progress was made or there are no waiters).
486484
*/
487485

488-
static bool do_promote(struct gfs2_glock *gl)
486+
static void do_promote(struct gfs2_glock *gl)
489487
{
490488
struct gfs2_holder *gh, *current_gh;
491489

@@ -496,13 +494,10 @@ static bool do_promote(struct gfs2_glock *gl)
496494
if (!may_grant(gl, current_gh, gh)) {
497495
/*
498496
* If we get here, it means we may not grant this
499-
* holder for some reason. If this holder is at the
500-
* head of the list, it means we have a blocked holder
501-
* at the head, so return false.
497+
* holder for some reason.
502498
*/
503-
if (list_is_first(&gh->gh_list, &gl->gl_holders))
504-
return false;
505-
do_error(gl, 0); /* Fail queued try locks */
499+
if (current_gh)
500+
do_error(gl, 0); /* Fail queued try locks */
506501
break;
507502
}
508503
set_bit(HIF_HOLDER, &gh->gh_iflags);
@@ -511,7 +506,6 @@ static bool do_promote(struct gfs2_glock *gl)
511506
if (!current_gh)
512507
current_gh = gh;
513508
}
514-
return true;
515509
}
516510

517511
/**
@@ -855,7 +849,8 @@ __acquires(&gl->gl_lockref.lock)
855849
} else {
856850
if (test_bit(GLF_DEMOTE, &gl->gl_flags))
857851
gfs2_demote_wake(gl);
858-
if (do_promote(gl))
852+
do_promote(gl);
853+
if (find_first_holder(gl))
859854
goto out_unlock;
860855
gh = find_first_waiter(gl);
861856
if (!gh)

0 commit comments

Comments
 (0)