Move "first lock" glops call
Hi,
Further patches in the glock cleanup series,
Steve.
From 109c714b2b66e656b0004a628239cdf571eafe46 Mon Sep 17 00:00:00 2001
From: Steven Whitehouse <[email protected]>
Date: Tue, 31 Jul 2007 16:53:31 +0100
Subject: [PATCH] [GFS2] Move "first lock" glops call
Rather than setting a flag "HIF_FIRST" for each granted lock holder that is the first one on the glock's list, and then call the ->go_lock() glops function later, in the context of the process waiting for the glock, this patch calls the ->go_lock() function directly, removing the need for the HIF_FIRST flag.
Signed-off-by Steven Whitehouse <[email protected]>
fs/gfs2/glock.c +17 -25
@@ -467,6 +467,20 @@ static void rq_mutex(struct gfs2_glock *gl)wake_up_bit (&gh->gh_iflags,HIF_WAIT ); } +static void first_holder (struct gfs2_holder *gh) +{ +struct gfs2_glock *gl = gh->gh_gl; +const struct gfs2_glock_operations *glops = gl->gl_ops; + +if (glops->go_lock) { +spin_unlock (&gl->gl_spin); + gh->gh_error = glops->go_lock (gh); +spin_lock (&gl->gl_spin); +if (gh->gh_error) +list_del_init (&gh->gh_list); + } +} +/** * rq_promote - process a promote request in the queue * @gh: the glock holder
@@ -493,8 +507,7 @@ static int rq_promote(struct gfs2_glock *gl) }if (list_empty (&gl->gl_holders)) { -set_bit (HIF_FIRST , &gh->gh_iflags); -set_bit (GLF_LOCK , &gl->gl_flags); +first_holder (gh); }else {struct gfs2_holder *next_gh;if (gh->gh_state ==LM_ST_EXCLUSIVE )
@@ -748,10 +761,9 @@ static void xmote_bh(struct gfs2_glock *gl, unsigned int ret) goto out;if (relaxed_state_ok (gl->gl_state, gh->gh_state, gh->gh_flags)) {list_add_tail (&gh->gh_list, &gl->gl_holders); - gh->gh_error =0 ;set_bit (HIF_HOLDER , &gh->gh_iflags); -set_bit (HIF_FIRST , &gh->gh_iflags); - op_done =0 ; + gh->gh_error =0 ; +first_holder (gh); goto out; } gh->gh_error =GLR_TRYFAILED ;
@@ -868,7 +880,6 @@ static int glock_wait_internal(struct gfs2_holder *gh) {struct gfs2_glock *gl = gh->gh_gl;struct gfs2_sbd *sdp = gl->gl_sbd; -const struct gfs2_glock_operations *glops = gl->gl_ops;if (test_bit (HIF_ABORTED , &gh->gh_iflags))return -EIO ;
@@ -898,25 +909,6 @@ static int glock_wait_internal(struct gfs2_holder *gh)gfs2_assert_withdraw (sdp,relaxed_state_ok (gl->gl_state, gh->gh_state, gh->gh_flags)); -if (test_bit (HIF_FIRST , &gh->gh_iflags)) { -gfs2_assert_warn (sdp,test_bit (GLF_LOCK , &gl->gl_flags)); - -if (glops->go_lock) { - gh->gh_error = glops->go_lock (gh); -if (gh->gh_error) { -spin_lock (&gl->gl_spin); -list_del_init (&gh->gh_list); -spin_unlock (&gl->gl_spin); - } - } - -spin_lock (&gl->gl_spin); - gl->gl_req_gh =NULL ; -clear_bit (GLF_LOCK , &gl->gl_flags); -run_queue (gl); -spin_unlock (&gl->gl_spin); - } -return gh->gh_error; }
fs/gfs2/incore.h +0 -1
@@ -135,7 +135,6 @@ enum {/* States */ HIF_HOLDER =6 , -HIF_FIRST =7 ,HIF_ABORTED =9 , HIF_WAIT = 10, };
Signature · 1 line
1.5.1.2