Patch "ocfs2/dlm: fix race between convert and migration" has been added to the 4.7-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
ocfs2/dlm: fix race between convert and migration
to the 4.7-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
ocfs2-dlm-fix-race-between-convert-and-migration.patch
and it can be found in the queue-4.7 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
e6f0c6e6170fec175fe676495f29029aecdf486cMon Sep 17 00:00:00 2001
From: Joseph Qi <[email protected]>
Date: Mon, 19 Sep 2016 14:43:55 -0700
Subject: ocfs2/dlm: fix race between convert and migration
From: Joseph Qi <[email protected]>
commit e6f0c6e6170fec175fe676495f29029aecdf486c upstream.
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.
--- fs/ocfs2/dlm/dlmconvert.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
fs/ocfs2/dlm/dlmconvert.c +6 -6
@@ -268,7 +268,6 @@ enum dlm_status dlmconvert_remote(struct struct dlm_lock *lock, int flags, int type) { enum dlm_status status; -u8 old_owner = res->owner;mlog (0 ,"type=%d, convert_type=%d, busy=%d\n" , lock->ml.type, lock->ml.convert_type, res->state &DLM_LOCK_RES_IN_PROGRESS );
@@ -335,7 +334,6 @@ enum dlm_status dlmconvert_remote(structspin_lock (&res->spinlock); res->state &= ~DLM_LOCK_RES_IN_PROGRESS ; - lock->convert_pending =0 ;/* if it failed, move it back to granted queue. * if master returns DLM_NORMAL and then down before sending ast, * it may have already been moved to granted queue, reset to
@@ -344,12 +342,14 @@ enum dlm_status dlmconvert_remote(structif (status !=DLM_NOTQUEUED )dlm_error (status);dlm_revert_pending_convert (res, lock); - }else if ((res->state &DLM_LOCK_RES_RECOVERING ) || - (old_owner != res->owner)) { -mlog (0 ,"res %.*s is in recovering or has been recovered.\n" , - res->lockname.len, res->lockname.name); + }else if (!lock->convert_pending) { +mlog (0 ,"%s: res %.*s, owner died and lock has been moved back " +"to granted list, retry convert.\n" , + dlm->name, res->lockname.len, res->lockname.name); status =DLM_RECOVERING ; } + + lock->convert_pending =0 ; bail:spin_unlock (&res->spinlock);
Patches currently in stable-queue which might be from [email protected] are
queue-4.7/ocfs2-fix-start-offset-to-ocfs2_zero_range_for_truncate.patch queue-4.7/ocfs2-dlm-fix-race-between-convert-and-migration.patch queue-4.7/revert-ocfs2-bump-up-o2cb-network-protocol-version.patch