From: Steven Whitehouse <swhiteho@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH] [GFS2] Merge gfs2_glock_drop_th() into gfs2_glock_xmote_th()
Date: Mon, 30 Jul 2007 10:32:17 +0100 [thread overview]
Message-ID: <11857879512912-git-send-email-swhiteho@redhat.com> (raw)
In-Reply-To: <11857879493817-git-send-email-swhiteho@redhat.com>
These two functions were very similar in form. After the previous
patch its fairly easy to merge them. Also there was some left
over code in drop_bh() which was unused since we no longer use
gfs2_holder structures for "drop"s.
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index dd23ab1..6324f57 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -55,7 +55,6 @@ typedef void (*glock_examiner) (struct gfs2_glock * gl);
static int gfs2_dump_lockstate(struct gfs2_sbd *sdp);
static int dump_glock(struct glock_iter *gi, struct gfs2_glock *gl);
static void gfs2_glock_xmote_th(struct gfs2_glock *gl, struct gfs2_holder *gh);
-static void gfs2_glock_drop_th(struct gfs2_glock *gl);
static DECLARE_RWSEM(gfs2_umount_flush_sem);
static struct dentry *gfs2_root;
@@ -544,16 +543,9 @@ static int rq_demote(struct gfs2_glock *gl)
return 0;
}
set_bit(GLF_LOCK, &gl->gl_flags);
- if (gl->gl_demote_state == LM_ST_UNLOCKED ||
- gl->gl_state != LM_ST_EXCLUSIVE) {
- spin_unlock(&gl->gl_spin);
- gfs2_glock_drop_th(gl);
- } else {
- spin_unlock(&gl->gl_spin);
- gfs2_glock_xmote_th(gl, NULL);
- }
+ spin_unlock(&gl->gl_spin);
+ gfs2_glock_xmote_th(gl, NULL);
spin_lock(&gl->gl_spin);
-
return 0;
}
@@ -750,7 +742,7 @@ static void xmote_bh(struct gfs2_glock *gl, unsigned int ret)
if (gl->gl_state != gl->gl_demote_state) {
gl->gl_req_bh = NULL;
spin_unlock(&gl->gl_spin);
- gfs2_glock_drop_th(gl);
+ gfs2_glock_xmote_th(gl, NULL);
gfs2_glock_put(gl);
return;
}
@@ -803,47 +795,6 @@ out:
}
/**
- * gfs2_glock_xmote_th - Call into the lock module to acquire or change a glock
- * @gl: The glock in question
- * @state: the requested state
- * @flags: modifier flags to the lock call
- *
- */
-
-static void gfs2_glock_xmote_th(struct gfs2_glock *gl, struct gfs2_holder *gh)
-{
- struct gfs2_sbd *sdp = gl->gl_sbd;
- int flags = gh ? gh->gh_flags : 0;
- unsigned state = gh ? gh->gh_state : gl->gl_demote_state;
- const struct gfs2_glock_operations *glops = gl->gl_ops;
- int lck_flags = flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB |
- LM_FLAG_NOEXP | LM_FLAG_ANY |
- LM_FLAG_PRIORITY);
- unsigned int lck_ret;
-
- if (glops->go_xmote_th)
- glops->go_xmote_th(gl, state);
-
- gfs2_assert_warn(sdp, test_bit(GLF_LOCK, &gl->gl_flags));
- gfs2_assert_warn(sdp, list_empty(&gl->gl_holders));
- gfs2_assert_warn(sdp, state != LM_ST_UNLOCKED);
- gfs2_assert_warn(sdp, state != gl->gl_state);
-
- gfs2_glock_hold(gl);
- gl->gl_req_bh = xmote_bh;
-
- lck_ret = gfs2_lm_lock(sdp, gl->gl_lock, gl->gl_state, state, lck_flags);
-
- if (gfs2_assert_withdraw(sdp, !(lck_ret & LM_OUT_ERROR)))
- return;
-
- if (lck_ret & LM_OUT_ASYNC)
- gfs2_assert_warn(sdp, lck_ret == LM_OUT_ASYNC);
- else
- xmote_bh(gl, lck_ret);
-}
-
-/**
* drop_bh - Called after a lock module unlock completes
* @gl: the glock
* @ret: the return status
@@ -857,7 +808,6 @@ static void drop_bh(struct gfs2_glock *gl, unsigned int ret)
{
struct gfs2_sbd *sdp = gl->gl_sbd;
const struct gfs2_glock_operations *glops = gl->gl_ops;
- struct gfs2_holder *gh = gl->gl_req_gh;
gfs2_assert_warn(sdp, test_bit(GLF_LOCK, &gl->gl_flags));
gfs2_assert_warn(sdp, list_empty(&gl->gl_holders));
@@ -869,57 +819,59 @@ static void drop_bh(struct gfs2_glock *gl, unsigned int ret)
if (glops->go_inval)
glops->go_inval(gl, DIO_METADATA);
- if (gh) {
- spin_lock(&gl->gl_spin);
- list_del_init(&gh->gh_list);
- gh->gh_error = 0;
- spin_unlock(&gl->gl_spin);
- }
-
spin_lock(&gl->gl_spin);
- gl->gl_req_gh = NULL;
gl->gl_req_bh = NULL;
clear_bit(GLF_LOCK, &gl->gl_flags);
run_queue(gl);
spin_unlock(&gl->gl_spin);
gfs2_glock_put(gl);
-
- if (gh)
- gfs2_holder_wake(gh);
}
/**
- * gfs2_glock_drop_th - call into the lock module to unlock a lock
- * @gl: the glock
+ * gfs2_glock_xmote_th - Call into the lock module to acquire or change a glock
+ * @gl: The glock in question
+ * @state: the requested state
+ * @flags: modifier flags to the lock call
*
*/
-static void gfs2_glock_drop_th(struct gfs2_glock *gl)
+static void gfs2_glock_xmote_th(struct gfs2_glock *gl, struct gfs2_holder *gh)
{
struct gfs2_sbd *sdp = gl->gl_sbd;
+ int flags = gh ? gh->gh_flags : 0;
+ unsigned state = gh ? gh->gh_state : gl->gl_demote_state;
const struct gfs2_glock_operations *glops = gl->gl_ops;
- unsigned int ret;
+ int lck_flags = flags & (LM_FLAG_TRY | LM_FLAG_TRY_1CB |
+ LM_FLAG_NOEXP | LM_FLAG_ANY |
+ LM_FLAG_PRIORITY);
+ unsigned int lck_ret;
if (glops->go_xmote_th)
- glops->go_xmote_th(gl, LM_ST_UNLOCKED);
+ glops->go_xmote_th(gl, state);
gfs2_assert_warn(sdp, test_bit(GLF_LOCK, &gl->gl_flags));
gfs2_assert_warn(sdp, list_empty(&gl->gl_holders));
- gfs2_assert_warn(sdp, gl->gl_state != LM_ST_UNLOCKED);
+ gfs2_assert_warn(sdp, state != gl->gl_state);
gfs2_glock_hold(gl);
- gl->gl_req_bh = drop_bh;
+ if (state != LM_ST_UNLOCKED) {
+ gl->gl_req_bh = xmote_bh;
+ lck_ret = gfs2_lm_lock(sdp, gl->gl_lock, gl->gl_state, state, lck_flags);
+ } else {
+ gl->gl_req_bh = drop_bh;
+ lck_ret = gfs2_lm_unlock(sdp, gl->gl_lock, gl->gl_state);
+ }
- ret = gfs2_lm_unlock(sdp, gl->gl_lock, gl->gl_state);
+ if (gfs2_assert_withdraw(sdp, !(lck_ret & LM_OUT_ERROR)))
+ return;
- if (gfs2_assert_withdraw(sdp, !(ret & LM_OUT_ERROR)))
+ if ((lck_ret & LM_OUT_ASYNC) == 0) {
+ gl->gl_req_bh(gl, lck_ret);
return;
+ }
- if (!ret)
- drop_bh(gl, ret);
- else
- gfs2_assert_warn(sdp, ret == LM_OUT_ASYNC);
+ BUG_ON(lck_ret != LM_OUT_ASYNC);
}
/**
--
1.5.1.2
next prev parent 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 ` [Cluster-devel] [PATCH] [GFS2] Clean up arguments to rq_mutex/rq_promote Steven Whitehouse
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 ` Steven Whitehouse [this message]
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=11857879512912-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).