>From 8f034dc615fe13618d42df62dde2137f680f218b Mon Sep 17 00:00:00 2001
From: Steven Whitehouse <[EMAIL PROTECTED]>
Date: Mon, 30 Jul 2007 20:16:38 +0100
Subject: [PATCH] [GFS2] Merge drop_bh() into xmote_bh()

The xmote_bh() function already does everything which drop_bh()
does and more. The ->go_xmote_bh() callback is protected against
this new caller since the two instances of it both check the
current state against LM_ST_UNLOCKED.

Signed-off-by: Steven Whitehouse <[EMAIL PROTECTED]>

diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index 83cd60b..d564876 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -316,7 +316,6 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
        gl->gl_ip = 0;
        gl->gl_ops = glops;
        gl->gl_req_gh = NULL;
-       gl->gl_req_bh = NULL;
        gl->gl_vn = 0;
        gl->gl_stamp = jiffies;
        gl->gl_object = NULL;
@@ -730,7 +729,6 @@ static void xmote_bh(struct gfs2_glock *gl, unsigned int 
ret)
                } else {
                        spin_lock(&gl->gl_spin);
                        if (gl->gl_state != gl->gl_demote_state) {
-                               gl->gl_req_bh = NULL;
                                spin_unlock(&gl->gl_spin);
                                gfs2_glock_xmote_th(gl, NULL);
                                gfs2_glock_put(gl);
@@ -772,7 +770,6 @@ out:
        if (op_done) {
                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);
@@ -785,40 +782,6 @@ out:
 }
 
 /**
- * drop_bh - Called after a lock module unlock completes
- * @gl: the glock
- * @ret: the return status
- *
- * Doesn't wake up the process waiting on the struct gfs2_holder (if any)
- * Doesn't drop the reference on the glock the top half took out
- *
- */
-
-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;
-
-       gfs2_assert_warn(sdp, test_bit(GLF_LOCK, &gl->gl_flags));
-       gfs2_assert_warn(sdp, list_empty(&gl->gl_holders));
-       gfs2_assert_warn(sdp, !ret);
-
-       state_change(gl, LM_ST_UNLOCKED);
-       gfs2_demote_wake(gl);
-
-       if (glops->go_inval)
-               glops->go_inval(gl, DIO_METADATA);
-
-       spin_lock(&gl->gl_spin);
-       gl->gl_req_bh = NULL;
-       clear_bit(GLF_LOCK, &gl->gl_flags);
-       run_queue(gl);
-       spin_unlock(&gl->gl_spin);
-
-       gfs2_glock_put(gl);
-}
-
-/**
  * gfs2_glock_xmote_th - Call into the lock module to acquire or change a glock
  * @gl: The glock in question
  * @state: the requested state
@@ -846,10 +809,8 @@ static void gfs2_glock_xmote_th(struct gfs2_glock *gl, 
struct gfs2_holder *gh)
 
        gfs2_glock_hold(gl);
        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);
        }
 
@@ -857,7 +818,7 @@ static void gfs2_glock_xmote_th(struct gfs2_glock *gl, 
struct gfs2_holder *gh)
                return;
 
        if ((lck_ret & LM_OUT_ASYNC) == 0) {
-               gl->gl_req_bh(gl, lck_ret);
+               xmote_bh(gl, lck_ret);
                return;
        }
 
@@ -880,7 +841,7 @@ static void do_cancels(struct gfs2_holder *gh)
        while (gl->gl_req_gh != gh &&
               !test_bit(HIF_HOLDER, &gh->gh_iflags) &&
               !list_empty(&gh->gh_list)) {
-               if (gl->gl_req_bh && !(gl->gl_req_gh &&
+               if (gl->gl_req_gh && !(gl->gl_req_gh &&
                                     (gl->gl_req_gh->gh_flags & GL_NOCANCEL))) {
                        spin_unlock(&gl->gl_spin);
                        gfs2_lm_cancel(gl->gl_sbd, gl->gl_lock);
@@ -951,7 +912,6 @@ static int glock_wait_internal(struct gfs2_holder *gh)
 
                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);
@@ -1426,8 +1386,7 @@ void gfs2_glock_cb(void *cb_data, unsigned int type, void 
*data)
                gl = gfs2_glock_find(sdp, &async->lc_name);
                if (gfs2_assert_warn(sdp, gl))
                        return;
-               if (!gfs2_assert_warn(sdp, gl->gl_req_bh))
-                       gl->gl_req_bh(gl, async->lc_ret);
+               xmote_bh(gl, async->lc_ret);
                gfs2_glock_put(gl);
                up_read(&gfs2_umount_flush_sem);
                return;
@@ -1800,7 +1759,6 @@ static int dump_glock(struct glock_iter *gi, struct 
gfs2_glock *gl)
                print_dbg(gi, "  gl_owner = -1\n");
        print_dbg(gi, "  gl_ip = %lu\n", gl->gl_ip);
        print_dbg(gi, "  req_gh = %s\n", (gl->gl_req_gh) ? "yes" : "no");
-       print_dbg(gi, "  req_bh = %s\n", (gl->gl_req_bh) ? "yes" : "no");
        print_dbg(gi, "  lvb_count = %d\n", atomic_read(&gl->gl_lvb_count));
        print_dbg(gi, "  object = %s\n", (gl->gl_object) ? "yes" : "no");
        print_dbg(gi, "  le = %s\n",
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h
index 0eca96a..cda2fba 100644
--- a/fs/gfs2/incore.h
+++ b/fs/gfs2/incore.h
@@ -26,8 +26,6 @@ struct gfs2_ail;
 struct gfs2_jdesc;
 struct gfs2_sbd;
 
-typedef void (*gfs2_glop_bh_t) (struct gfs2_glock *gl, unsigned int ret);
-
 struct gfs2_log_header_host {
        u64 lh_sequence;        /* Sequence number of this transaction */
        u32 lh_flags;           /* GFS2_LOG_HEAD_... */
@@ -183,7 +181,6 @@ struct gfs2_glock {
        const struct gfs2_glock_operations *gl_ops;
 
        struct gfs2_holder *gl_req_gh;
-       gfs2_glop_bh_t gl_req_bh;
 
        void *gl_lock;
        char *gl_lvb;
-- 
1.5.1.2



Reply via email to