Commit 02ffad08e838997fad3de05c85560a57e5fd92de

Authored by Benjamin Marzinski
Committed by Steven Whitehouse
1 parent 229615def3

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 <bmarzins@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>

Showing 2 changed files with 5 additions and 3 deletions Side-by-side Diff

... ... @@ -203,6 +203,7 @@
203 203 unsigned int gl_target;
204 204 unsigned int gl_reply;
205 205 unsigned int gl_hash;
  206 + unsigned int gl_req;
206 207 unsigned int gl_demote_state; /* state requested by remote node */
207 208 unsigned long gl_demote_time; /* time of first demote request */
208 209 struct list_head gl_holders;
... ... @@ -46,11 +46,11 @@
46 46 BUG();
47 47 }
48 48  
49   - ret = gl->gl_target;
  49 + ret = gl->gl_req;
50 50 if (gl->gl_lksb.sb_flags & DLM_SBF_ALTMODE) {
51   - if (gl->gl_target == LM_ST_SHARED)
  51 + if (gl->gl_req == LM_ST_SHARED)
52 52 ret = LM_ST_DEFERRED;
53   - else if (gl->gl_target == LM_ST_DEFERRED)
  53 + else if (gl->gl_req == LM_ST_DEFERRED)
54 54 ret = LM_ST_SHARED;
55 55 else
56 56 BUG();
... ... @@ -147,6 +147,7 @@
147 147 int req;
148 148 u32 lkf;
149 149  
  150 + gl->gl_req = req_state;
150 151 req = make_mode(req_state);
151 152 lkf = make_flags(gl->gl_lksb.sb_lkid, flags, req);
152 153