From: Bob Peterson <rpeterso@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 06/13] GFS2: Make do_xmote not call the state machine again
Date: Mon, 19 Nov 2018 07:29:24 -0600 [thread overview]
Message-ID: <20181119132931.15726-7-rpeterso@redhat.com> (raw)
In-Reply-To: <20181119132931.15726-1-rpeterso@redhat.com>
Before this patch, the state machine could call do_xmote which,
in turn, could call back into the state machine. This patch unravels
the logic so instead it sends back an -EAGAIN return code, which
signals the state machine to loop under the new state.
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
---
fs/gfs2/glock.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index b541c4053dd7..8dc98d069afa 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -527,9 +527,11 @@ static int finish_xmote(struct gfs2_glock *gl)
* @gl: The lock state
* @target: The target lock state
*
+ * Returns: 0 if the lock is pending, or
+ * -EAGAIN if we need to run the state machine again to finish_xmote
*/
-static void do_xmote(struct gfs2_glock *gl, unsigned int target)
+static int do_xmote(struct gfs2_glock *gl, unsigned int target)
__releases(&gl->gl_lockref.lock)
__acquires(&gl->gl_lockref.lock)
{
@@ -537,11 +539,11 @@ __acquires(&gl->gl_lockref.lock)
struct gfs2_sbd *sdp = gl->gl_name.ln_sbd;
struct gfs2_holder *gh = find_first_waiter(gl);
unsigned int lck_flags = (unsigned int)(gh ? gh->gh_flags : 0);
- int ret;
+ int ret = 0;
if (unlikely(test_bit(SDF_SHUTDOWN, &sdp->sd_flags)) &&
target != LM_ST_UNLOCKED)
- return;
+ return 0;
lck_flags &= (LM_FLAG_TRY | LM_FLAG_TRY_1CB | LM_FLAG_NOEXP |
LM_FLAG_PRIORITY);
GLOCK_BUG_ON(gl, gl->gl_state == target);
@@ -572,21 +574,23 @@ __acquires(&gl->gl_lockref.lock)
target == LM_ST_UNLOCKED &&
test_bit(SDF_SKIP_DLM_UNLOCK, &sdp->sd_flags)) {
gl->gl_reply = target;
- state_machine(gl, GL_ST_FINISH_XMOTE);
+ ret = -EAGAIN;
gfs2_glock_queue_work(gl, 0);
}
else if (ret) {
fs_err(sdp, "lm_lock ret %d\n", ret);
GLOCK_BUG_ON(gl, !test_bit(SDF_SHUTDOWN,
&sdp->sd_flags));
+ ret = 0;
}
} else { /* lock_nolock */
gl->gl_reply = target;
- state_machine(gl, GL_ST_FINISH_XMOTE);
+ ret = -EAGAIN;
gfs2_glock_queue_work(gl, 0);
}
spin_lock(&gl->gl_lockref.lock);
+ return ret;
}
/**
@@ -698,13 +702,16 @@ static void __state_machine(struct gfs2_glock *gl, int new_state)
case GL_ST_DO_XMOTE:
gl->gl_mch = GL_ST_IDLE;
- do_xmote(gl, gl->gl_target);
+ ret = do_xmote(gl, gl->gl_target);
+ if (ret == -EAGAIN)
+ gl->gl_mch = GL_ST_FINISH_XMOTE;
break;
case GL_ST_DO_XMOTE_UNLOCK:
gl->gl_mch = GL_ST_IDLE;
- do_xmote(gl, LM_ST_UNLOCKED);
- finish_xmote(gl);
+ ret = do_xmote(gl, LM_ST_UNLOCKED);
+ if (ret == -EAGAIN)
+ gl->gl_mch = GL_ST_FINISH_XMOTE;
break;
}
} while (gl->gl_mch != GL_ST_IDLE);
--
2.19.1
next prev parent reply other threads:[~2018-11-19 13:29 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-19 13:29 [Cluster-devel] [PATCH 00/13] Radical Reform of glock state machine (take 2) Bob Peterson
2018-11-19 13:29 ` [Cluster-devel] [PATCH 01/13] GFS2: Remove gotos from function run_queue Bob Peterson
2018-11-19 13:29 ` [Cluster-devel] [PATCH 02/13] GFS2: Make do_xmote determine its own gh parameter Bob Peterson
2018-11-19 14:00 ` Steven Whitehouse
2018-11-19 21:06 ` Bob Peterson
2018-11-20 15:46 ` Steven Whitehouse
2018-11-19 13:29 ` [Cluster-devel] [PATCH 03/13] GFS2: Eliminate a goto in finish_xmote Bob Peterson
2018-11-19 13:49 ` Steven Whitehouse
2018-11-19 21:26 ` Bob Peterson
2018-11-20 15:52 ` Steven Whitehouse
2018-11-19 13:29 ` [Cluster-devel] [PATCH 04/13] GFS2: Baby step toward a real state machine: finish_xmote Bob Peterson
2018-11-19 13:29 ` [Cluster-devel] [PATCH 05/13] GFS2: Add do_xmote states to state machine Bob Peterson
2018-11-19 13:29 ` Bob Peterson [this message]
2018-11-19 13:29 ` [Cluster-devel] [PATCH 07/13] GFS2: Add blocking and non-blocking demote " Bob Peterson
2018-11-19 13:29 ` [Cluster-devel] [PATCH 08/13] GFS2: Add a new GL_ST_PROMOTE state to glock " Bob Peterson
2018-11-19 13:29 ` [Cluster-devel] [PATCH 09/13] GFS2: Replace run_queue with new GL_ST_RUN state in " Bob Peterson
2018-11-19 13:29 ` [Cluster-devel] [PATCH 10/13] GFS2: Reduce redundancy in GL_ST_DEMOTE_NONBLOCK state Bob Peterson
2018-11-19 13:29 ` [Cluster-devel] [PATCH 11/13] GFS2: Reduce glock_work_func to a single call to state_machine Bob Peterson
2018-11-19 13:29 ` [Cluster-devel] [PATCH 12/13] GFS2: Add new GL_ST_UNLOCK state to reduce calls to the __ version Bob Peterson
2018-11-19 13:29 ` [Cluster-devel] [PATCH 13/13] GFS2: Optimization of GL_ST_UNLOCK state Bob Peterson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181119132931.15726-7-rpeterso@redhat.com \
--to=rpeterso@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).