ocfs2/dlm: disable BUG_ON when DLM_LOCK_RES_DROPPING_REF, is cleared before dlm_deref_lockres_done_handler
We found a BUG situation in which DLM_LOCK_RES_DROPPING_REF is cleared unexpected that described below. To solve the bug, we disable the BUG_ON and purge lockres in dlm_do_local_recovery_cleanup.
Node 1 Node 2(master)dlm_purge_lockres
dlm_deref_lockres_handler
DLM_LOCK_RES_SETREF_INPROG is set response DLM_DEREF_RESPONSE_INPROG
receive DLM_DEREF_RESPONSE_INPROG
stop puring in dlm_purge_lockres
and wait for DLM_DEREF_RESPONSE_DONE
dispatch dlm_deref_lockres_worker response DLM_DEREF_RESPONSE_DONE
receive DLM_DEREF_RESPONSE_DONE and
prepare to purge lockres
Node 2 goes down
find Node2 down and do local
clean up for Node2:dlm_do_local_recovery_cleanup
-> clear DLM_LOCK_RES_DROPPING_REF
when purging lockres, BUG_ON happens
because DLM_LOCK_RES_DROPPING_REF is clear:dlm_deref_lockres_done_handler
->BUG_ON(!(res->state & DLM_LOCK_RES_DROPPING_REF));
--- fs/ocfs2/dlm/dlmmaster.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)
fs/ocfs2/dlm/dlmmaster.c +12 -1
@@ -2416,7 +2416,16 @@ int dlm_deref_lockres_done_handler(struct o2net_msg *msg, u32 len, void *data, }spin_lock (&res->spinlock); -BUG_ON (!(res->state &DLM_LOCK_RES_DROPPING_REF )); +if (!(res->state &DLM_LOCK_RES_DROPPING_REF )) { +spin_unlock (&res->spinlock); +spin_unlock (&dlm->spinlock); +mlog (ML_NOTICE ,"%s:%.*s: node %u sends deref done " +"but it is already derefed!\n" , dlm->name, + res->lockname.len, res->lockname.name, node); +dlm_lockres_put (res); + goto done; + } +if (!list_empty (&res->purge)) {mlog (0 ,"%s: Removing res %.*s from purgelist\n" , dlm->name, res->lockname.len, res->lockname.name);
@@ -2455,6 +2464,8 @@ int dlm_deref_lockres_done_handler(struct o2net_msg *msg, u32 len, void *data,spin_unlock (&dlm->spinlock); + ret =0 ; + done:dlm_put (dlm);return ret;
Signature · 1 line
1.8.4.3
Hi Jun,
Quoted 45 lines · piaojun
We found a BUG situation in which
DLM_LOCK_RES_DROPPING_REFis cleared unexpected that described below. To solve the bug, we disable theBUG_ONand purge lockres indlm_do_local_recovery_cleanup.Node 1 Node 2(master)
dlm_purge_lockres
dlm_deref_lockres_handler
DLM_LOCK_RES_SETREF_INPROGis set responseDLM_DEREF_RESPONSE_INPROGreceive
DLM_DEREF_RESPONSE_INPROG
stop puring indlm_purge_lockres
and wait forDLM_DEREF_RESPONSE_DONEdispatch
dlm_deref_lockres_workerresponseDLM_DEREF_RESPONSE_DONEreceive
DLM_DEREF_RESPONSE_DONEand
prepare to purge lockresNode 2 goes down
find Node2 down and do local
clean up for Node2:dlm_do_local_recovery_cleanup
-> clearDLM_LOCK_RES_DROPPING_REFwhen purging lockres,
BUG_ONhappens
becauseDLM_LOCK_RES_DROPPING_REFis clear:dlm_deref_lockres_done_handler
->BUG_ON(!(res->state &DLM_LOCK_RES_DROPPING_REF));Fixes 60d663cb5273 ("ocfs2/dlm: add DEREF_DONE message")Signed-off-by Jun Piao <[email protected]>--- fs/ocfs2/dlm/dlmmaster.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)fs/ocfs2/dlm/dlmmaster.c +0
-0@@ -2416,7 +2416,16 @@ int dlm_deref_lockres_done_handler(struct o2net_msg *msg, u32 len, void *data, }
fs/ocfs2/dlm/dlmmaster.c int dlm_deref_lockres_done_handler(struct o2net_msg *msg, u32 len, void *data, · line 2425
Quoted 10 lines
fs/ocfs2/dlm/dlmmaster.c +7
-1spin_lock (&res->spinlock); -BUG_ON (!(res->state &DLM_LOCK_RES_DROPPING_REF )); +if (!(res->state &DLM_LOCK_RES_DROPPING_REF )) { +spin_unlock (&res->spinlock); +spin_unlock (&dlm->spinlock); +mlog (ML_NOTICE ,"%s:%.*s: node %u sends deref done " +"but it is already derefed!\n" , dlm->name, + res->lockname.len, res->lockname.name, node); +dlm_lockres_put (res);
So we treat this case as normal?
If so, we'd better return 0 other than -EINVAL.
Thanks,
Joseph
Quoted 16 lines
fs/ocfs2/dlm/dlmmaster.c +5
-0+ goto done; + } +if (!list_empty (&res->purge)) {mlog (0 ,"%s: Removing res %.*s from purgelist\n" , dlm->name, res->lockname.len, res->lockname.name);@@ -2455,6 +2464,8 @@ int dlm_deref_lockres_done_handler(struct o2net_msg *msg, u32 len, void *data,spin_unlock (&dlm->spinlock); + ret =0 ; + done:dlm_put (dlm);return ret;
Quoted 61 lines · Joseph Qi
Hi Jun,
Quoted 45 lines · piaojun
We found a BUG situation in which
DLM_LOCK_RES_DROPPING_REFis cleared unexpected that described below. To solve the bug, we disable theBUG_ONand purge lockres indlm_do_local_recovery_cleanup.Node 1 Node 2(master)
dlm_purge_lockres
dlm_deref_lockres_handler
DLM_LOCK_RES_SETREF_INPROGis set responseDLM_DEREF_RESPONSE_INPROGreceive
DLM_DEREF_RESPONSE_INPROG
stop puring indlm_purge_lockres
and wait forDLM_DEREF_RESPONSE_DONEdispatch
dlm_deref_lockres_workerresponseDLM_DEREF_RESPONSE_DONEreceive
DLM_DEREF_RESPONSE_DONEand
prepare to purge lockresNode 2 goes down
find Node2 down and do local
clean up for Node2:dlm_do_local_recovery_cleanup
-> clearDLM_LOCK_RES_DROPPING_REFwhen purging lockres,
BUG_ONhappens
becauseDLM_LOCK_RES_DROPPING_REFis clear:dlm_deref_lockres_done_handler
->BUG_ON(!(res->state &DLM_LOCK_RES_DROPPING_REF));Fixes 60d663cb5273 ("ocfs2/dlm: add DEREF_DONE message")Signed-off-by Jun Piao <[email protected]>--- fs/ocfs2/dlm/dlmmaster.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-)fs/ocfs2/dlm/dlmmaster.c +0
-0@@ -2416,7 +2416,16 @@ int dlm_deref_lockres_done_handler(struct o2net_msg *msg, u32 len, void *data, }fs/ocfs2/dlm/dlmmaster.c int dlm_deref_lockres_done_handler(struct o2net_msg *msg, u32 len, void *data, · line 2425
Quoted 10 lines
fs/ocfs2/dlm/dlmmaster.c +7
-1spin_lock (&res->spinlock); -BUG_ON (!(res->state &DLM_LOCK_RES_DROPPING_REF )); +if (!(res->state &DLM_LOCK_RES_DROPPING_REF )) { +spin_unlock (&res->spinlock); +spin_unlock (&dlm->spinlock); +mlog (ML_NOTICE ,"%s:%.*s: node %u sends deref done " +"but it is already derefed!\n" , dlm->name, + res->lockname.len, res->lockname.name, node); +dlm_lockres_put (res);So we treat this case as normal?
If so, we'd better return 0 other than-EINVAL.
Quoted 3 lines
Thanks,
Joseph
Good suggestion, I will fix this problem in the following [PATCH v2]. Thanks,
Jun Piao
Quoted 21 lines
Quoted 8 lines
fs/ocfs2/dlm/dlmmaster.c +3
-0+ goto done; + } +if (!list_empty (&res->purge)) {mlog (0 ,"%s: Removing res %.*s from purgelist\n" , dlm->name, res->lockname.len, res->lockname.name);fs/ocfs2/dlm/dlmmaster.c int dlm_deref_lockres_done_handler(struct o2net_msg *msg, u32 len, void *data, · line 2471
Quoted 8 lines
fs/ocfs2/dlm/dlmmaster.c +2
-0@@ -2455,6 +2464,8 @@ int dlm_deref_lockres_done_handler(struct o2net_msg *msg, u32 len, void *data,spin_unlock (&dlm->spinlock); + ret =0 ; + done:dlm_put (dlm);return ret;.