From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bob Peterson Date: Mon, 9 Jul 2018 12:50:25 -0500 Subject: [Cluster-devel] [GFS2 PATCH 09/12] GFS2: Reduce redundancy in GL_ST_DEMOTE_NONBLOCK state In-Reply-To: <20180709175028.17090-1-rpeterso@redhat.com> References: <20180709175028.17090-1-rpeterso@redhat.com> Message-ID: <20180709175028.17090-10-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 This patch just simplifies the path through the GL_ST_DEMOTE_NONBLOCK state in the state machine. Regardless of whether a holder is found, it still needs to clear the GLF_LOCK bit. But we need to be careful to do it check for a holder before we release GLF_LOCK. Signed-off-by: Bob Peterson --- fs/gfs2/glock.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index bc5ac558a917..4b910bd126f5 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c @@ -672,15 +672,13 @@ static void __state_machine(struct gfs2_glock *gl, int new_state, case GL_ST_DEMOTE_NONBLOCK: gl->gl_mch = GL_ST_IDLE; - if (find_first_holder(gl)) { - clear_bit(GLF_LOCK, &gl->gl_flags); - smp_mb__after_atomic(); - break; - } + gh = find_first_holder(gl); clear_bit(GLF_LOCK, &gl->gl_flags); smp_mb__after_atomic(); - gl->gl_lockref.count++; - __gfs2_glock_queue_work(gl, 0); + if (!gh) { + gl->gl_lockref.count++; + __gfs2_glock_queue_work(gl, 0); + } break; case GL_ST_PROMOTE: -- 2.17.1