From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bob Peterson Date: Mon, 9 Jul 2018 12:50:27 -0500 Subject: [Cluster-devel] [GFS2 PATCH 11/12] GFS2: Add new GL_ST_UNLOCK state to reduce calls to the __ version In-Reply-To: <20180709175028.17090-1-rpeterso@redhat.com> References: <20180709175028.17090-1-rpeterso@redhat.com> Message-ID: <20180709175028.17090-12-rpeterso@redhat.com> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Before this patch, the truncate code called __state_machine but only did the unlock of GLF_UNLOCK. This patch adds a new state GL_ST_UNLOCK does the same thing, thus allowing it to call the regular state_machine function. This reduces the calls to the helper. Signed-off-by: Bob Peterson --- fs/gfs2/glock.c | 11 ++++++----- fs/gfs2/glock.h | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index e20bb1222c01..b7b8cf16d613 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -749,6 +749,11 @@ static void __state_machine(struct gfs2_glock *gl, int new_state, } gl->gl_mch = GL_ST_RUN; break; + + case GL_ST_UNLOCK: + clear_bit(GLF_LOCK, &gl->gl_flags); + gl->gl_mch = GL_ST_RUN; + break; } } while (gl->gl_mch != GL_ST_IDLE || new_state != GL_ST_IDLE); @@ -773,7 +778,6 @@ static void __state_machine(struct gfs2_glock *gl, int new_state, * @gl: pointer to the glock we are transitioning * @new_state: The new state we need to execute * - * Just like __state_machine but it acquires the gl_lockref lock */ static void state_machine(struct gfs2_glock *gl, int new_state, const int nonblock) @@ -1733,10 +1737,7 @@ void gfs2_glock_finish_truncate(struct gfs2_inode *ip) ret = gfs2_truncatei_resume(ip); gfs2_assert_withdraw(gl->gl_name.ln_sbd, ret == 0); - spin_lock(&gl->gl_lockref.lock); - clear_bit(GLF_LOCK, &gl->gl_flags); - __state_machine(gl, GL_ST_RUN, 1); - spin_unlock(&gl->gl_lockref.lock); + state_machine(gl, GL_ST_UNLOCK, 1); } static const char *state2str(unsigned state) diff --git a/fs/gfs2/glock.h b/fs/gfs2/glock.h index 0b1dffb92e8a..5bbf3118c7c3 100644 --- a/fs/gfs2/glock.h +++ b/fs/gfs2/glock.h @@ -131,6 +131,7 @@ enum gl_machine_states { GL_ST_PROMOTE = 6, /* Promote the lock */ GL_ST_RUN = 7, /* "Run" or progress the lock */ GL_ST_WORK = 8, /* Perform general glock work */ + GL_ST_UNLOCK = 9, /* Unlock then run */ }; struct lm_lockops { -- 2.17.1