Skip to content

Commit 8693419

Browse files
AstralBobAndreas Gruenbacher
authored and
Andreas Gruenbacher
committed
gfs2: Clear flags when withdraw prevents xmote
There are a couple places in function do_xmote where normal processing is circumvented due to withdraws in progress. However, since we bypass most of do_xmote() we bypass telling dlm to lock the dlm lock, which means dlm will never respond with a completion callback. Since the completion callback ordinarily clears GLF_LOCK, this patch changes function do_xmote to handle those situations more gracefully so the file system may be unmounted after withdraw. A very similar situation happens with the GLF_DEMOTE_IN_PROGRESS flag, which is cleared by function finish_xmote(). Since the withdraw causes us to skip the majority of do_xmote, it therefore also skips the call to finish_xmote() so the DEMOTE_IN_PROGRESS flag needs to be cleared manually. Signed-off-by: Bob Peterson <[email protected]> Signed-off-by: Andreas Gruenbacher <[email protected]>
1 parent 053640a commit 8693419

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

Diff for: fs/gfs2/glock.c

+20-2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ typedef void (*glock_examiner) (struct gfs2_glock * gl);
5959

6060
static void do_xmote(struct gfs2_glock *gl, struct gfs2_holder *gh, unsigned int target);
6161
static void __gfs2_glock_dq(struct gfs2_holder *gh);
62+
static void handle_callback(struct gfs2_glock *gl, unsigned int state,
63+
unsigned long delay, bool remote);
6264

6365
static struct dentry *gfs2_root;
6466
static struct workqueue_struct *glock_workqueue;
@@ -730,7 +732,8 @@ static bool is_system_glock(struct gfs2_glock *gl)
730732
*
731733
*/
732734

733-
static void do_xmote(struct gfs2_glock *gl, struct gfs2_holder *gh, unsigned int target)
735+
static void do_xmote(struct gfs2_glock *gl, struct gfs2_holder *gh,
736+
unsigned int target)
734737
__releases(&gl->gl_lockref.lock)
735738
__acquires(&gl->gl_lockref.lock)
736739
{
@@ -741,7 +744,8 @@ __acquires(&gl->gl_lockref.lock)
741744

742745
if (target != LM_ST_UNLOCKED && glock_blocked_by_withdraw(gl) &&
743746
gh && !(gh->gh_flags & LM_FLAG_NOEXP))
744-
return;
747+
goto skip_inval;
748+
745749
lck_flags &= (LM_FLAG_TRY | LM_FLAG_TRY_1CB | LM_FLAG_NOEXP |
746750
LM_FLAG_PRIORITY);
747751
GLOCK_BUG_ON(gl, gl->gl_state == target);
@@ -826,6 +830,20 @@ __acquires(&gl->gl_lockref.lock)
826830
(target != LM_ST_UNLOCKED ||
827831
test_bit(SDF_WITHDRAW_RECOVERY, &sdp->sd_flags))) {
828832
if (!is_system_glock(gl)) {
833+
handle_callback(gl, LM_ST_UNLOCKED, 0, false); /* sets demote */
834+
/*
835+
* Ordinarily, we would call dlm and its callback would call
836+
* finish_xmote, which would call state_change() to the new state.
837+
* Since we withdrew, we won't call dlm, so call state_change
838+
* manually, but to the UNLOCKED state we desire.
839+
*/
840+
state_change(gl, LM_ST_UNLOCKED);
841+
/*
842+
* We skip telling dlm to do the locking, so we won't get a
843+
* reply that would otherwise clear GLF_LOCK. So we clear it here.
844+
*/
845+
clear_bit(GLF_LOCK, &gl->gl_flags);
846+
clear_bit(GLF_DEMOTE_IN_PROGRESS, &gl->gl_flags);
829847
gfs2_glock_queue_work(gl, GL_GLOCK_DFT_HOLD);
830848
goto out;
831849
} else {

0 commit comments

Comments
 (0)