From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bob Peterson Date: Mon, 9 Jul 2018 12:50:28 -0500 Subject: [Cluster-devel] [GFS2 PATCH 12/12] GFS2: Optimization of GL_ST_UNLOCK state In-Reply-To: <20180709175028.17090-1-rpeterso@redhat.com> References: <20180709175028.17090-1-rpeterso@redhat.com> Message-ID: <20180709175028.17090-13-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 The previous patch added a new GL_ST_UNLOCK state that simply cleared the GLF_LOCK bit, then went into the RUN state. Since the RUN state immediately sets the GLF_LOCK again and does a few other things, we can optimize it by putting GL_ST_UNLOCK in the middle of the GL_ST_RUN state. This avoids unlock-then-lock and extra checks and skips directly to the resulting promotion/demotion state. Signed-off-by: Bob Peterson --- fs/gfs2/glock.c | 6 ++---- fs/gfs2/glock.h | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index b7b8cf16d613..56db2e78c99f 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -723,7 +723,9 @@ static void __state_machine(struct gfs2_glock *gl, int new_state, GLOCK_BUG_ON(gl, test_bit(GLF_DEMOTE_IN_PROGRESS, &gl->gl_flags)); + /* Fall through */ + case GL_ST_UNLOCK: if (test_bit(GLF_DEMOTE, &gl->gl_flags) && gl->gl_demote_state != gl->gl_state) gl->gl_mch = nonblock ? GL_ST_DEMOTE_NONBLOCK : @@ -750,10 +752,6 @@ 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); diff --git a/fs/gfs2/glock.h b/fs/gfs2/glock.h index 5bbf3118c7c3..e1a5bc2d3f76 100644 --- a/fs/gfs2/glock.h +++ b/fs/gfs2/glock.h @@ -131,7 +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 */ + GL_ST_UNLOCK = 9, /* Unlock the glock */ }; struct lm_lockops { -- 2.17.1