[Cluster-devel] [PATCH 12/13] GFS2: Add new GL_ST_UNLOCK state to reduce calls to the __ version
Bob Peterson
rpeterso at redhat.com
Mon Nov 19 13:29:30 UTC 2018
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 <rpeterso at redhat.com>
---
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 22ddeda90199..33f4a530caf4 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -750,6 +750,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);
@@ -774,7 +779,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)
@@ -1734,10 +1738,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.19.1
More information about the Cluster-devel
mailing list