All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Whitehouse <swhiteho@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH] [GFS2] Clean up arguments to rq_mutex/rq_promote
Date: Mon, 30 Jul 2007 10:32:14 +0100	[thread overview]
Message-ID: <1185787946183-git-send-email-swhiteho@redhat.com> (raw)
In-Reply-To: <11857879381186-git-send-email-swhiteho@redhat.com>

By making the arguments to rq_mutex and rq_promote into glocks
and moving the asserts to those functions, run_queue becomes
much simpler. Also rq_mutex always returned 1, so I've changed it
to return void and it always breaks out of the loop.

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>

diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index e4bc8ae..65d6eba 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -455,18 +455,18 @@ static void wait_on_demote(struct gfs2_glock *gl)
  * Returns: 1 if the queue is blocked
  */
 
-static int rq_mutex(struct gfs2_holder *gh)
+static void rq_mutex(struct gfs2_glock *gl)
 {
-	struct gfs2_glock *gl = gh->gh_gl;
+	struct gfs2_holder *gh = list_entry(gl->gl_waiters1.next,
+					    struct gfs2_holder, gh_list);
 
+	BUG_ON(test_bit(HIF_MUTEX, &gh->gh_iflags) == 0);
 	list_del_init(&gh->gh_list);
 	/*  gh->gh_error never examined.  */
 	set_bit(GLF_LOCK, &gl->gl_flags);
 	clear_bit(HIF_WAIT, &gh->gh_iflags);
 	smp_mb();
 	wake_up_bit(&gh->gh_iflags, HIF_WAIT);
-
-	return 1;
 }
 
 /**
@@ -478,11 +478,13 @@ static int rq_mutex(struct gfs2_holder *gh)
  * Returns: 1 if the queue is blocked
  */
 
-static int rq_promote(struct gfs2_holder *gh)
+static int rq_promote(struct gfs2_glock *gl)
 {
-	struct gfs2_glock *gl = gh->gh_gl;
+	struct gfs2_holder *gh = list_entry(gl->gl_waiters3.next,
+					    struct gfs2_holder, gh_list);
 	struct gfs2_sbd *sdp = gl->gl_sbd;
 
+	BUG_ON(test_bit(HIF_PROMOTE, &gh->gh_iflags) == 0);
 	if (!relaxed_state_ok(gl->gl_state, gh->gh_state, gh->gh_flags)) {
 		if (list_empty(&gl->gl_holders)) {
 			gl->gl_req_gh = gh;
@@ -562,35 +564,21 @@ static int rq_demote(struct gfs2_glock *gl)
  */
 static void run_queue(struct gfs2_glock *gl)
 {
-	struct gfs2_holder *gh;
-	int blocked = 1;
+	int blocked;
 
 	for (;;) {
+		blocked = 1;
 		if (test_bit(GLF_LOCK, &gl->gl_flags))
 			break;
 
 		if (!list_empty(&gl->gl_waiters1)) {
-			gh = list_entry(gl->gl_waiters1.next,
-					struct gfs2_holder, gh_list);
-
-			if (test_bit(HIF_MUTEX, &gh->gh_iflags))
-				blocked = rq_mutex(gh);
-			else
-				gfs2_assert_warn(gl->gl_sbd, 0);
-
+			rq_mutex(gl);
+			break;
 		} else if (test_bit(GLF_DEMOTE, &gl->gl_flags)) {
 			blocked = rq_demote(gl);
 		} else if (!list_empty(&gl->gl_waiters3)) {
-			gh = list_entry(gl->gl_waiters3.next,
-					struct gfs2_holder, gh_list);
-
-			if (test_bit(HIF_PROMOTE, &gh->gh_iflags))
-				blocked = rq_promote(gh);
-			else
-				gfs2_assert_warn(gl->gl_sbd, 0);
-
-		} else
-			break;
+			blocked = rq_promote(gl);
+		}
 
 		if (blocked)
 			break;
-- 
1.5.1.2



  reply	other threads:[~2007-07-30  9:32 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-30  9:32 [Cluster-devel] [GFS2] Clean up glock layer Steven Whitehouse
2007-07-30  9:32 ` Steven Whitehouse [this message]
2007-07-30  9:32   ` [Cluster-devel] [PATCH] [GFS2] Clean up run_queue() Steven Whitehouse
2007-07-30  9:32     ` [Cluster-devel] [PATCH] [GFS2] Merge ->go_drop_th() with ->go_xmote_th() Steven Whitehouse
2007-07-30  9:32       ` [Cluster-devel] [PATCH] [GFS2] Merge gfs2_glock_drop_th() into gfs2_glock_xmote_th() Steven Whitehouse
2007-07-30  9:32         ` [Cluster-devel] [PATCH] [GFs2] Remove reclaim logic from rq_promote() Steven Whitehouse
2007-08-02 13:39     ` [Cluster-devel] [PATCH] [GFS2] Clean up run_queue() David Teigland

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1185787946183-git-send-email-swhiteho@redhat.com \
    --to=swhiteho@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.