aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoseph Qi <joseph.qi@huawei.com>2016-09-19 17:43:55 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-09-19 18:36:16 -0400
commite6f0c6e6170fec175fe676495f29029aecdf486c (patch)
tree9f0ccd2923830ee0088a81d3abb5526d829c2832
parent9bb627be47a574b764e162e8513d5db78d49e7f5 (diff)
ocfs2/dlm: fix race between convert and migration
Commit ac7cf246dfdb ("ocfs2/dlm: fix race between convert and recovery") checks if lockres master has changed to identify whether new master has finished recovery or not. This will introduce a race that right after old master does umount ( means master will change), a new convert request comes. In this case, it will reset lockres state to DLM_RECOVERING and then retry convert, and then fail with lockres->l_action being set to OCFS2_AST_INVALID, which will cause inconsistent lock level between ocfs2 and dlm, and then finally BUG. Since dlm recovery will clear lock->convert_pending in dlm_move_lockres_to_recovery_list, we can use it to correctly identify the race case between convert and recovery. So fix it. Fixes: ac7cf246dfdb ("ocfs2/dlm: fix race between convert and recovery") Link: http://lkml.kernel.org/r/57CE1569.8010704@huawei.com Signed-off-by: Joseph Qi <joseph.qi@huawei.com> Signed-off-by: Jun Piao <piaojun@huawei.com> Cc: Mark Fasheh <mfasheh@suse.de> Cc: Joel Becker <jlbec@evilplan.org> Cc: Junxiao Bi <junxiao.bi@oracle.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/ocfs2/dlm/dlmconvert.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/fs/ocfs2/dlm/dlmconvert.c b/fs/ocfs2/dlm/dlmconvert.c
index cdeafb4e7ed6..0bb128659d4b 100644
--- a/fs/ocfs2/dlm/dlmconvert.c
+++ b/fs/ocfs2/dlm/dlmconvert.c
@@ -268,7 +268,6 @@ enum dlm_status dlmconvert_remote(struct dlm_ctxt *dlm,
268 struct dlm_lock *lock, int flags, int type) 268 struct dlm_lock *lock, int flags, int type)
269{ 269{
270 enum dlm_status status; 270 enum dlm_status status;
271 u8 old_owner = res->owner;
272 271
273 mlog(0, "type=%d, convert_type=%d, busy=%d\n", lock->ml.type, 272 mlog(0, "type=%d, convert_type=%d, busy=%d\n", lock->ml.type,
274 lock->ml.convert_type, res->state & DLM_LOCK_RES_IN_PROGRESS); 273 lock->ml.convert_type, res->state & DLM_LOCK_RES_IN_PROGRESS);
@@ -335,7 +334,6 @@ enum dlm_status dlmconvert_remote(struct dlm_ctxt *dlm,
335 334
336 spin_lock(&res->spinlock); 335 spin_lock(&res->spinlock);
337 res->state &= ~DLM_LOCK_RES_IN_PROGRESS; 336 res->state &= ~DLM_LOCK_RES_IN_PROGRESS;
338 lock->convert_pending = 0;
339 /* if it failed, move it back to granted queue. 337 /* if it failed, move it back to granted queue.
340 * if master returns DLM_NORMAL and then down before sending ast, 338 * if master returns DLM_NORMAL and then down before sending ast,
341 * it may have already been moved to granted queue, reset to 339 * it may have already been moved to granted queue, reset to
@@ -344,12 +342,14 @@ enum dlm_status dlmconvert_remote(struct dlm_ctxt *dlm,
344 if (status != DLM_NOTQUEUED) 342 if (status != DLM_NOTQUEUED)
345 dlm_error(status); 343 dlm_error(status);
346 dlm_revert_pending_convert(res, lock); 344 dlm_revert_pending_convert(res, lock);
347 } else if ((res->state & DLM_LOCK_RES_RECOVERING) || 345 } else if (!lock->convert_pending) {
348 (old_owner != res->owner)) { 346 mlog(0, "%s: res %.*s, owner died and lock has been moved back "
349 mlog(0, "res %.*s is in recovering or has been recovered.\n", 347 "to granted list, retry convert.\n",
350 res->lockname.len, res->lockname.name); 348 dlm->name, res->lockname.len, res->lockname.name);
351 status = DLM_RECOVERING; 349 status = DLM_RECOVERING;
352 } 350 }
351
352 lock->convert_pending = 0;
353bail: 353bail:
354 spin_unlock(&res->spinlock); 354 spin_unlock(&res->spinlock);
355 355