From 02ffad08e838997fad3de05c85560a57e5fd92de Mon Sep 17 00:00:00 2001 From: Benjamin Marzinski Date: Fri, 6 Mar 2009 10:03:20 -0600 Subject: GFS2: Fix locking bug in failed shared to exclusive conversion After calling out to the dlm, GFS2 sets the new state of a glock to gl_target in gdlm_ast(). However, gl_target is not always the lock state that was requested. If a conversion from shared to exclusive fails, finish_xmote() will call do_xmote() with LM_ST_UNLOCKED, instead of gl->gl_target, so that it can reacquire the lock in exlusive the next time around. In this case, setting the lock to gl_target in gdlm_ast() will make GFS2 think that it has the glock in exclusive mode, when really, it doesn't have the glock locked at all. This patch adds a new field to the gfs2_glock structure, gl_req, to track the mode that was requested. Signed-off-by: Benjamin Marzinski Signed-off-by: Steven Whitehouse --- fs/gfs2/lock_dlm.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'fs/gfs2/lock_dlm.c') diff --git a/fs/gfs2/lock_dlm.c b/fs/gfs2/lock_dlm.c index a0bb7d2251a..46df988323b 100644 --- a/fs/gfs2/lock_dlm.c +++ b/fs/gfs2/lock_dlm.c @@ -46,11 +46,11 @@ static void gdlm_ast(void *arg) BUG(); } - ret = gl->gl_target; + ret = gl->gl_req; if (gl->gl_lksb.sb_flags & DLM_SBF_ALTMODE) { - if (gl->gl_target == LM_ST_SHARED) + if (gl->gl_req == LM_ST_SHARED) ret = LM_ST_DEFERRED; - else if (gl->gl_target == LM_ST_DEFERRED) + else if (gl->gl_req == LM_ST_DEFERRED) ret = LM_ST_SHARED; else BUG(); @@ -147,6 +147,7 @@ static unsigned int gdlm_lock(struct gfs2_glock *gl, int req; u32 lkf; + gl->gl_req = req_state; req = make_mode(req_state); lkf = make_flags(gl->gl_lksb.sb_lkid, flags, req); -- cgit v1.2.3