ocfs2/dlm: return DLM_CANCELGRANT if the lock is on granted list and the operation is canceled
PATCH 1/1 ocfs2/dlm: return DLM_CANCELGRANT if the lock is on granted list and the operation is canceled
In the dlm_move_lockres_to_recovery_list function, if the lock is in the granted queue and cancel_pending is set, it will encounter a BUG. I think this is a meaningless BUG, so be prepared to remove it. A scenario that causes this BUG will be given below.
At the beginning, Node 1 is the master and has NL lock, Node 2 has PR lock, Node 3 has PR lock too.
Node 1 Node 2 Node 3
want to get EX lock.
want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.
receive BAST from Node 1. downconvert thread begin to cancel PR to EX conversion. In dlmunlock_common function, downconvert thread has set lock->cancel_pending, but did not enter dlm_send_remote_unlock_request function.
Node2 dies because
the host is powered down.
In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.
receive AST from Node 1. change lock level to EX, move lock to granted list.
Node1 dies because
the host is powered down.
In dlm_move_lockres_to_recovery_list function. the lock is in the granted queue and cancel_pending is set. BUG_ON.
But after clearing this BUG, process will encounter the second BUG in the ocfs2_unlock_ast function. Here is a scenario that will cause the second BUG in ocfs2_unlock_ast as follows:
At the beginning, Node 1 is the master and has NL lock, Node 2 has PR lock, Node 3 has PR lock too.
Node 1 Node 2 Node 3
want to get EX lock.
want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.
receive BAST from
Node 1. downconvert thread begin to
cancel PR to EX conversion. In dlmunlock_common function, downconvert thread has released lock->spinlock and res->spinlock, but did not enter dlm_send_remote_unlock_request function.
Node2 dies because
the host is powered down.
In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.
receive AST from Node 1. change lock level to EX, move lock to granted list, set lockres->l_unlock_action as OCFS2_UNLOCK_INVALID in ocfs2_locking_ast function.
Node2 dies because
the host is powered down.
Node 3 realize that Node 1 is dead, remove Node 1 from domain_map. downconvert thread get DLM_NORMAL from dlm_send_remote_unlock_request function and set *call_ast as 1. Then downconvert thread meet BUG in ocfs2_unlock_ast function.
To avoid meet the second BUG, function dlmunlock_common shuold return DLM_CANCELGRANT if the lock is on granted list and the operation is canceled.
--- fs/ocfs2/dlm/dlmrecovery.c | 1 - fs/ocfs2/dlm/dlmunlock.c | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-)
fs/ocfs2/dlm/dlmrecovery.c +0 -1
@@ -2134,7 +2134,6 @@ void dlm_move_lockres_to_recovery_list(struct dlm_ctxt *dlm,* if this had completed successfully * before sending this lock state to the * new master */ -BUG_ON (i !=DLM_CONVERTING_LIST );mlog (0 ,"node died with cancel pending " "on %.*s. move back to granted list.\n" , res->lockname.len, res->lockname.name);
fs/ocfs2/dlm/dlmunlock.c +5 -0
@@ -183,6 +183,11 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm, flags, owner);spin_lock (&res->spinlock);spin_lock (&lock->spinlock); + +if ((flags &LKM_CANCEL ) && +dlm_lock_on_list (&res->granted, lock)) + status =DLM_CANCELGRANT ; +/* if the master told us the lock was already granted, * let the ast handle all of these actions */ if (status ==DLM_CANCELGRANT ) {
Signature · 5 lines
1.8.3.1 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://oss.oracle.com/pipermail/ocfs2-devel/attachments/20181203/845049c8/attachment.html
PATCH 1/1 ocfs2/dlm: return DLM_CANCELGRANT if the lock is on granted list and the operation is canceled
Hi Jian,
I suppose you can't just remove the BUG_ON() check. If you remove it, below code violates the original logic.
'''
2141 dlm_commit_pending_cancel(res, lock);
'''
What's more important is *locking cancel* must be against a *locking conversion* progress. So it makes sense to check if this lock is on converting list.
So I have to NACK to this patch.
Thanks,
Changwei
Quoted 152 lines · wangjian
In the
dlm_move_lockres_to_recovery_listfunction, if the lock is in the granted queue andcancel_pendingis set, it will encounter a BUG. I think this is a meaningless BUG, so be prepared to remove it. A scenario that causes this BUG will be given below.At the beginning, Node 1 is the master and has NL lock, Node 2 has PR lock, Node 3 has PR lock too.
Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from Node 1. downconvert thread begin to cancel PR to EX conversion. In
dlmunlock_commonfunction, downconvert thread has setlock->cancel_pending, but did not enterdlm_send_remote_unlock_requestfunction.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1. change lock level to EX, move lock to granted list.
Node1 dies because
the host is powered down.In
dlm_move_lockres_to_recovery_listfunction. the lock is in the granted queue andcancel_pendingis set.BUG_ON.But after clearing this BUG, process will encounter the second BUG in the
ocfs2_unlock_astfunction. Here is a scenario that will cause the second BUG inocfs2_unlock_astas follows:At the beginning, Node 1 is the master and has NL lock, Node 2 has PR lock, Node 3 has PR lock too.
Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from
Node 1. downconvert thread begin to
cancel PR to EX conversion. Indlmunlock_commonfunction, downconvert thread has releasedlock->spinlockandres->spinlock, but did not enterdlm_send_remote_unlock_requestfunction.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1. change lock level to EX, move lock to granted list, set
lockres->l_unlock_actionasOCFS2_UNLOCK_INVALIDinocfs2_locking_astfunction.Node2 dies because
the host is powered down.Node 3 realize that Node 1 is dead, remove Node 1 from
domain_map. downconvert thread getDLM_NORMALfromdlm_send_remote_unlock_requestfunction and set*call_astas 1. Then downconvert thread meet BUG inocfs2_unlock_astfunction.To avoid meet the second BUG, function
dlmunlock_commonshuold returnDLM_CANCELGRANTif the lock is on granted list and the operation is canceled.Signed-off-by Jian Wang<[email protected]>Reviewed-by Yiwen Jiang<[email protected]>--- fs/ocfs2/dlm/dlmrecovery.c | 1 - fs/ocfs2/dlm/dlmunlock.c | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-)fs/ocfs2/dlm/dlmrecovery.c +0
-1@@ -2134,7 +2134,6 @@ void dlm_move_lockres_to_recovery_list(struct dlm_ctxt *dlm,* if this had completed successfully * before sending this lock state to the * new master */ -BUG_ON (i !=DLM_CONVERTING_LIST );mlog (0 ,"node died with cancel pending " "on %.*s. move back to granted list.\n" , res->lockname.len, res->lockname.name);fs/ocfs2/dlm/dlmunlock.c +5
-0@@ -183,6 +183,11 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm, flags, owner);spin_lock (&res->spinlock);spin_lock (&lock->spinlock); + +if ((flags &LKM_CANCEL ) && +dlm_lock_on_list (&res->granted, lock)) + status =DLM_CANCELGRANT ; +/* if the master told us the lock was already granted, * let the ast handle all of these actions */ if (status ==DLM_CANCELGRANT ) {Signature · 1 line
1.8.3.1
PATCH 1/1 ocfs2/dlm: return DLM_CANCELGRANT if the lock is on granted list and the operation is canceled
Hi Changwei,
I don't fully agree with your point of view. In my opinion, the lock cancellation process and the lock conversion process are asynchronous. We can't guarantee that the lock must be in the convert list during the lock conversion process, otherwise this BUG will not happen.
So, I think this is a meaningless BUG.
Thanks,
Jian
Quoted 164 lines · Changwei Ge
Hi Jian,
I suppose you can't just remove the
BUG_ON()check. If you remove it, below code violates the original logic.'''
2141dlm_commit_pending_cancel(res, lock);
'''What's more important is *locking cancel* must be against a *locking conversion* progress. So it makes sense to check if this lock is on converting list.
So I have to NACK to this patch.
Thanks,
ChangweiQuoted 145 lines · wangjian
In the
dlm_move_lockres_to_recovery_listfunction, if the lock is in the granted queue andcancel_pendingis set, it will encounter a BUG. I think this is a meaningless BUG, so be prepared to remove it. A scenario that causes this BUG will be given below.At the beginning, Node 1 is the master and has NL lock, Node 2 has PR lock, Node 3 has PR lock too.
Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from Node 1. downconvert thread begin to cancel PR to EX conversion. In
dlmunlock_commonfunction, downconvert thread has setlock->cancel_pending, but did not enterdlm_send_remote_unlock_requestfunction.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1. change lock level to EX, move lock to granted list.
Node1 dies because
the host is powered down.In
dlm_move_lockres_to_recovery_listfunction. the lock is in the granted queue andcancel_pendingis set.BUG_ON.But after clearing this BUG, process will encounter the second BUG in the
ocfs2_unlock_astfunction. Here is a scenario that will cause the second BUG inocfs2_unlock_astas follows:At the beginning, Node 1 is the master and has NL lock, Node 2 has PR lock, Node 3 has PR lock too.
Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from
Node 1. downconvert thread begin to
cancel PR to EX conversion. Indlmunlock_commonfunction, downconvert thread has releasedlock->spinlockandres->spinlock, but did not enterdlm_send_remote_unlock_requestfunction.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1. change lock level to EX, move lock to granted list, set
lockres->l_unlock_actionasOCFS2_UNLOCK_INVALIDinocfs2_locking_astfunction.Node2 dies because
the host is powered down.Node 3 realize that Node 1 is dead, remove Node 1 from
domain_map. downconvert thread getDLM_NORMALfromdlm_send_remote_unlock_requestfunction and set*call_astas 1. Then downconvert thread meet BUG inocfs2_unlock_astfunction.To avoid meet the second BUG, function
dlmunlock_commonshuold returnDLM_CANCELGRANTif the lock is on granted list and the operation is canceled.Signed-off-by Jian Wang<[email protected]>Reviewed-by Yiwen Jiang<[email protected]>--- fs/ocfs2/dlm/dlmrecovery.c | 1 - fs/ocfs2/dlm/dlmunlock.c | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-)fs/ocfs2/dlm/dlmrecovery.c +0
-1@@ -2134,7 +2134,6 @@ void dlm_move_lockres_to_recovery_list(struct dlm_ctxt *dlm,* if this had completed successfully * before sending this lock state to the * new master */ -BUG_ON (i !=DLM_CONVERTING_LIST );mlog (0 ,"node died with cancel pending " "on %.*s. move back to granted list.\n" , res->lockname.len, res->lockname.name);fs/ocfs2/dlm/dlmunlock.c +4
-0@@ -183,6 +183,11 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm, flags, owner);spin_lock (&res->spinlock);spin_lock (&lock->spinlock); + +if ((flags &LKM_CANCEL ) && +dlm_lock_on_list (&res->granted, lock)) + status =DLM_CANCELGRANT ;
Quoted 9 lines
Quoted 7 lines
fs/ocfs2/dlm/dlmunlock.c +1
-0+/* if the master told us the lock was already granted, * let the ast handle all of these actions */ if (status ==DLM_CANCELGRANT ) {Signature · 1 line
1.8.3.1.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://oss.oracle.com/pipermail/ocfs2-devel/attachments/20181206/4ce296b0/attachment-0001.html
PATCH 1/1 ocfs2/dlm: return DLM_CANCELGRANT if the lock is on granted list and the operation is canceled
Hi Jian,
I suppose that the situation you described truly exists. But the way you fix the issue is not in my favor.
If you remove the BUG check why you still call dlm_commit_pending_cancel() to move the lock back to grant on matter it's on converting list or not?
So how about keeping the BUG check in dlm_move_lockres_to_recovery_list().
If the locking _ast_ comes back very fast just check ::cancel_pending in dlm_proxy_ast_handler() and clear it. Then with the logic checking if the lock is on grant list (in dlmunlock_common() more less like your current method) or not we can easily tell if the cancellation succeeds or not.
That complies the original dlm design, which I think is better and easier for maintainers to understand.
Thanks,
Changwei
Quoted 184 lines · wangjian
Hi Changwei,
I don't fully agree with your point of view. In my opinion, the lock cancellation process and the lock conversion process are asynchronous. We can't guarantee that the lock must be in the convert list during the lock conversion process, otherwise this BUG will not happen.
So, I think this is a meaningless BUG.Thanks,
JianQuoted 173 lines · Changwei Ge
Hi Jian,
I suppose you can't just remove the
BUG_ON()check. If you remove it, below code violates the original logic.'''
2141dlm_commit_pending_cancel(res, lock);
'''What's more important is *locking cancel* must be against a *locking conversion* progress. So it makes sense to check if this lock is on converting list.
So I have to NACK to this patch.
Thanks,
ChangweiQuoted 152 lines · wangjian
In the
dlm_move_lockres_to_recovery_listfunction, if the lock is in the granted queue andcancel_pendingis set, it will encounter a BUG. I think this is a meaningless BUG, so be prepared to remove it. A scenario that causes this BUG will be given below.At the beginning, Node 1 is the master and has NL lock, Node 2 has PR lock, Node 3 has PR lock too.
Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from Node 1. downconvert thread begin to cancel PR to EX conversion. In
dlmunlock_commonfunction, downconvert thread has setlock->cancel_pending, but did not enterdlm_send_remote_unlock_requestfunction.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1. change lock level to EX, move lock to granted list.
Node1 dies because
the host is powered down.In
dlm_move_lockres_to_recovery_listfunction. the lock is in the granted queue andcancel_pendingis set.BUG_ON.But after clearing this BUG, process will encounter the second BUG in the
ocfs2_unlock_astfunction. Here is a scenario that will cause the second BUG inocfs2_unlock_astas follows:At the beginning, Node 1 is the master and has NL lock, Node 2 has PR lock, Node 3 has PR lock too.
Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from
Node 1. downconvert thread begin to
cancel PR to EX conversion. Indlmunlock_commonfunction, downconvert thread has releasedlock->spinlockandres->spinlock, but did not enterdlm_send_remote_unlock_requestfunction.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1. change lock level to EX, move lock to granted list, set
lockres->l_unlock_actionasOCFS2_UNLOCK_INVALIDinocfs2_locking_astfunction.Node2 dies because
the host is powered down.Node 3 realize that Node 1 is dead, remove Node 1 from
domain_map. downconvert thread getDLM_NORMALfromdlm_send_remote_unlock_requestfunction and set*call_astas 1. Then downconvert thread meet BUG inocfs2_unlock_astfunction.To avoid meet the second BUG, function
dlmunlock_commonshuold returnDLM_CANCELGRANTif the lock is on granted list and the operation is canceled.Signed-off-by Jian Wang<[email protected]>Reviewed-by Yiwen Jiang<[email protected]>--- fs/ocfs2/dlm/dlmrecovery.c | 1 - fs/ocfs2/dlm/dlmunlock.c | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-)fs/ocfs2/dlm/dlmrecovery.c +0
-1@@ -2134,7 +2134,6 @@ void dlm_move_lockres_to_recovery_list(struct dlm_ctxt *dlm,* if this had completed successfully * before sending this lock state to the * new master */ -BUG_ON (i !=DLM_CONVERTING_LIST );mlog (0 ,"node died with cancel pending " "on %.*s. move back to granted list.\n" , res->lockname.len, res->lockname.name);fs/ocfs2/dlm/dlmunlock.c +5
-0@@ -183,6 +183,11 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm, flags, owner);spin_lock (&res->spinlock);spin_lock (&lock->spinlock); + +if ((flags &LKM_CANCEL ) && +dlm_lock_on_list (&res->granted, lock)) + status =DLM_CANCELGRANT ; +/* if the master told us the lock was already granted, * let the ast handle all of these actions */ if (status ==DLM_CANCELGRANT ) {Signature · 1 line
1.8.3.1.
PATCH 1/1 ocfs2/dlm: return DLM_CANCELGRANT if the lock is on granted list and the operation is canceled
Hi Changwei,
I understand your idea. But we should be aware that the cancel_convert process and other processes (accepting the AST process, the recovery process) are asynchronous. For example, according to your idea, check if the lock is in the grant queue before calling the dlm_send_remote_unlock_request function in the dlm_proxy_ast_handler function. Then decide whether to clear cancel_pending. But if the AST does not come at this time, the check passes and cancel_pendig will not be cleared. Then AST immediately came over again, which also led to a bug. I personally think that for asynchronous processes we can't guarantee the speed of execution of each process. All we can do is to avoid the BUG scene.
As for the question you said ("If you remove the BUG check why you still call dlm_commit_pending_cancel() to move the lock back to grant on matter it's on converting list or not?").
I think we should first check if the lock is in the grant queue
(at this time, dlm->spinlock and res->spinlock have been added), then decide whether to call dlm_commit_pending_cancel function.
Thanks,
Jian
Quoted 203 lines · Changwei Ge
Hi Jian,
I suppose that the situation you described truly exists. But the way you fix the issue is not in my favor.
If you remove the BUG check why you still call
dlm_commit_pending_cancel()to move the lock back to grant on matter it's on converting list or not?So how about keeping the BUG check in
dlm_move_lockres_to_recovery_list().
If the locking _ast_ comes back very fast just check ::cancel_pending indlm_proxy_ast_handler()and clear it. Then with the logic checking if the lock is on grant list (indlmunlock_common()more less like your current method) or not we can easily tell if the cancellation succeeds or not.That complies the original dlm design, which I think is better and easier for maintainers to understand.
Thanks,
ChangweiQuoted 7 lines · wangjian
Hi Changwei,
I don't fully agree with your point of view. In my opinion, the lock cancellation process and the lock conversion process are asynchronous. We can't guarantee that the lock must be in the convert list during the lock conversion process, otherwise this BUG will not happen.
So, I think this is a meaningless BUG.Quoted 177 lines
Thanks,
JianQuoted 173 lines · Changwei Ge
Hi Jian,
I suppose you can't just remove the
BUG_ON()check. If you remove it, below code violates the original logic.'''
2141dlm_commit_pending_cancel(res, lock);
'''What's more important is *locking cancel* must be against a *locking conversion* progress. So it makes sense to check if this lock is on converting list.
So I have to NACK to this patch.
Thanks,
ChangweiQuoted 152 lines · wangjian
In the
dlm_move_lockres_to_recovery_listfunction, if the lock is in the granted queue andcancel_pendingis set, it will encounter a BUG. I think this is a meaningless BUG, so be prepared to remove it. A scenario that causes this BUG will be given below.At the beginning, Node 1 is the master and has NL lock, Node 2 has PR lock, Node 3 has PR lock too.
Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from Node 1. downconvert thread begin to cancel PR to EX conversion. In
dlmunlock_commonfunction, downconvert thread has setlock->cancel_pending, but did not enterdlm_send_remote_unlock_requestfunction.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1. change lock level to EX, move lock to granted list.
Node1 dies because
the host is powered down.In
dlm_move_lockres_to_recovery_listfunction. the lock is in the granted queue andcancel_pendingis set.BUG_ON.But after clearing this BUG, process will encounter the second BUG in the
ocfs2_unlock_astfunction. Here is a scenario that will cause the second BUG inocfs2_unlock_astas follows:At the beginning, Node 1 is the master and has NL lock, Node 2 has PR lock, Node 3 has PR lock too.
Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from
Node 1. downconvert thread begin to
cancel PR to EX conversion. Indlmunlock_commonfunction, downconvert thread has releasedlock->spinlockandres->spinlock, but did not enterdlm_send_remote_unlock_requestfunction.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1. change lock level to EX, move lock to granted list, set
lockres->l_unlock_actionasOCFS2_UNLOCK_INVALIDinocfs2_locking_astfunction.Node2 dies because
the host is powered down.Node 3 realize that Node 1 is dead, remove Node 1 from
domain_map. downconvert thread getDLM_NORMALfromdlm_send_remote_unlock_requestfunction and set*call_astas 1. Then downconvert thread meet BUG inocfs2_unlock_astfunction.To avoid meet the second BUG, function
dlmunlock_commonshuold returnDLM_CANCELGRANTif the lock is on granted list and the operation is canceled.Signed-off-by Jian Wang<[email protected]>Reviewed-by Yiwen Jiang<[email protected]>--- fs/ocfs2/dlm/dlmrecovery.c | 1 - fs/ocfs2/dlm/dlmunlock.c | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-)fs/ocfs2/dlm/dlmrecovery.c +0
-1@@ -2134,7 +2134,6 @@ void dlm_move_lockres_to_recovery_list(struct dlm_ctxt *dlm,* if this had completed successfully * before sending this lock state to the * new master */ -BUG_ON (i !=DLM_CONVERTING_LIST );mlog (0 ,"node died with cancel pending " "on %.*s. move back to granted list.\n" , res->lockname.len, res->lockname.name);fs/ocfs2/dlm/dlmunlock.c +5
-0@@ -183,6 +183,11 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm, flags, owner);spin_lock (&res->spinlock);spin_lock (&lock->spinlock); + +if ((flags &LKM_CANCEL ) && +dlm_lock_on_list (&res->granted, lock)) + status =DLM_CANCELGRANT ; +/* if the master told us the lock was already granted, * let the ast handle all of these actions */ if (status ==DLM_CANCELGRANT ) {Signature · 1 line
1.8.3.1.
Quoted 2 lines
.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://oss.oracle.com/pipermail/ocfs2-devel/attachments/20181208/72efffab/attachment.html
PATCH 1/1 ocfs2/dlm: return DLM_CANCELGRANT if the lock is on granted list and the operation is canceled
Hi Changwei,
The problem can't be solved completely if clear ::cancel_pending in dlm_proxy_ast_handler, as AST will come at anytime just before ::cancel_pendig is set. If there is not any other better solutions, could we accept this patch? This bug is very harmful.
Thanks,
Jun
Quoted 233 lines · wangjian
Hi Changwei,
I understand your idea. But we should be aware that the
cancel_convertprocess and other processes (accepting the AST process, the recovery process) are asynchronous. For example, according to your idea, check if the lock is in the grant queue before calling thedlm_send_remote_unlock_requestfunction in thedlm_proxy_ast_handlerfunction. Then decide whether to clearcancel_pending. But if the AST does not come at this time, the check passes andcancel_pendigwill not be cleared. Then AST immediately came over again, which also led to a bug. I personally think that for asynchronous processes we can't guarantee the speed of execution of each process. All we can do is to avoid the BUG scene.As for the question you said ("If you remove the BUG check why you still call
dlm_commit_pending_cancel()to move the lock back to grant on matter it's on converting list or not?").
I think we should first check if the lock is in the grant queue
(at this time,dlm->spinlockandres->spinlockhave been added), then decide whether to calldlm_commit_pending_cancelfunction.Thanks,
JianQuoted 203 lines · Changwei Ge
Hi Jian,
I suppose that the situation you described truly exists. But the way you fix the issue is not in my favor.
If you remove the BUG check why you still call
dlm_commit_pending_cancel()to move the lock back to grant on matter it's on converting list or not?So how about keeping the BUG check in
dlm_move_lockres_to_recovery_list().
If the locking _ast_ comes back very fast just check ::cancel_pending indlm_proxy_ast_handler()and clear it. Then with the logic checking if the lock is on grant list (indlmunlock_common()more less like your current method) or not we can easily tell if the cancellation succeeds or not.That complies the original dlm design, which I think is better and easier for maintainers to understand.
Thanks,
ChangweiQuoted 7 lines · wangjian
Hi Changwei,
I don't fully agree with your point of view. In my opinion, the lock cancellation process and the lock conversion process are asynchronous. We can't guarantee that the lock must be in the convert list during the lock conversion process, otherwise this BUG will not happen.
So, I think this is a meaningless BUG.Quoted 177 lines
Thanks,
JianQuoted 173 lines · Changwei Ge
Hi Jian,
I suppose you can't just remove the
BUG_ON()check. If you remove it, below code violates the original logic.'''
2141dlm_commit_pending_cancel(res, lock);
'''What's more important is *locking cancel* must be against a *locking conversion* progress. So it makes sense to check if this lock is on converting list.
So I have to NACK to this patch.
Thanks,
ChangweiQuoted 152 lines · wangjian
In the
dlm_move_lockres_to_recovery_listfunction, if the lock is in the granted queue andcancel_pendingis set, it will encounter a BUG. I think this is a meaningless BUG, so be prepared to remove it. A scenario that causes this BUG will be given below.At the beginning, Node 1 is the master and has NL lock, Node 2 has PR lock, Node 3 has PR lock too.
Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from Node 1. downconvert thread begin to cancel PR to EX conversion. In
dlmunlock_commonfunction, downconvert thread has setlock->cancel_pending, but did not enterdlm_send_remote_unlock_requestfunction.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1. change lock level to EX, move lock to granted list.
Node1 dies because
the host is powered down.In
dlm_move_lockres_to_recovery_listfunction. the lock is in the granted queue andcancel_pendingis set.BUG_ON.But after clearing this BUG, process will encounter the second BUG in the
ocfs2_unlock_astfunction. Here is a scenario that will cause the second BUG inocfs2_unlock_astas follows:At the beginning, Node 1 is the master and has NL lock, Node 2 has PR lock, Node 3 has PR lock too.
Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from
Node 1. downconvert thread begin to
cancel PR to EX conversion. Indlmunlock_commonfunction, downconvert thread has releasedlock->spinlockandres->spinlock, but did not enterdlm_send_remote_unlock_requestfunction.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1. change lock level to EX, move lock to granted list, set
lockres->l_unlock_actionasOCFS2_UNLOCK_INVALIDinocfs2_locking_astfunction.Node2 dies because
the host is powered down.Node 3 realize that Node 1 is dead, remove Node 1 from
domain_map. downconvert thread getDLM_NORMALfromdlm_send_remote_unlock_requestfunction and set*call_astas 1. Then downconvert thread meet BUG inocfs2_unlock_astfunction.To avoid meet the second BUG, function
dlmunlock_commonshuold returnDLM_CANCELGRANTif the lock is on granted list and the operation is canceled.Signed-off-by Jian Wang<[email protected]>Reviewed-by Yiwen Jiang<[email protected]>--- fs/ocfs2/dlm/dlmrecovery.c | 1 - fs/ocfs2/dlm/dlmunlock.c | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-)fs/ocfs2/dlm/dlmrecovery.c +0
-1@@ -2134,7 +2134,6 @@ void dlm_move_lockres_to_recovery_list(struct dlm_ctxt *dlm,* if this had completed successfully * before sending this lock state to the * new master */ -BUG_ON (i !=DLM_CONVERTING_LIST );mlog (0 ,"node died with cancel pending " "on %.*s. move back to granted list.\n" , res->lockname.len, res->lockname.name);fs/ocfs2/dlm/dlmunlock.c +5
-0@@ -183,6 +183,11 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm, flags, owner);spin_lock (&res->spinlock);spin_lock (&lock->spinlock); + +if ((flags &LKM_CANCEL ) && +dlm_lock_on_list (&res->granted, lock)) + status =DLM_CANCELGRANT ; +/* if the master told us the lock was already granted, * let the ast handle all of these actions */ if (status ==DLM_CANCELGRANT ) {Signature · 1 line
1.8.3.1.
Quoted 2 lines
.
_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel
PATCH 1/1 ocfs2/dlm: return DLM_CANCELGRANT if the lock is on granted list and the operation is canceled
Hi Jun,
Quoted 6 lines · piaojun
Hi Changwei,
The problem can't be solved completely if clear ::cancel_pending in
dlm_proxy_ast_handler, as AST will come at anytime just before ::cancel_pendig is set. If there is not any other better solutions, could we accept this patch? This bug is very harmful.
Um, I am recalling the problem this patch is trying to address... If I miss something, please let me know.
I read the patch again, it seems that NODE3 finds a lock on its _grant list_ with ::cancel_pending set, which makes dlm insane. Actually, I don't like patches addressing problems killing BUG checks as it keeps the whole software consistent with its original design. With those BUG checks, we can add feature and fix bugs in an elegant way.
As we the lock is *already granted*, why not just check ::cancel_pending and if it is set, clear it and then move the lock to grant list since cancellation obviously cant work anymore. And I think we even don't have to worry about dlm_send_remote_unlock_request() since message sending will fail anyway, but function will return NORMAL as NODE1 was *dead* already.
I admit that the problem reported truly exists and should be solved but the method is not in my favor. :-) I have several reasons for your reference:
1) My biggest concern is we should not remove the BUG check ( BUG_ON(i != DLM_CONVERTING_LIST) ), because it might violate the original ocfs2/dlm design making following maintenance work hard.
2) As for another patch from Jian, it can't use LVB to boost performance that single locking procedure.
I am providing a draft code for you and Jian's reference.
root at ubuntu16:/home/chge/linux[master]# git diff
fs/ocfs2/dlm/dlmast.c +4 -1
@@ -372,8 +372,11 @@ int dlm_proxy_ast_handler(struct o2net_msg *msg, u32 len, void *data, head = &res->converting; lock =NULL ;list_for_each_entry (lock, head, list) { -if (lock->ml.cookie == cookie) +if (lock->ml.cookie == cookie) { +if (lock->cancel_pending) + lock->cancel_pending =0 ; goto do_ast; + } }
Thanks,
Changwei
Quoted 239 lines
Thanks,
JunQuoted 233 lines · wangjian
Hi Changwei,
I understand your idea. But we should be aware that the
cancel_convertprocess and other processes (accepting the AST process, the recovery process) are asynchronous. For example, according to your idea, check if the lock is in the grant queue before calling thedlm_send_remote_unlock_requestfunction in thedlm_proxy_ast_handlerfunction. Then decide whether to clearcancel_pending. But if the AST does not come at this time, the check passes andcancel_pendigwill not be cleared. Then AST immediately came over again, which also led to a bug. I personally think that for asynchronous processes we can't guarantee the speed of execution of each process. All we can do is to avoid the BUG scene.As for the question you said ("If you remove the BUG check why you still call
dlm_commit_pending_cancel()to move the lock back to grant on matter it's on converting list or not?").
I think we should first check if the lock is in the grant queue
(at this time,dlm->spinlockandres->spinlockhave been added), then decide whether to calldlm_commit_pending_cancelfunction.Thanks,
JianQuoted 203 lines · Changwei Ge
Hi Jian,
I suppose that the situation you described truly exists. But the way you fix the issue is not in my favor.
If you remove the BUG check why you still call
dlm_commit_pending_cancel()to move the lock back to grant on matter it's on converting list or not?So how about keeping the BUG check in
dlm_move_lockres_to_recovery_list().
If the locking _ast_ comes back very fast just check ::cancel_pending indlm_proxy_ast_handler()and clear it. Then with the logic checking if the lock is on grant list (indlmunlock_common()more less like your current method) or not we can easily tell if the cancellation succeeds or not.That complies the original dlm design, which I think is better and easier for maintainers to understand.
Thanks,
ChangweiQuoted 7 lines · wangjian
Hi Changwei,
I don't fully agree with your point of view. In my opinion, the lock cancellation process and the lock conversion process are asynchronous. We can't guarantee that the lock must be in the convert list during the lock conversion process, otherwise this BUG will not happen.
So, I think this is a meaningless BUG.Quoted 177 lines
Thanks,
JianQuoted 173 lines · Changwei Ge
Hi Jian,
I suppose you can't just remove the
BUG_ON()check. If you remove it, below code violates the original logic.'''
2141dlm_commit_pending_cancel(res, lock);
'''What's more important is *locking cancel* must be against a *locking conversion* progress. So it makes sense to check if this lock is on converting list.
So I have to NACK to this patch.
Thanks,
ChangweiQuoted 152 lines · wangjian
In the
dlm_move_lockres_to_recovery_listfunction, if the lock is in the granted queue andcancel_pendingis set, it will encounter a BUG. I think this is a meaningless BUG, so be prepared to remove it. A scenario that causes this BUG will be given below.At the beginning, Node 1 is the master and has NL lock, Node 2 has PR lock, Node 3 has PR lock too.
Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from Node 1. downconvert thread begin to cancel PR to EX conversion. In
dlmunlock_commonfunction, downconvert thread has setlock->cancel_pending, but did not enterdlm_send_remote_unlock_requestfunction.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1. change lock level to EX, move lock to granted list.
Node1 dies because
the host is powered down.In
dlm_move_lockres_to_recovery_listfunction. the lock is in the granted queue andcancel_pendingis set.BUG_ON.But after clearing this BUG, process will encounter the second BUG in the
ocfs2_unlock_astfunction. Here is a scenario that will cause the second BUG inocfs2_unlock_astas follows:At the beginning, Node 1 is the master and has NL lock, Node 2 has PR lock, Node 3 has PR lock too.
Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from
Node 1. downconvert thread begin to
cancel PR to EX conversion. Indlmunlock_commonfunction, downconvert thread has releasedlock->spinlockandres->spinlock, but did not enterdlm_send_remote_unlock_requestfunction.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1. change lock level to EX, move lock to granted list, set
lockres->l_unlock_actionasOCFS2_UNLOCK_INVALIDinocfs2_locking_astfunction.Node2 dies because
the host is powered down.Node 3 realize that Node 1 is dead, remove Node 1 from
domain_map. downconvert thread getDLM_NORMALfromdlm_send_remote_unlock_requestfunction and set*call_astas 1. Then downconvert thread meet BUG inocfs2_unlock_astfunction.To avoid meet the second BUG, function
dlmunlock_commonshuold returnDLM_CANCELGRANTif the lock is on granted list and the operation is canceled.Signed-off-by Jian Wang<[email protected]>Reviewed-by Yiwen Jiang<[email protected]>--- fs/ocfs2/dlm/dlmrecovery.c | 1 - fs/ocfs2/dlm/dlmunlock.c | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-)fs/ocfs2/dlm/dlmrecovery.c +0
-1@@ -2134,7 +2134,6 @@ void dlm_move_lockres_to_recovery_list(struct dlm_ctxt *dlm,* if this had completed successfully * before sending this lock state to the * new master */ -BUG_ON (i !=DLM_CONVERTING_LIST );mlog (0 ,"node died with cancel pending " "on %.*s. move back to granted list.\n" , res->lockname.len, res->lockname.name);fs/ocfs2/dlm/dlmunlock.c +5
-0@@ -183,6 +183,11 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm, flags, owner);spin_lock (&res->spinlock);spin_lock (&lock->spinlock); + +if ((flags &LKM_CANCEL ) && +dlm_lock_on_list (&res->granted, lock)) + status =DLM_CANCELGRANT ; +/* if the master told us the lock was already granted, * let the ast handle all of these actions */ if (status ==DLM_CANCELGRANT ) {Signature · 1 line
1.8.3.1.
Quoted 2 lines
.
_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel
PATCH 1/1 ocfs2/dlm: return DLM_CANCELGRANT if the lock is on granted list and the operation is canceled
Hi Changwei,
Quoted 10 lines · Changwei Ge
Hi Jun,
Quoted 6 lines · piaojun
Hi Changwei,
The problem can't be solved completely if clear ::cancel_pending in
dlm_proxy_ast_handler, as AST will come at anytime just before ::cancel_pendig is set. If there is not any other better solutions, could we accept this patch? This bug is very harmful.
Quoted 6 lines
Um, I am recalling the problem this patch is trying to address... If I miss something, please let me know.
I read the patch again, it seems that NODE3 finds a lock on its
_grantlist_with ::cancel_pending set, which makes dlm insane. Actually, I don't like patches addressing problems killing BUG checks as it keeps the whole software consistent with its original design. With those BUG checks, we can add feature and fix bugs in an elegant way.
I also agree this.
Quoted 20 lines
As we the lock is *already granted*, why not just check ::cancel_pending and if it is set, clear it and then move the lock to grant list since cancellation obviously cant work anymore. And I think we even don't have to worry about
dlm_send_remote_unlock_request()since message sending will fail anyway, but function will return NORMAL as NODE1 was *dead* already.I admit that the problem reported truly exists and should be solved but the method is not in my favor. :-) I have several reasons for your reference:
1) My biggest concern is we should not remove the BUG check (BUG_ON(i != DLM_CONVERTING_LIST)), because it might violate the original ocfs2/dlm design making following maintenance work hard.
2) As for another patch from Jian, it can't use LVB to boost performance that single locking procedure.I am providing a draft code for you and Jian's reference.
root at ubuntu16:/home/chge/linux[master]# git diff
fs/ocfs2/dlm/dlmast.c +0
-0
fs/ocfs2/dlm/dlmast.c int dlm_proxy_ast_handler(struct o2net_msg *msg, u32 len, void *data, · line 377
Quoted 7 lines
fs/ocfs2/dlm/dlmast.c +3
-1@@ -372,8 +372,11 @@ int dlm_proxy_ast_handler(struct o2net_msg *msg, u32 len, void *data, head = &res->converting; lock =NULL ;list_for_each_entry (lock, head, list) { -if (lock->ml.cookie == cookie) +if (lock->ml.cookie == cookie) { +if (lock->cancel_pending) + lock->cancel_pending =0 ;
I'm afraid that there is a case lock->cancel_pending is not set yet in dlmunlock_common, so this problem still exist.
Quoted 249 lines
fs/ocfs2/dlm/dlmast.c +1
-0goto do_ast; + } } Thanks,Changwei
Quoted 239 lines
Thanks,
JunQuoted 233 lines · wangjian
Hi Changwei,
I understand your idea. But we should be aware that the
cancel_convertprocess and other processes (accepting the AST process, the recovery process) are asynchronous. For example, according to your idea, check if the lock is in the grant queue before calling thedlm_send_remote_unlock_requestfunction in thedlm_proxy_ast_handlerfunction. Then decide whether to clearcancel_pending. But if the AST does not come at this time, the check passes andcancel_pendigwill not be cleared. Then AST immediately came over again, which also led to a bug. I personally think that for asynchronous processes we can't guarantee the speed of execution of each process. All we can do is to avoid the BUG scene.As for the question you said ("If you remove the BUG check why you still call
dlm_commit_pending_cancel()to move the lock back to grant on matter it's on converting list or not?").
I think we should first check if the lock is in the grant queue
(at this time,dlm->spinlockandres->spinlockhave been added), then decide whether to calldlm_commit_pending_cancelfunction.Thanks,
JianQuoted 203 lines · Changwei Ge
Hi Jian,
I suppose that the situation you described truly exists. But the way you fix the issue is not in my favor.
If you remove the BUG check why you still call
dlm_commit_pending_cancel()to move the lock back to grant on matter it's on converting list or not?So how about keeping the BUG check in
dlm_move_lockres_to_recovery_list().
If the locking _ast_ comes back very fast just check ::cancel_pending indlm_proxy_ast_handler()and clear it. Then with the logic checking if the lock is on grant list (indlmunlock_common()more less like your current method) or not we can easily tell if the cancellation succeeds or not.That complies the original dlm design, which I think is better and easier for maintainers to understand.
Thanks,
ChangweiQuoted 7 lines · wangjian
Hi Changwei,
I don't fully agree with your point of view. In my opinion, the lock cancellation process and the lock conversion process are asynchronous. We can't guarantee that the lock must be in the convert list during the lock conversion process, otherwise this BUG will not happen.
So, I think this is a meaningless BUG.Quoted 177 lines
Thanks,
JianQuoted 173 lines · Changwei Ge
Hi Jian,
I suppose you can't just remove the
BUG_ON()check. If you remove it, below code violates the original logic.'''
2141dlm_commit_pending_cancel(res, lock);
'''What's more important is *locking cancel* must be against a *locking conversion* progress. So it makes sense to check if this lock is on converting list.
So I have to NACK to this patch.
Thanks,
ChangweiQuoted 152 lines · wangjian
In the
dlm_move_lockres_to_recovery_listfunction, if the lock is in the granted queue andcancel_pendingis set, it will encounter a BUG. I think this is a meaningless BUG, so be prepared to remove it. A scenario that causes this BUG will be given below.At the beginning, Node 1 is the master and has NL lock, Node 2 has PR lock, Node 3 has PR lock too.
Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from Node 1. downconvert thread begin to cancel PR to EX conversion. In
dlmunlock_commonfunction, downconvert thread has setlock->cancel_pending, but did not enterdlm_send_remote_unlock_requestfunction.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1. change lock level to EX, move lock to granted list.
Node1 dies because
the host is powered down.In
dlm_move_lockres_to_recovery_listfunction. the lock is in the granted queue andcancel_pendingis set.BUG_ON.But after clearing this BUG, process will encounter the second BUG in the
ocfs2_unlock_astfunction. Here is a scenario that will cause the second BUG inocfs2_unlock_astas follows:At the beginning, Node 1 is the master and has NL lock, Node 2 has PR lock, Node 3 has PR lock too.
Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from
Node 1. downconvert thread begin to
cancel PR to EX conversion. Indlmunlock_commonfunction, downconvert thread has releasedlock->spinlockandres->spinlock, but did not enterdlm_send_remote_unlock_requestfunction.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1. change lock level to EX, move lock to granted list, set
lockres->l_unlock_actionasOCFS2_UNLOCK_INVALIDinocfs2_locking_astfunction.Node2 dies because
the host is powered down.Node 3 realize that Node 1 is dead, remove Node 1 from
domain_map. downconvert thread getDLM_NORMALfromdlm_send_remote_unlock_requestfunction and set*call_astas 1. Then downconvert thread meet BUG inocfs2_unlock_astfunction.To avoid meet the second BUG, function
dlmunlock_commonshuold returnDLM_CANCELGRANTif the lock is on granted list and the operation is canceled.Signed-off-by Jian Wang<[email protected]>Reviewed-by Yiwen Jiang<[email protected]>--- fs/ocfs2/dlm/dlmrecovery.c | 1 - fs/ocfs2/dlm/dlmunlock.c | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-)fs/ocfs2/dlm/dlmrecovery.c +0
-1@@ -2134,7 +2134,6 @@ void dlm_move_lockres_to_recovery_list(struct dlm_ctxt *dlm,* if this had completed successfully * before sending this lock state to the * new master */ -BUG_ON (i !=DLM_CONVERTING_LIST );mlog (0 ,"node died with cancel pending " "on %.*s. move back to granted list.\n" , res->lockname.len, res->lockname.name);fs/ocfs2/dlm/dlmunlock.c +5
-0@@ -183,6 +183,11 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm, flags, owner);spin_lock (&res->spinlock);spin_lock (&lock->spinlock); + +if ((flags &LKM_CANCEL ) && +dlm_lock_on_list (&res->granted, lock)) + status =DLM_CANCELGRANT ; +/* if the master told us the lock was already granted, * let the ast handle all of these actions */ if (status ==DLM_CANCELGRANT ) {Signature · 1 line
1.8.3.1.
Quoted 2 lines
.
_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel.
PATCH 1/1 ocfs2/dlm: return DLM_CANCELGRANT if the lock is on granted list and the operation is canceled
Quoted 36 lines · piaojun
Hi Changwei,
Quoted 10 lines · Changwei Ge
Hi Jun,
Quoted 6 lines · piaojun
Hi Changwei,
The problem can't be solved completely if clear ::cancel_pending in
dlm_proxy_ast_handler, as AST will come at anytime just before ::cancel_pendig is set. If there is not any other better solutions, could we accept this patch? This bug is very harmful.Quoted 6 lines
Um, I am recalling the problem this patch is trying to address... If I miss something, please let me know.
I read the patch again, it seems that NODE3 finds a lock on its
_grantlist_with ::cancel_pending set, which makes dlm insane. Actually, I don't like patches addressing problems killing BUG checks as it keeps the whole software consistent with its original design. With those BUG checks, we can add feature and fix bugs in an elegant way.I also agree this.
Quoted 14 lines
As we the lock is *already granted*, why not just check ::cancel_pending and if it is set, clear it and then move the lock to grant list since cancellation obviously cant work anymore. And I think we even don't have to worry about
dlm_send_remote_unlock_request()since message sending will fail anyway, but function will return NORMAL as NODE1 was *dead* already.I admit that the problem reported truly exists and should be solved but the method is not in my favor. :-) I have several reasons for your reference:
1) My biggest concern is we should not remove the BUG check (BUG_ON(i != DLM_CONVERTING_LIST)), because it might violate the original ocfs2/dlm design making following maintenance work hard.
2) As for another patch from Jian, it can't use LVB to boost performance that single locking procedure.I am providing a draft code for you and Jian's reference.
Quoted 16 lines
fs/ocfs2/dlm/dlmast.c int dlm_proxy_ast_handler(struct o2net_msg *msg, u32 len, void *data, · line 377
Quoted 13 lines
root at ubuntu16:/home/chge/linux[master]# git diff
fs/ocfs2/dlm/dlmast.c +3
-1@@ -372,8 +372,11 @@ int dlm_proxy_ast_handler(struct o2net_msg *msg, u32 len, void *data, head = &res->converting; lock =NULL ;list_for_each_entry (lock, head, list) { -if (lock->ml.cookie == cookie) +if (lock->ml.cookie == cookie) { +if (lock->cancel_pending) + lock->cancel_pending =0 ;I'm afraid that there is a case
lock->cancel_pendingis not set yet indlmunlock_common, so this problem still exist.
Please refer to my another mail which might close the race you are concerning.
Quoted 251 lines
Quoted 250 lines
fs/ocfs2/dlm/dlmast.c +1
-0goto do_ast; + } } Thanks,Changwei
Quoted 239 lines
Thanks,
JunQuoted 233 lines · wangjian
Hi Changwei,
I understand your idea. But we should be aware that the
cancel_convertprocess and other processes (accepting the AST process, the recovery process) are asynchronous. For example, according to your idea, check if the lock is in the grant queue before calling thedlm_send_remote_unlock_requestfunction in thedlm_proxy_ast_handlerfunction. Then decide whether to clearcancel_pending. But if the AST does not come at this time, the check passes andcancel_pendigwill not be cleared. Then AST immediately came over again, which also led to a bug. I personally think that for asynchronous processes we can't guarantee the speed of execution of each process. All we can do is to avoid the BUG scene.As for the question you said ("If you remove the BUG check why you still call
dlm_commit_pending_cancel()to move the lock back to grant on matter it's on converting list or not?").
I think we should first check if the lock is in the grant queue
(at this time,dlm->spinlockandres->spinlockhave been added), then decide whether to calldlm_commit_pending_cancelfunction.Thanks,
JianQuoted 203 lines · Changwei Ge
Hi Jian,
I suppose that the situation you described truly exists. But the way you fix the issue is not in my favor.
If you remove the BUG check why you still call
dlm_commit_pending_cancel()to move the lock back to grant on matter it's on converting list or not?So how about keeping the BUG check in
dlm_move_lockres_to_recovery_list().
If the locking _ast_ comes back very fast just check ::cancel_pending indlm_proxy_ast_handler()and clear it. Then with the logic checking if the lock is on grant list (indlmunlock_common()more less like your current method) or not we can easily tell if the cancellation succeeds or not.That complies the original dlm design, which I think is better and easier for maintainers to understand.
Thanks,
ChangweiQuoted 7 lines · wangjian
Hi Changwei,
I don't fully agree with your point of view. In my opinion, the lock cancellation process and the lock conversion process are asynchronous. We can't guarantee that the lock must be in the convert list during the lock conversion process, otherwise this BUG will not happen.
So, I think this is a meaningless BUG.Quoted 177 lines
Thanks,
JianQuoted 173 lines · Changwei Ge
Hi Jian,
I suppose you can't just remove the
BUG_ON()check. If you remove it, below code violates the original logic.'''
2141dlm_commit_pending_cancel(res, lock);
'''What's more important is *locking cancel* must be against a *locking conversion* progress. So it makes sense to check if this lock is on converting list.
So I have to NACK to this patch.
Thanks,
ChangweiQuoted 152 lines · wangjian
In the
dlm_move_lockres_to_recovery_listfunction, if the lock is in the granted queue andcancel_pendingis set, it will encounter a BUG. I think this is a meaningless BUG, so be prepared to remove it. A scenario that causes this BUG will be given below.At the beginning, Node 1 is the master and has NL lock, Node 2 has PR lock, Node 3 has PR lock too.
Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from Node 1. downconvert thread begin to cancel PR to EX conversion. In
dlmunlock_commonfunction, downconvert thread has setlock->cancel_pending, but did not enterdlm_send_remote_unlock_requestfunction.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1. change lock level to EX, move lock to granted list.
Node1 dies because
the host is powered down.In
dlm_move_lockres_to_recovery_listfunction. the lock is in the granted queue andcancel_pendingis set.BUG_ON.But after clearing this BUG, process will encounter the second BUG in the
ocfs2_unlock_astfunction. Here is a scenario that will cause the second BUG inocfs2_unlock_astas follows:At the beginning, Node 1 is the master and has NL lock, Node 2 has PR lock, Node 3 has PR lock too.
Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from
Node 1. downconvert thread begin to
cancel PR to EX conversion. Indlmunlock_commonfunction, downconvert thread has releasedlock->spinlockandres->spinlock, but did not enterdlm_send_remote_unlock_requestfunction.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1. change lock level to EX, move lock to granted list, set
lockres->l_unlock_actionasOCFS2_UNLOCK_INVALIDinocfs2_locking_astfunction.Node2 dies because
the host is powered down.Node 3 realize that Node 1 is dead, remove Node 1 from
domain_map. downconvert thread getDLM_NORMALfromdlm_send_remote_unlock_requestfunction and set*call_astas 1. Then downconvert thread meet BUG inocfs2_unlock_astfunction.To avoid meet the second BUG, function
dlmunlock_commonshuold returnDLM_CANCELGRANTif the lock is on granted list and the operation is canceled.Signed-off-by Jian Wang<[email protected]>Reviewed-by Yiwen Jiang<[email protected]>--- fs/ocfs2/dlm/dlmrecovery.c | 1 - fs/ocfs2/dlm/dlmunlock.c | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-)fs/ocfs2/dlm/dlmrecovery.c +0
-1@@ -2134,7 +2134,6 @@ void dlm_move_lockres_to_recovery_list(struct dlm_ctxt *dlm,* if this had completed successfully * before sending this lock state to the * new master */ -BUG_ON (i !=DLM_CONVERTING_LIST );mlog (0 ,"node died with cancel pending " "on %.*s. move back to granted list.\n" , res->lockname.len, res->lockname.name);fs/ocfs2/dlm/dlmunlock.c +5
-0@@ -183,6 +183,11 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm, flags, owner);spin_lock (&res->spinlock);spin_lock (&lock->spinlock); + +if ((flags &LKM_CANCEL ) && +dlm_lock_on_list (&res->granted, lock)) + status =DLM_CANCELGRANT ; +/* if the master told us the lock was already granted, * let the ast handle all of these actions */ if (status ==DLM_CANCELGRANT ) {Signature · 1 line
1.8.3.1.
Quoted 2 lines
.
_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel.
PATCH 1/1 ocfs2/dlm: return DLM_CANCELGRANT if the lock is on granted list and the operation is canceled
In reply to piaojunQuoted 4 lines · piaojun
Hi Changwei,
The problem can't be solved completely if clear ::cancel_pending in
dlm_proxy_ast_handler, as AST will come at anytime just before
So how about also add check here bere setting ::cancel_pending in dlmunlock_common() before invoking dlm_send_remote_unlock_request(). If already on grant list just return DLM_CANCELGRANT
Then a further reference code might look like:
root at ubuntu16:/home/chge/linux[master]# git diff
fs/ocfs2/dlm/dlmast.c +4 -1
@@ -372,8 +372,11 @@ int dlm_proxy_ast_handler(struct o2net_msg *msg, u32 len, void *data, head = &res->converting; lock =NULL ;list_for_each_entry (lock, head, list) { -if (lock->ml.cookie == cookie) +if (lock->ml.cookie == cookie) { +if (lock->cancel_pending) + lock->cancel_pending =0 ; goto do_ast; + } }/* if not on convert, try blocked for ast, granted for bast */
fs/ocfs2/dlm/dlmunlock.c +7 -2
@@ -174,9 +174,14 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm,if (!master_node) { owner = res->owner;/* drop locks and send message */ -if (flags &LKM_CANCEL ) +if (flags &LKM_CANCEL ) { +if (dlm_lock_on_list (&res->granted, lock)) { + status =DLM_CANCELGRANT ; + goto leave; + } + lock->cancel_pending =1 ; -else + }else lock->unlock_pending =1 ;spin_unlock (&lock->spinlock);spin_unlock (&res->spinlock);
Thanks,
Changwei
Quoted 241 lines
::cancel_pendig is set. If there is not any other better solutions, could we accept this patch? This bug is very harmful.
Thanks,
JunQuoted 233 lines · wangjian
Hi Changwei,
I understand your idea. But we should be aware that the
cancel_convertprocess and other processes (accepting the AST process, the recovery process) are asynchronous. For example, according to your idea, check if the lock is in the grant queue before calling thedlm_send_remote_unlock_requestfunction in thedlm_proxy_ast_handlerfunction. Then decide whether to clearcancel_pending. But if the AST does not come at this time, the check passes andcancel_pendigwill not be cleared. Then AST immediately came over again, which also led to a bug. I personally think that for asynchronous processes we can't guarantee the speed of execution of each process. All we can do is to avoid the BUG scene.As for the question you said ("If you remove the BUG check why you still call
dlm_commit_pending_cancel()to move the lock back to grant on matter it's on converting list or not?").
I think we should first check if the lock is in the grant queue
(at this time,dlm->spinlockandres->spinlockhave been added), then decide whether to calldlm_commit_pending_cancelfunction.Thanks,
JianQuoted 203 lines · Changwei Ge
Hi Jian,
I suppose that the situation you described truly exists. But the way you fix the issue is not in my favor.
If you remove the BUG check why you still call
dlm_commit_pending_cancel()to move the lock back to grant on matter it's on converting list or not?So how about keeping the BUG check in
dlm_move_lockres_to_recovery_list().
If the locking _ast_ comes back very fast just check ::cancel_pending indlm_proxy_ast_handler()and clear it. Then with the logic checking if the lock is on grant list (indlmunlock_common()more less like your current method) or not we can easily tell if the cancellation succeeds or not.That complies the original dlm design, which I think is better and easier for maintainers to understand.
Thanks,
ChangweiQuoted 7 lines · wangjian
Hi Changwei,
I don't fully agree with your point of view. In my opinion, the lock cancellation process and the lock conversion process are asynchronous. We can't guarantee that the lock must be in the convert list during the lock conversion process, otherwise this BUG will not happen.
So, I think this is a meaningless BUG.Quoted 177 lines
Thanks,
JianQuoted 173 lines · Changwei Ge
Hi Jian,
I suppose you can't just remove the
BUG_ON()check. If you remove it, below code violates the original logic.'''
2141dlm_commit_pending_cancel(res, lock);
'''What's more important is *locking cancel* must be against a *locking conversion* progress. So it makes sense to check if this lock is on converting list.
So I have to NACK to this patch.
Thanks,
ChangweiQuoted 152 lines · wangjian
In the
dlm_move_lockres_to_recovery_listfunction, if the lock is in the granted queue andcancel_pendingis set, it will encounter a BUG. I think this is a meaningless BUG, so be prepared to remove it. A scenario that causes this BUG will be given below.At the beginning, Node 1 is the master and has NL lock, Node 2 has PR lock, Node 3 has PR lock too.
Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from Node 1. downconvert thread begin to cancel PR to EX conversion. In
dlmunlock_commonfunction, downconvert thread has setlock->cancel_pending, but did not enterdlm_send_remote_unlock_requestfunction.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1. change lock level to EX, move lock to granted list.
Node1 dies because
the host is powered down.In
dlm_move_lockres_to_recovery_listfunction. the lock is in the granted queue andcancel_pendingis set.BUG_ON.But after clearing this BUG, process will encounter the second BUG in the
ocfs2_unlock_astfunction. Here is a scenario that will cause the second BUG inocfs2_unlock_astas follows:At the beginning, Node 1 is the master and has NL lock, Node 2 has PR lock, Node 3 has PR lock too.
Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from
Node 1. downconvert thread begin to
cancel PR to EX conversion. Indlmunlock_commonfunction, downconvert thread has releasedlock->spinlockandres->spinlock, but did not enterdlm_send_remote_unlock_requestfunction.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1. change lock level to EX, move lock to granted list, set
lockres->l_unlock_actionasOCFS2_UNLOCK_INVALIDinocfs2_locking_astfunction.Node2 dies because
the host is powered down.Node 3 realize that Node 1 is dead, remove Node 1 from
domain_map. downconvert thread getDLM_NORMALfromdlm_send_remote_unlock_requestfunction and set*call_astas 1. Then downconvert thread meet BUG inocfs2_unlock_astfunction.To avoid meet the second BUG, function
dlmunlock_commonshuold returnDLM_CANCELGRANTif the lock is on granted list and the operation is canceled.Signed-off-by Jian Wang<[email protected]>Reviewed-by Yiwen Jiang<[email protected]>--- fs/ocfs2/dlm/dlmrecovery.c | 1 - fs/ocfs2/dlm/dlmunlock.c | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-)fs/ocfs2/dlm/dlmrecovery.c +0
-1@@ -2134,7 +2134,6 @@ void dlm_move_lockres_to_recovery_list(struct dlm_ctxt *dlm,* if this had completed successfully * before sending this lock state to the * new master */ -BUG_ON (i !=DLM_CONVERTING_LIST );mlog (0 ,"node died with cancel pending " "on %.*s. move back to granted list.\n" , res->lockname.len, res->lockname.name);fs/ocfs2/dlm/dlmunlock.c +5
-0@@ -183,6 +183,11 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm, flags, owner);spin_lock (&res->spinlock);spin_lock (&lock->spinlock); + +if ((flags &LKM_CANCEL ) && +dlm_lock_on_list (&res->granted, lock)) + status =DLM_CANCELGRANT ; +/* if the master told us the lock was already granted, * let the ast handle all of these actions */ if (status ==DLM_CANCELGRANT ) {Signature · 1 line
1.8.3.1.
Quoted 2 lines
.
_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel
PATCH 1/1 ocfs2/dlm: return DLM_CANCELGRANT if the lock is on granted list and the operation is canceled
Hi Changwei,
Quoted 34 lines · Changwei Ge
Quoted 4 lines · piaojun
Hi Changwei,
The problem can't be solved completely if clear ::cancel_pending in
dlm_proxy_ast_handler, as AST will come at anytime just beforeSo how about also add check here bere setting ::cancel_pending in
dlmunlock_common()before invokingdlm_send_remote_unlock_request(). If already on grant list just returnDLM_CANCELGRANTThen a further reference code might look like:
root at ubuntu16:/home/chge/linux[master]# git diff
fs/ocfs2/dlm/dlmast.c +4
-1@@ -372,8 +372,11 @@ int dlm_proxy_ast_handler(struct o2net_msg *msg, u32 len, void *data, head = &res->converting; lock =NULL ;list_for_each_entry (lock, head, list) { -if (lock->ml.cookie == cookie) +if (lock->ml.cookie == cookie) { +if (lock->cancel_pending) + lock->cancel_pending =0 ; goto do_ast; + } }/* if not on convert, try blocked for ast, granted for bast */ fs/ocfs2/dlm/dlmunlock.c +0
-0
fs/ocfs2/dlm/dlmunlock.c static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm, · line 180
Quoted 8 lines
fs/ocfs2/dlm/dlmunlock.c +4
-1@@ -174,9 +174,14 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm,if (!master_node) { owner = res->owner;/* drop locks and send message */ -if (flags &LKM_CANCEL ) +if (flags &LKM_CANCEL ) { +if (dlm_lock_on_list (&res->granted, lock)) { + status =DLM_CANCELGRANT ; + goto leave;
If master dead and then lockres is moved to granted list in dlm_move_lockres_to_recovery_list, the OCFS2_LOCK_BUSY is not cleared. And this will cause stuck problem when ocfs2_drop_lock. The reason is that unlock ast won't be done when DLM_CANCELGRANT is set. So I think we need distinguish all the cases of moving lockres to grant list.
Quoted 257 lines
fs/ocfs2/dlm/dlmunlock.c +3
-1+ } + lock->cancel_pending =1 ; - else + }else lock->unlock_pending =1 ;spin_unlock (&lock->spinlock);spin_unlock (&res->spinlock);Thanks,
ChangweiQuoted 241 lines
::cancel_pendig is set. If there is not any other better solutions, could we accept this patch? This bug is very harmful.
Thanks,
JunQuoted 233 lines · wangjian
Hi Changwei,
I understand your idea. But we should be aware that the
cancel_convertprocess and other processes (accepting the AST process, the recovery process) are asynchronous. For example, according to your idea, check if the lock is in the grant queue before calling thedlm_send_remote_unlock_requestfunction in thedlm_proxy_ast_handlerfunction. Then decide whether to clearcancel_pending. But if the AST does not come at this time, the check passes andcancel_pendigwill not be cleared. Then AST immediately came over again, which also led to a bug. I personally think that for asynchronous processes we can't guarantee the speed of execution of each process. All we can do is to avoid the BUG scene.As for the question you said ("If you remove the BUG check why you still call
dlm_commit_pending_cancel()to move the lock back to grant on matter it's on converting list or not?").
I think we should first check if the lock is in the grant queue
(at this time,dlm->spinlockandres->spinlockhave been added), then decide whether to calldlm_commit_pending_cancelfunction.Thanks,
JianQuoted 203 lines · Changwei Ge
Hi Jian,
I suppose that the situation you described truly exists. But the way you fix the issue is not in my favor.
If you remove the BUG check why you still call
dlm_commit_pending_cancel()to move the lock back to grant on matter it's on converting list or not?So how about keeping the BUG check in
dlm_move_lockres_to_recovery_list().
If the locking _ast_ comes back very fast just check ::cancel_pending indlm_proxy_ast_handler()and clear it. Then with the logic checking if the lock is on grant list (indlmunlock_common()more less like your current method) or not we can easily tell if the cancellation succeeds or not.That complies the original dlm design, which I think is better and easier for maintainers to understand.
Thanks,
ChangweiQuoted 7 lines · wangjian
Hi Changwei,
I don't fully agree with your point of view. In my opinion, the lock cancellation process and the lock conversion process are asynchronous. We can't guarantee that the lock must be in the convert list during the lock conversion process, otherwise this BUG will not happen.
So, I think this is a meaningless BUG.Quoted 177 lines
Thanks,
JianQuoted 173 lines · Changwei Ge
Hi Jian,
I suppose you can't just remove the
BUG_ON()check. If you remove it, below code violates the original logic.'''
2141dlm_commit_pending_cancel(res, lock);
'''What's more important is *locking cancel* must be against a *locking conversion* progress. So it makes sense to check if this lock is on converting list.
So I have to NACK to this patch.
Thanks,
ChangweiQuoted 152 lines · wangjian
In the
dlm_move_lockres_to_recovery_listfunction, if the lock is in the granted queue andcancel_pendingis set, it will encounter a BUG. I think this is a meaningless BUG, so be prepared to remove it. A scenario that causes this BUG will be given below.At the beginning, Node 1 is the master and has NL lock, Node 2 has PR lock, Node 3 has PR lock too.
Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from Node 1. downconvert thread begin to cancel PR to EX conversion. In
dlmunlock_commonfunction, downconvert thread has setlock->cancel_pending, but did not enterdlm_send_remote_unlock_requestfunction.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1. change lock level to EX, move lock to granted list.
Node1 dies because
the host is powered down.In
dlm_move_lockres_to_recovery_listfunction. the lock is in the granted queue andcancel_pendingis set.BUG_ON.But after clearing this BUG, process will encounter the second BUG in the
ocfs2_unlock_astfunction. Here is a scenario that will cause the second BUG inocfs2_unlock_astas follows:At the beginning, Node 1 is the master and has NL lock, Node 2 has PR lock, Node 3 has PR lock too.
Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from
Node 1. downconvert thread begin to
cancel PR to EX conversion. Indlmunlock_commonfunction, downconvert thread has releasedlock->spinlockandres->spinlock, but did not enterdlm_send_remote_unlock_requestfunction.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1. change lock level to EX, move lock to granted list, set
lockres->l_unlock_actionasOCFS2_UNLOCK_INVALIDinocfs2_locking_astfunction.Node2 dies because
the host is powered down.Node 3 realize that Node 1 is dead, remove Node 1 from
domain_map. downconvert thread getDLM_NORMALfromdlm_send_remote_unlock_requestfunction and set*call_astas 1. Then downconvert thread meet BUG inocfs2_unlock_astfunction.To avoid meet the second BUG, function
dlmunlock_commonshuold returnDLM_CANCELGRANTif the lock is on granted list and the operation is canceled.Signed-off-by Jian Wang<[email protected]>Reviewed-by Yiwen Jiang<[email protected]>--- fs/ocfs2/dlm/dlmrecovery.c | 1 - fs/ocfs2/dlm/dlmunlock.c | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-)fs/ocfs2/dlm/dlmrecovery.c +0
-1@@ -2134,7 +2134,6 @@ void dlm_move_lockres_to_recovery_list(struct dlm_ctxt *dlm,* if this had completed successfully * before sending this lock state to the * new master */ -BUG_ON (i !=DLM_CONVERTING_LIST );mlog (0 ,"node died with cancel pending " "on %.*s. move back to granted list.\n" , res->lockname.len, res->lockname.name);fs/ocfs2/dlm/dlmunlock.c +5
-0@@ -183,6 +183,11 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm, flags, owner);spin_lock (&res->spinlock);spin_lock (&lock->spinlock); + +if ((flags &LKM_CANCEL ) && +dlm_lock_on_list (&res->granted, lock)) + status =DLM_CANCELGRANT ; +/* if the master told us the lock was already granted, * let the ast handle all of these actions */ if (status ==DLM_CANCELGRANT ) {Signature · 1 line
1.8.3.1.
Quoted 2 lines
.
_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel.
PATCH 1/1 ocfs2/dlm: return DLM_CANCELGRANT if the lock is on granted list and the operation is canceled
Hi Jun,
Quoted 40 lines · piaojun
Hi Changwei,
Quoted 37 lines · Changwei Ge
Quoted 4 lines · piaojun
Hi Changwei,
The problem can't be solved completely if clear ::cancel_pending in
dlm_proxy_ast_handler, as AST will come at anytime just beforeSo how about also add check here bere setting ::cancel_pending in
dlmunlock_common()before invokingdlm_send_remote_unlock_request(). If already on grant list just returnDLM_CANCELGRANTThen a further reference code might look like:
root at ubuntu16:/home/chge/linux[master]# git diff
fs/ocfs2/dlm/dlmast.c +4
-1@@ -372,8 +372,11 @@ int dlm_proxy_ast_handler(struct o2net_msg *msg, u32 len, void *data, head = &res->converting; lock =NULL ;list_for_each_entry (lock, head, list) { -if (lock->ml.cookie == cookie) +if (lock->ml.cookie == cookie) { +if (lock->cancel_pending) + lock->cancel_pending =0 ; goto do_ast; + } }/* if not on convert, try blocked for ast, granted for bast */ fs/ocfs2/dlm/dlmunlock.c +0
-0@@ -174,9 +174,14 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm,if (!master_node) { owner = res->owner;/* drop locks and send message */
Quoted 8 lines
fs/ocfs2/dlm/dlmunlock.c static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm, · line 180
Quoted 5 lines
fs/ocfs2/dlm/dlmunlock.c +4
-1-if (flags &LKM_CANCEL ) +if (flags &LKM_CANCEL ) { +if (dlm_lock_on_list (&res->granted, lock)) { + status =DLM_CANCELGRANT ; + goto leave;If master dead and then lockres is moved to granted list in
dlm_move_lockres_to_recovery_list, theOCFS2_LOCK_BUSYis not cleared.
OCFS2_LOCK_BUSY should be cleared in ocfs2_locking_ast() since previous locking AST has come back(moving lock to grant list). That's why we return DLM_CANCELGRANT to caller to avoid calling AST. Otherwise ast() will be called twice, which is obviously a BUG.
Quoted 2 lines
And this will cause stuck problem when
ocfs2_drop_lock. The reason is that unlock ast won't be done whenDLM_CANCELGRANTis set. So I think
With above elaboration, you don't have to worry the hang issue anymore.
Thanks,
Changwei
Quoted 260 lines
we need distinguish all the cases of moving lockres to grant list.
Quoted 257 lines
fs/ocfs2/dlm/dlmunlock.c +3
-1+ } + lock->cancel_pending =1 ; - else + }else lock->unlock_pending =1 ;spin_unlock (&lock->spinlock);spin_unlock (&res->spinlock);Thanks,
ChangweiQuoted 241 lines
::cancel_pendig is set. If there is not any other better solutions, could we accept this patch? This bug is very harmful.
Thanks,
JunQuoted 233 lines · wangjian
Hi Changwei,
I understand your idea. But we should be aware that the
cancel_convertprocess and other processes (accepting the AST process, the recovery process) are asynchronous. For example, according to your idea, check if the lock is in the grant queue before calling thedlm_send_remote_unlock_requestfunction in thedlm_proxy_ast_handlerfunction. Then decide whether to clearcancel_pending. But if the AST does not come at this time, the check passes andcancel_pendigwill not be cleared. Then AST immediately came over again, which also led to a bug. I personally think that for asynchronous processes we can't guarantee the speed of execution of each process. All we can do is to avoid the BUG scene.As for the question you said ("If you remove the BUG check why you still call
dlm_commit_pending_cancel()to move the lock back to grant on matter it's on converting list or not?").
I think we should first check if the lock is in the grant queue
(at this time,dlm->spinlockandres->spinlockhave been added), then decide whether to calldlm_commit_pending_cancelfunction.Thanks,
JianQuoted 203 lines · Changwei Ge
Hi Jian,
I suppose that the situation you described truly exists. But the way you fix the issue is not in my favor.
If you remove the BUG check why you still call
dlm_commit_pending_cancel()to move the lock back to grant on matter it's on converting list or not?So how about keeping the BUG check in
dlm_move_lockres_to_recovery_list().
If the locking _ast_ comes back very fast just check ::cancel_pending indlm_proxy_ast_handler()and clear it. Then with the logic checking if the lock is on grant list (indlmunlock_common()more less like your current method) or not we can easily tell if the cancellation succeeds or not.That complies the original dlm design, which I think is better and easier for maintainers to understand.
Thanks,
ChangweiQuoted 7 lines · wangjian
Hi Changwei,
I don't fully agree with your point of view. In my opinion, the lock cancellation process and the lock conversion process are asynchronous. We can't guarantee that the lock must be in the convert list during the lock conversion process, otherwise this BUG will not happen.
So, I think this is a meaningless BUG.Quoted 177 lines
Thanks,
JianQuoted 173 lines · Changwei Ge
Hi Jian,
I suppose you can't just remove the
BUG_ON()check. If you remove it, below code violates the original logic.'''
2141dlm_commit_pending_cancel(res, lock);
'''What's more important is *locking cancel* must be against a *locking conversion* progress. So it makes sense to check if this lock is on converting list.
So I have to NACK to this patch.
Thanks,
ChangweiQuoted 152 lines · wangjian
In the
dlm_move_lockres_to_recovery_listfunction, if the lock is in the granted queue andcancel_pendingis set, it will encounter a BUG. I think this is a meaningless BUG, so be prepared to remove it. A scenario that causes this BUG will be given below.At the beginning, Node 1 is the master and has NL lock, Node 2 has PR lock, Node 3 has PR lock too.
Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from Node 1. downconvert thread begin to cancel PR to EX conversion. In
dlmunlock_commonfunction, downconvert thread has setlock->cancel_pending, but did not enterdlm_send_remote_unlock_requestfunction.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1. change lock level to EX, move lock to granted list.
Node1 dies because
the host is powered down.In
dlm_move_lockres_to_recovery_listfunction. the lock is in the granted queue andcancel_pendingis set.BUG_ON.But after clearing this BUG, process will encounter the second BUG in the
ocfs2_unlock_astfunction. Here is a scenario that will cause the second BUG inocfs2_unlock_astas follows:At the beginning, Node 1 is the master and has NL lock, Node 2 has PR lock, Node 3 has PR lock too.
Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from
Node 1. downconvert thread begin to
cancel PR to EX conversion. Indlmunlock_commonfunction, downconvert thread has releasedlock->spinlockandres->spinlock, but did not enterdlm_send_remote_unlock_requestfunction.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1. change lock level to EX, move lock to granted list, set
lockres->l_unlock_actionasOCFS2_UNLOCK_INVALIDinocfs2_locking_astfunction.Node2 dies because
the host is powered down.Node 3 realize that Node 1 is dead, remove Node 1 from
domain_map. downconvert thread getDLM_NORMALfromdlm_send_remote_unlock_requestfunction and set*call_astas 1. Then downconvert thread meet BUG inocfs2_unlock_astfunction.To avoid meet the second BUG, function
dlmunlock_commonshuold returnDLM_CANCELGRANTif the lock is on granted list and the operation is canceled.Signed-off-by Jian Wang<[email protected]>Reviewed-by Yiwen Jiang<[email protected]>--- fs/ocfs2/dlm/dlmrecovery.c | 1 - fs/ocfs2/dlm/dlmunlock.c | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-)fs/ocfs2/dlm/dlmrecovery.c +0
-1@@ -2134,7 +2134,6 @@ void dlm_move_lockres_to_recovery_list(struct dlm_ctxt *dlm,* if this had completed successfully * before sending this lock state to the * new master */ -BUG_ON (i !=DLM_CONVERTING_LIST );mlog (0 ,"node died with cancel pending " "on %.*s. move back to granted list.\n" , res->lockname.len, res->lockname.name);fs/ocfs2/dlm/dlmunlock.c +5
-0@@ -183,6 +183,11 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm, flags, owner);spin_lock (&res->spinlock);spin_lock (&lock->spinlock); + +if ((flags &LKM_CANCEL ) && +dlm_lock_on_list (&res->granted, lock)) + status =DLM_CANCELGRANT ; +/* if the master told us the lock was already granted, * let the ast handle all of these actions */ if (status ==DLM_CANCELGRANT ) {Signature · 1 line
1.8.3.1.
Quoted 2 lines
.
_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel.
PATCH 1/1 ocfs2/dlm: return DLM_CANCELGRANT if the lock is on granted list and the operation is canceled
Hi Changwei,
Quoted 52 lines · Changwei Ge
Hi Jun,
Quoted 40 lines · piaojun
Hi Changwei,
Quoted 37 lines · Changwei Ge
Quoted 4 lines · piaojun
Hi Changwei,
The problem can't be solved completely if clear ::cancel_pending in
dlm_proxy_ast_handler, as AST will come at anytime just beforeSo how about also add check here bere setting ::cancel_pending in
dlmunlock_common()before invokingdlm_send_remote_unlock_request(). If already on grant list just returnDLM_CANCELGRANTThen a further reference code might look like:
root at ubuntu16:/home/chge/linux[master]# git diff
fs/ocfs2/dlm/dlmast.c +4
-1@@ -372,8 +372,11 @@ int dlm_proxy_ast_handler(struct o2net_msg *msg, u32 len, void *data, head = &res->converting; lock =NULL ;list_for_each_entry (lock, head, list) { -if (lock->ml.cookie == cookie) +if (lock->ml.cookie == cookie) { +if (lock->cancel_pending) + lock->cancel_pending =0 ; goto do_ast; + } }/* if not on convert, try blocked for ast, granted for bast */ fs/ocfs2/dlm/dlmunlock.c +0
-0@@ -174,9 +174,14 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm,if (!master_node) { owner = res->owner;/* drop locks and send message */ Quoted 8 lines
fs/ocfs2/dlm/dlmunlock.c static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm, · line 180
Quoted 5 lines
fs/ocfs2/dlm/dlmunlock.c +4
-1-if (flags &LKM_CANCEL ) +if (flags &LKM_CANCEL ) { +if (dlm_lock_on_list (&res->granted, lock)) { + status =DLM_CANCELGRANT ; + goto leave;If master dead and then lockres is moved to granted list in
dlm_move_lockres_to_recovery_list, theOCFS2_LOCK_BUSYis not cleared.
Quoted 2 lines
OCFS2_LOCK_BUSYshould be cleared inocfs2_locking_ast()since previous locking AST has come back(moving lock to grant list). That's why we returnDLM_CANCELGRANTto caller to avoid calling AST. Otherwiseast()will be called twice, which is obviously a BUG.
I mean master is already dead and ast won't come. So the OCFS2_LOCK_BUSY is not cleared. And there are two cases that lockres is moved to grant list:
1. AST comes back and OCFS2_LOCK_BUSY is cleared.
2. AST does not come back and OCFS2_LOCK_BUSY remains, recovery process move it to grant list. In this case, we need do AST for it.
Perhaps we need do AST again for it.
Quoted 271 lines
Quoted 3 lines
And this will cause stuck problem when
ocfs2_drop_lock. The reason is that unlock ast won't be done whenDLM_CANCELGRANTis set. So I thinkWith above elaboration, you don't have to worry the hang issue anymore.
Thanks,
ChangweiQuoted 260 lines
we need distinguish all the cases of moving lockres to grant list.
Quoted 257 lines
fs/ocfs2/dlm/dlmunlock.c +3
-1+ } + lock->cancel_pending =1 ; - else + }else lock->unlock_pending =1 ;spin_unlock (&lock->spinlock);spin_unlock (&res->spinlock);Thanks,
ChangweiQuoted 241 lines
::cancel_pendig is set. If there is not any other better solutions, could we accept this patch? This bug is very harmful.
Thanks,
JunQuoted 233 lines · wangjian
Hi Changwei,
I understand your idea. But we should be aware that the
cancel_convertprocess and other processes (accepting the AST process, the recovery process) are asynchronous. For example, according to your idea, check if the lock is in the grant queue before calling thedlm_send_remote_unlock_requestfunction in thedlm_proxy_ast_handlerfunction. Then decide whether to clearcancel_pending. But if the AST does not come at this time, the check passes andcancel_pendigwill not be cleared. Then AST immediately came over again, which also led to a bug. I personally think that for asynchronous processes we can't guarantee the speed of execution of each process. All we can do is to avoid the BUG scene.As for the question you said ("If you remove the BUG check why you still call
dlm_commit_pending_cancel()to move the lock back to grant on matter it's on converting list or not?").
I think we should first check if the lock is in the grant queue
(at this time,dlm->spinlockandres->spinlockhave been added), then decide whether to calldlm_commit_pending_cancelfunction.Thanks,
JianQuoted 203 lines · Changwei Ge
Hi Jian,
I suppose that the situation you described truly exists. But the way you fix the issue is not in my favor.
If you remove the BUG check why you still call
dlm_commit_pending_cancel()to move the lock back to grant on matter it's on converting list or not?So how about keeping the BUG check in
dlm_move_lockres_to_recovery_list().
If the locking _ast_ comes back very fast just check ::cancel_pending indlm_proxy_ast_handler()and clear it. Then with the logic checking if the lock is on grant list (indlmunlock_common()more less like your current method) or not we can easily tell if the cancellation succeeds or not.That complies the original dlm design, which I think is better and easier for maintainers to understand.
Thanks,
ChangweiQuoted 7 lines · wangjian
Hi Changwei,
I don't fully agree with your point of view. In my opinion, the lock cancellation process and the lock conversion process are asynchronous. We can't guarantee that the lock must be in the convert list during the lock conversion process, otherwise this BUG will not happen.
So, I think this is a meaningless BUG.Quoted 177 lines
Thanks,
JianQuoted 173 lines · Changwei Ge
Hi Jian,
I suppose you can't just remove the
BUG_ON()check. If you remove it, below code violates the original logic.'''
2141dlm_commit_pending_cancel(res, lock);
'''What's more important is *locking cancel* must be against a *locking conversion* progress. So it makes sense to check if this lock is on converting list.
So I have to NACK to this patch.
Thanks,
ChangweiQuoted 152 lines · wangjian
In the
dlm_move_lockres_to_recovery_listfunction, if the lock is in the granted queue andcancel_pendingis set, it will encounter a BUG. I think this is a meaningless BUG, so be prepared to remove it. A scenario that causes this BUG will be given below.At the beginning, Node 1 is the master and has NL lock, Node 2 has PR lock, Node 3 has PR lock too.
Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from Node 1. downconvert thread begin to cancel PR to EX conversion. In
dlmunlock_commonfunction, downconvert thread has setlock->cancel_pending, but did not enterdlm_send_remote_unlock_requestfunction.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1. change lock level to EX, move lock to granted list.
Node1 dies because
the host is powered down.In
dlm_move_lockres_to_recovery_listfunction. the lock is in the granted queue andcancel_pendingis set.BUG_ON.But after clearing this BUG, process will encounter the second BUG in the
ocfs2_unlock_astfunction. Here is a scenario that will cause the second BUG inocfs2_unlock_astas follows:At the beginning, Node 1 is the master and has NL lock, Node 2 has PR lock, Node 3 has PR lock too.
Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from
Node 1. downconvert thread begin to
cancel PR to EX conversion. Indlmunlock_commonfunction, downconvert thread has releasedlock->spinlockandres->spinlock, but did not enterdlm_send_remote_unlock_requestfunction.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1. change lock level to EX, move lock to granted list, set
lockres->l_unlock_actionasOCFS2_UNLOCK_INVALIDinocfs2_locking_astfunction.Node2 dies because
the host is powered down.Node 3 realize that Node 1 is dead, remove Node 1 from
domain_map. downconvert thread getDLM_NORMALfromdlm_send_remote_unlock_requestfunction and set*call_astas 1. Then downconvert thread meet BUG inocfs2_unlock_astfunction.To avoid meet the second BUG, function
dlmunlock_commonshuold returnDLM_CANCELGRANTif the lock is on granted list and the operation is canceled.Signed-off-by Jian Wang<[email protected]>Reviewed-by Yiwen Jiang<[email protected]>--- fs/ocfs2/dlm/dlmrecovery.c | 1 - fs/ocfs2/dlm/dlmunlock.c | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-)fs/ocfs2/dlm/dlmrecovery.c +0
-1@@ -2134,7 +2134,6 @@ void dlm_move_lockres_to_recovery_list(struct dlm_ctxt *dlm,* if this had completed successfully * before sending this lock state to the * new master */ -BUG_ON (i !=DLM_CONVERTING_LIST );mlog (0 ,"node died with cancel pending " "on %.*s. move back to granted list.\n" , res->lockname.len, res->lockname.name);fs/ocfs2/dlm/dlmunlock.c +5
-0@@ -183,6 +183,11 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm, flags, owner);spin_lock (&res->spinlock);spin_lock (&lock->spinlock); + +if ((flags &LKM_CANCEL ) && +dlm_lock_on_list (&res->granted, lock)) + status =DLM_CANCELGRANT ; +/* if the master told us the lock was already granted, * let the ast handle all of these actions */ if (status ==DLM_CANCELGRANT ) {Signature · 1 line
1.8.3.1.
Quoted 2 lines
.
_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel.
.
PATCH 1/1 ocfs2/dlm: return DLM_CANCELGRANT if the lock is on granted list and the operation is canceled
Hi Jun
I just read the code around unlock/cancel.
Quoted 37 lines · piaojun
Hi Changwei,
Quoted 34 lines · Changwei Ge
Hi Jun,
Quoted 31 lines · piaojun
Hi Changwei,
Quoted 28 lines · Changwei Ge
Quoted 4 lines · piaojun
Hi Changwei,
The problem can't be solved completely if clear ::cancel_pending in
dlm_proxy_ast_handler, as AST will come at anytime just beforeSo how about also add check here bere setting ::cancel_pending in
dlmunlock_common()before invokingdlm_send_remote_unlock_request(). If already on grant list just returnDLM_CANCELGRANTThen a further reference code might look like:
root at ubuntu16:/home/chge/linux[master]# git diff
fs/ocfs2/dlm/dlmast.c +4
-1@@ -372,8 +372,11 @@ int dlm_proxy_ast_handler(struct o2net_msg *msg, u32 len, void *data, head = &res->converting; lock =NULL ;list_for_each_entry (lock, head, list) { -if (lock->ml.cookie == cookie) +if (lock->ml.cookie == cookie) { +if (lock->cancel_pending) + lock->cancel_pending =0 ; goto do_ast; + } }
Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
fs/ocfs2/dlm/dlmast.c +0
-0/* if not on convert, try blocked for ast, granted for bast */ fs/ocfs2/dlm/dlmunlock.c +0
-0@@ -174,9 +174,14 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm,Quoted 8 lines
Quoted 8 lines
fs/ocfs2/dlm/dlmunlock.c static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm, · line 180
Quoted 8 lines
fs/ocfs2/dlm/dlmunlock.c +4
-1if (!master_node) { owner = res->owner;/* drop locks and send message */ -if (flags &LKM_CANCEL ) +if (flags &LKM_CANCEL ) { +if (dlm_lock_on_list (&res->granted, lock)) { + status =DLM_CANCELGRANT ; + goto leave;
I found that above code should be useless.
As upstream code already take it into consideration that AST has come before cancellation. In dlm_get_cancel_actions()
'''
} else if (dlm_lock_on_list(&res->granted, lock)) {
/* too late, already granted. */
status = DLM_CANCELGRANT;
*actions = DLM_UNLOCK_CALL_AST;
} else {
'''Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
If master dead and then lockres is moved to granted list in
dlm_move_lockres_to_recovery_list, theOCFS2_LOCK_BUSYis not cleared.
OCFS2_LOCK_BUSYshould be cleared inocfs2_locking_ast()since previous locking AST has come back(moving lock to grant list). That's why we returnDLM_CANCELGRANTto caller to avoid calling AST. Otherwiseast()will be called twice, which is obviously a BUG.
Quoted 6 lines
I mean master is already dead and ast won't come. So the
OCFS2_LOCK_BUSYis not cleared. And there are two cases that lockres is moved to grant list:
1. AST comes back andOCFS2_LOCK_BUSYis cleared.
2. AST does not come back andOCFS2_LOCK_BUSYremains, recovery process move it to grant list. In this case, we need do AST for it.
For point 2, ocfs2 can handle it, so you still don't have to worry. It's no problem. In dlmconvert_remote()
341 if (status != DLM_NORMAL) {
342 if (status != DLM_NOTQUEUED)
343 dlm_error(status);
344 dlm_revert_pending_convert(res, lock);
345 } else if (!lock->convert_pending) {
346 mlog(0, "%s: res %.*s, owner died and lock has been moved back "
347 "to granted list, retry convert.\n",
348 dlm->name, res->lockname.len, res->lockname.name);
349 status = DLM_RECOVERING;
350 }
Thus, dlmlock() will wait until RECOVERY is done.
And for ocfs2 layer, it's apparent, it doesn't have to be aware of what happened to DLM.
Thanks,
Changwei
Quoted 275 lines
Perhaps we need do AST again for it.
Quoted 271 lines
Quoted 3 lines
And this will cause stuck problem when
ocfs2_drop_lock. The reason is that unlock ast won't be done whenDLM_CANCELGRANTis set. So I thinkWith above elaboration, you don't have to worry the hang issue anymore.
Thanks,
ChangweiQuoted 260 lines
we need distinguish all the cases of moving lockres to grant list.
Quoted 257 lines
fs/ocfs2/dlm/dlmunlock.c +3
-1+ } + lock->cancel_pending =1 ; - else + }else lock->unlock_pending =1 ;spin_unlock (&lock->spinlock);spin_unlock (&res->spinlock);Thanks,
ChangweiQuoted 241 lines
::cancel_pendig is set. If there is not any other better solutions, could we accept this patch? This bug is very harmful.
Thanks,
JunQuoted 233 lines · wangjian
Hi Changwei,
I understand your idea. But we should be aware that the
cancel_convertprocess and other processes (accepting the AST process, the recovery process) are asynchronous. For example, according to your idea, check if the lock is in the grant queue before calling thedlm_send_remote_unlock_requestfunction in thedlm_proxy_ast_handlerfunction. Then decide whether to clearcancel_pending. But if the AST does not come at this time, the check passes andcancel_pendigwill not be cleared. Then AST immediately came over again, which also led to a bug. I personally think that for asynchronous processes we can't guarantee the speed of execution of each process. All we can do is to avoid the BUG scene.As for the question you said ("If you remove the BUG check why you still call
dlm_commit_pending_cancel()to move the lock back to grant on matter it's on converting list or not?").
I think we should first check if the lock is in the grant queue
(at this time,dlm->spinlockandres->spinlockhave been added), then decide whether to calldlm_commit_pending_cancelfunction.Thanks,
JianQuoted 203 lines · Changwei Ge
Hi Jian,
I suppose that the situation you described truly exists. But the way you fix the issue is not in my favor.
If you remove the BUG check why you still call
dlm_commit_pending_cancel()to move the lock back to grant on matter it's on converting list or not?So how about keeping the BUG check in
dlm_move_lockres_to_recovery_list().
If the locking _ast_ comes back very fast just check ::cancel_pending indlm_proxy_ast_handler()and clear it. Then with the logic checking if the lock is on grant list (indlmunlock_common()more less like your current method) or not we can easily tell if the cancellation succeeds or not.That complies the original dlm design, which I think is better and easier for maintainers to understand.
Thanks,
ChangweiQuoted 7 lines · wangjian
Hi Changwei,
I don't fully agree with your point of view. In my opinion, the lock cancellation process and the lock conversion process are asynchronous. We can't guarantee that the lock must be in the convert list during the lock conversion process, otherwise this BUG will not happen.
So, I think this is a meaningless BUG.Quoted 177 lines
Thanks,
JianQuoted 173 lines · Changwei Ge
Hi Jian,
I suppose you can't just remove the
BUG_ON()check. If you remove it, below code violates the original logic.'''
2141dlm_commit_pending_cancel(res, lock);
'''What's more important is *locking cancel* must be against a *locking conversion* progress. So it makes sense to check if this lock is on converting list.
So I have to NACK to this patch.
Thanks,
ChangweiQuoted 152 lines · wangjian
In the
dlm_move_lockres_to_recovery_listfunction, if the lock is in the granted queue andcancel_pendingis set, it will encounter a BUG. I think this is a meaningless BUG, so be prepared to remove it. A scenario that causes this BUG will be given below.At the beginning, Node 1 is the master and has NL lock, Node 2 has PR lock, Node 3 has PR lock too.
Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from Node 1. downconvert thread begin to cancel PR to EX conversion. In
dlmunlock_commonfunction, downconvert thread has setlock->cancel_pending, but did not enterdlm_send_remote_unlock_requestfunction.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1. change lock level to EX, move lock to granted list.
Node1 dies because
the host is powered down.In
dlm_move_lockres_to_recovery_listfunction. the lock is in the granted queue andcancel_pendingis set.BUG_ON.But after clearing this BUG, process will encounter the second BUG in the
ocfs2_unlock_astfunction. Here is a scenario that will cause the second BUG inocfs2_unlock_astas follows:At the beginning, Node 1 is the master and has NL lock, Node 2 has PR lock, Node 3 has PR lock too.
Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from
Node 1. downconvert thread begin to
cancel PR to EX conversion. Indlmunlock_commonfunction, downconvert thread has releasedlock->spinlockandres->spinlock, but did not enterdlm_send_remote_unlock_requestfunction.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1. change lock level to EX, move lock to granted list, set
lockres->l_unlock_actionasOCFS2_UNLOCK_INVALIDinocfs2_locking_astfunction.Node2 dies because
the host is powered down.Node 3 realize that Node 1 is dead, remove Node 1 from
domain_map. downconvert thread getDLM_NORMALfromdlm_send_remote_unlock_requestfunction and set*call_astas 1. Then downconvert thread meet BUG inocfs2_unlock_astfunction.To avoid meet the second BUG, function
dlmunlock_commonshuold returnDLM_CANCELGRANTif the lock is on granted list and the operation is canceled.Signed-off-by Jian Wang<[email protected]>Reviewed-by Yiwen Jiang<[email protected]>--- fs/ocfs2/dlm/dlmrecovery.c | 1 - fs/ocfs2/dlm/dlmunlock.c | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-)fs/ocfs2/dlm/dlmrecovery.c +0
-1@@ -2134,7 +2134,6 @@ void dlm_move_lockres_to_recovery_list(struct dlm_ctxt *dlm,* if this had completed successfully * before sending this lock state to the * new master */ -BUG_ON (i !=DLM_CONVERTING_LIST );mlog (0 ,"node died with cancel pending " "on %.*s. move back to granted list.\n" , res->lockname.len, res->lockname.name);fs/ocfs2/dlm/dlmunlock.c +5
-0@@ -183,6 +183,11 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm, flags, owner);spin_lock (&res->spinlock);spin_lock (&lock->spinlock); + +if ((flags &LKM_CANCEL ) && +dlm_lock_on_list (&res->granted, lock)) + status =DLM_CANCELGRANT ; +/* if the master told us the lock was already granted, * let the ast handle all of these actions */ if (status ==DLM_CANCELGRANT ) {Signature · 1 line
1.8.3.1.
Quoted 2 lines
.
_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel.
.
PATCH 1/1 ocfs2/dlm: return DLM_CANCELGRANT if the lock is on granted list and the operation is canceled
Hi Changwei,
Quoted 82 lines · Changwei Ge
Hi Jun
I just read the code around unlock/cancel.
Quoted 37 lines · piaojun
Hi Changwei,
Quoted 34 lines · Changwei Ge
Hi Jun,
Quoted 31 lines · piaojun
Hi Changwei,
Quoted 28 lines · Changwei Ge
Quoted 4 lines · piaojun
Hi Changwei,
The problem can't be solved completely if clear ::cancel_pending in
dlm_proxy_ast_handler, as AST will come at anytime just beforeSo how about also add check here bere setting ::cancel_pending in
dlmunlock_common()before invokingdlm_send_remote_unlock_request(). If already on grant list just returnDLM_CANCELGRANTThen a further reference code might look like:
root at ubuntu16:/home/chge/linux[master]# git diff
fs/ocfs2/dlm/dlmast.c +4
-1@@ -372,8 +372,11 @@ int dlm_proxy_ast_handler(struct o2net_msg *msg, u32 len, void *data, head = &res->converting; lock =NULL ;list_for_each_entry (lock, head, list) { -if (lock->ml.cookie == cookie) +if (lock->ml.cookie == cookie) { +if (lock->cancel_pending) + lock->cancel_pending =0 ; goto do_ast; + } }Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
fs/ocfs2/dlm/dlmast.c +0
-0/* if not on convert, try blocked for ast, granted for bast */ fs/ocfs2/dlm/dlmunlock.c +0
-0@@ -174,9 +174,14 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm,Quoted 8 lines
Quoted 8 lines
fs/ocfs2/dlm/dlmunlock.c static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm, · line 180
Quoted 8 lines
fs/ocfs2/dlm/dlmunlock.c +4
-1if (!master_node) { owner = res->owner;/* drop locks and send message */ -if (flags &LKM_CANCEL ) +if (flags &LKM_CANCEL ) { +if (dlm_lock_on_list (&res->granted, lock)) { + status =DLM_CANCELGRANT ; + goto leave;I found that above code should be useless.
As upstream code already take it into consideration that AST has come before cancellation. Indlm_get_cancel_actions()''' } else if (dlm_lock_on_list(&res->granted, lock)) { /* too late, already granted. */ status = DLM_CANCELGRANT; *actions = DLM_UNLOCK_CALL_AST; } else { '''Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
If master dead and then lockres is moved to granted list in
dlm_move_lockres_to_recovery_list, theOCFS2_LOCK_BUSYis not cleared.
OCFS2_LOCK_BUSYshould be cleared inocfs2_locking_ast()since previous locking AST has come back(moving lock to grant list). That's why we returnDLM_CANCELGRANTto caller to avoid calling AST. Otherwiseast()will be called twice, which is obviously a BUG.Quoted 6 lines
I mean master is already dead and ast won't come. So the
OCFS2_LOCK_BUSYis not cleared. And there are two cases that lockres is moved to grant list:
1. AST comes back andOCFS2_LOCK_BUSYis cleared.
2. AST does not come back andOCFS2_LOCK_BUSYremains, recovery process move it to grant list. In this case, we need do AST for it.
Quoted 2 lines
For point 2, ocfs2 can handle it, so you still don't have to worry. It's no problem. In
dlmconvert_remote()
What I worry about is that OCFS2_LOCK_BUSY won't be cleared if remote master is dead, as OCFS2_LOCK_BUSY is cleared in two cases:
1. remote AST come, clear it in dlm_proxy_ast_handler.
2. remote AST does not come when master dead, clear it in o2dlm_unlock_ast_wrapper.
For case 2, if DLM_CANCELGRANT is set, o2dlm_unlock_ast_wrapper just return and won't clear OCFS2_LOCK_BUSY. So in this case, I think we should do AST again for it.
Quoted 13 lines
341 if (status !=
DLM_NORMAL) {
342 if (status !=DLM_NOTQUEUED)
343dlm_error(status);
344dlm_revert_pending_convert(res, lock);
345 } else if (!lock->convert_pending) {
346 mlog(0, "%s: res %.*s, owner died and lock has been moved back "
347 "to granted list, retry convert.\n",
348dlm->name,res->lockname.len,res->lockname.name);
349 status =DLM_RECOVERING;
350 }
Quoted 2 lines
Thus,
dlmlock()will wait until RECOVERY is done.
And for ocfs2 layer, it's apparent, it doesn't have to be aware of what happened to DLM.
I do not think the waiting can solve this problem.
Quoted 282 lines
Thanks,
ChangweiQuoted 275 lines
Perhaps we need do AST again for it.
Quoted 271 lines
Quoted 3 lines
And this will cause stuck problem when
ocfs2_drop_lock. The reason is that unlock ast won't be done whenDLM_CANCELGRANTis set. So I thinkWith above elaboration, you don't have to worry the hang issue anymore.
Thanks,
ChangweiQuoted 260 lines
we need distinguish all the cases of moving lockres to grant list.
Quoted 257 lines
fs/ocfs2/dlm/dlmunlock.c +3
-1+ } + lock->cancel_pending =1 ; - else + }else lock->unlock_pending =1 ;spin_unlock (&lock->spinlock);spin_unlock (&res->spinlock);Thanks,
ChangweiQuoted 241 lines
::cancel_pendig is set. If there is not any other better solutions, could we accept this patch? This bug is very harmful.
Thanks,
JunQuoted 233 lines · wangjian
Hi Changwei,
I understand your idea. But we should be aware that the
cancel_convertprocess and other processes (accepting the AST process, the recovery process) are asynchronous. For example, according to your idea, check if the lock is in the grant queue before calling thedlm_send_remote_unlock_requestfunction in thedlm_proxy_ast_handlerfunction. Then decide whether to clearcancel_pending. But if the AST does not come at this time, the check passes andcancel_pendigwill not be cleared. Then AST immediately came over again, which also led to a bug. I personally think that for asynchronous processes we can't guarantee the speed of execution of each process. All we can do is to avoid the BUG scene.As for the question you said ("If you remove the BUG check why you still call
dlm_commit_pending_cancel()to move the lock back to grant on matter it's on converting list or not?").
I think we should first check if the lock is in the grant queue
(at this time,dlm->spinlockandres->spinlockhave been added), then decide whether to calldlm_commit_pending_cancelfunction.Thanks,
JianQuoted 203 lines · Changwei Ge
Hi Jian,
I suppose that the situation you described truly exists. But the way you fix the issue is not in my favor.
If you remove the BUG check why you still call
dlm_commit_pending_cancel()to move the lock back to grant on matter it's on converting list or not?So how about keeping the BUG check in
dlm_move_lockres_to_recovery_list().
If the locking _ast_ comes back very fast just check ::cancel_pending indlm_proxy_ast_handler()and clear it. Then with the logic checking if the lock is on grant list (indlmunlock_common()more less like your current method) or not we can easily tell if the cancellation succeeds or not.That complies the original dlm design, which I think is better and easier for maintainers to understand.
Thanks,
ChangweiQuoted 7 lines · wangjian
Hi Changwei,
I don't fully agree with your point of view. In my opinion, the lock cancellation process and the lock conversion process are asynchronous. We can't guarantee that the lock must be in the convert list during the lock conversion process, otherwise this BUG will not happen.
So, I think this is a meaningless BUG.Quoted 177 lines
Thanks,
JianQuoted 173 lines · Changwei Ge
Hi Jian,
I suppose you can't just remove the
BUG_ON()check. If you remove it, below code violates the original logic.'''
2141dlm_commit_pending_cancel(res, lock);
'''What's more important is *locking cancel* must be against a *locking conversion* progress. So it makes sense to check if this lock is on converting list.
So I have to NACK to this patch.
Thanks,
ChangweiQuoted 152 lines · wangjian
In the
dlm_move_lockres_to_recovery_listfunction, if the lock is in the granted queue andcancel_pendingis set, it will encounter a BUG. I think this is a meaningless BUG, so be prepared to remove it. A scenario that causes this BUG will be given below.At the beginning, Node 1 is the master and has NL lock, Node 2 has PR lock, Node 3 has PR lock too.
Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from Node 1. downconvert thread begin to cancel PR to EX conversion. In
dlmunlock_commonfunction, downconvert thread has setlock->cancel_pending, but did not enterdlm_send_remote_unlock_requestfunction.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1. change lock level to EX, move lock to granted list.
Node1 dies because
the host is powered down.In
dlm_move_lockres_to_recovery_listfunction. the lock is in the granted queue andcancel_pendingis set.BUG_ON.But after clearing this BUG, process will encounter the second BUG in the
ocfs2_unlock_astfunction. Here is a scenario that will cause the second BUG inocfs2_unlock_astas follows:At the beginning, Node 1 is the master and has NL lock, Node 2 has PR lock, Node 3 has PR lock too.
Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from
Node 1. downconvert thread begin to
cancel PR to EX conversion. Indlmunlock_commonfunction, downconvert thread has releasedlock->spinlockandres->spinlock, but did not enterdlm_send_remote_unlock_requestfunction.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1. change lock level to EX, move lock to granted list, set
lockres->l_unlock_actionasOCFS2_UNLOCK_INVALIDinocfs2_locking_astfunction.Node2 dies because
the host is powered down.Node 3 realize that Node 1 is dead, remove Node 1 from
domain_map. downconvert thread getDLM_NORMALfromdlm_send_remote_unlock_requestfunction and set*call_astas 1. Then downconvert thread meet BUG inocfs2_unlock_astfunction.To avoid meet the second BUG, function
dlmunlock_commonshuold returnDLM_CANCELGRANTif the lock is on granted list and the operation is canceled.Signed-off-by Jian Wang<[email protected]>Reviewed-by Yiwen Jiang<[email protected]>--- fs/ocfs2/dlm/dlmrecovery.c | 1 - fs/ocfs2/dlm/dlmunlock.c | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-)fs/ocfs2/dlm/dlmrecovery.c +0
-1@@ -2134,7 +2134,6 @@ void dlm_move_lockres_to_recovery_list(struct dlm_ctxt *dlm,* if this had completed successfully * before sending this lock state to the * new master */ -BUG_ON (i !=DLM_CONVERTING_LIST );mlog (0 ,"node died with cancel pending " "on %.*s. move back to granted list.\n" , res->lockname.len, res->lockname.name);fs/ocfs2/dlm/dlmunlock.c +5
-0@@ -183,6 +183,11 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm, flags, owner);spin_lock (&res->spinlock);spin_lock (&lock->spinlock); + +if ((flags &LKM_CANCEL ) && +dlm_lock_on_list (&res->granted, lock)) + status =DLM_CANCELGRANT ; +/* if the master told us the lock was already granted, * let the ast handle all of these actions */ if (status ==DLM_CANCELGRANT ) {Signature · 1 line
1.8.3.1.
Quoted 2 lines
.
_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel.
.
.
PATCH 1/1 ocfs2/dlm: return DLM_CANCELGRANT if the lock is on granted list and the operation is canceled
Quoted 85 lines · piaojun
Hi Changwei,
Quoted 82 lines · Changwei Ge
Hi Jun
I just read the code around unlock/cancel.
Quoted 37 lines · piaojun
Hi Changwei,
Quoted 34 lines · Changwei Ge
Hi Jun,
Quoted 31 lines · piaojun
Hi Changwei,
Quoted 28 lines · Changwei Ge
Quoted 4 lines · piaojun
Hi Changwei,
The problem can't be solved completely if clear ::cancel_pending in
dlm_proxy_ast_handler, as AST will come at anytime just beforeSo how about also add check here bere setting ::cancel_pending in
dlmunlock_common()before invokingdlm_send_remote_unlock_request(). If already on grant list just returnDLM_CANCELGRANTThen a further reference code might look like:
root at ubuntu16:/home/chge/linux[master]# git diff
fs/ocfs2/dlm/dlmast.c +4
-1@@ -372,8 +372,11 @@ int dlm_proxy_ast_handler(struct o2net_msg *msg, u32 len, void *data, head = &res->converting; lock =NULL ;list_for_each_entry (lock, head, list) { -if (lock->ml.cookie == cookie) +if (lock->ml.cookie == cookie) { +if (lock->cancel_pending) + lock->cancel_pending =0 ; goto do_ast; + } }Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
fs/ocfs2/dlm/dlmast.c +0
-0/* if not on convert, try blocked for ast, granted for bast */ fs/ocfs2/dlm/dlmunlock.c +0
-0@@ -174,9 +174,14 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm,Quoted 8 lines
Quoted 8 lines
fs/ocfs2/dlm/dlmunlock.c static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm, · line 180
Quoted 8 lines
fs/ocfs2/dlm/dlmunlock.c +4
-1if (!master_node) { owner = res->owner;/* drop locks and send message */ -if (flags &LKM_CANCEL ) +if (flags &LKM_CANCEL ) { +if (dlm_lock_on_list (&res->granted, lock)) { + status =DLM_CANCELGRANT ; + goto leave;I found that above code should be useless.
As upstream code already take it into consideration that AST has come before cancellation. Indlm_get_cancel_actions()''' } else if (dlm_lock_on_list(&res->granted, lock)) { /* too late, already granted. */ status = DLM_CANCELGRANT; *actions = DLM_UNLOCK_CALL_AST; } else { '''Quoted 13 lines
Quoted 6 lines
Quoted 3 lines
If master dead and then lockres is moved to granted list in
dlm_move_lockres_to_recovery_list, theOCFS2_LOCK_BUSYis not cleared.
OCFS2_LOCK_BUSYshould be cleared inocfs2_locking_ast()since previous locking AST has come back(moving lock to grant list). That's why we returnDLM_CANCELGRANTto caller to avoid calling AST. Otherwiseast()will be called twice, which is obviously a BUG.I mean master is already dead and ast won't come. So the
OCFS2_LOCK_BUSYis not cleared. And there are two cases that lockres is moved to grant list:
1. AST comes back andOCFS2_LOCK_BUSYis cleared.
2. AST does not come back andOCFS2_LOCK_BUSYremains, recovery process move it to grant list. In this case, we need do AST for it.
Quoted 8 lines
Quoted 2 lines
For point 2, ocfs2 can handle it, so you still don't have to worry. It's no problem. In
dlmconvert_remote()What I worry about is that
OCFS2_LOCK_BUSYwon't be cleared if remote master is dead, asOCFS2_LOCK_BUSYis cleared in two cases:
1. remote AST come, clear it indlm_proxy_ast_handler.
2. remote AST does not come when master dead, clear it ino2dlm_unlock_ast_wrapper.
Please don't worry about point 2.
Like my previous e-mail, after dlm recovery picking up a new master for corresponding lock resource. dlmlock() -> convert will retry and send request to new master.
Eventually, this locking(convert) will succeed and ast() will be called for ocfs2 layer to clear OCFS2_LOCK_BUSY.
Thanks,
Changwei
Quoted 306 lines
For case 2, if
DLM_CANCELGRANTis set,o2dlm_unlock_ast_wrapperjust return and won't clearOCFS2_LOCK_BUSY. So in this case, I think we should do AST again for it.Quoted 13 lines
341 if (status !=
DLM_NORMAL) {
342 if (status !=DLM_NOTQUEUED)
343dlm_error(status);
344dlm_revert_pending_convert(res, lock);
345 } else if (!lock->convert_pending) {
346 mlog(0, "%s: res %.*s, owner died and lock has been moved back "
347 "to granted list, retry convert.\n",
348dlm->name,res->lockname.len,res->lockname.name);
349 status =DLM_RECOVERING;
350 }Quoted 2 lines
Thus,
dlmlock()will wait until RECOVERY is done.
And for ocfs2 layer, it's apparent, it doesn't have to be aware of what happened to DLM.I do not think the waiting can solve this problem.
Quoted 282 lines
Thanks,
ChangweiQuoted 275 lines
Perhaps we need do AST again for it.
Quoted 271 lines
Quoted 3 lines
And this will cause stuck problem when
ocfs2_drop_lock. The reason is that unlock ast won't be done whenDLM_CANCELGRANTis set. So I thinkWith above elaboration, you don't have to worry the hang issue anymore.
Thanks,
ChangweiQuoted 260 lines
we need distinguish all the cases of moving lockres to grant list.
Quoted 257 lines
fs/ocfs2/dlm/dlmunlock.c +3
-1+ } + lock->cancel_pending =1 ; - else + }else lock->unlock_pending =1 ;spin_unlock (&lock->spinlock);spin_unlock (&res->spinlock);Thanks,
ChangweiQuoted 241 lines
::cancel_pendig is set. If there is not any other better solutions, could we accept this patch? This bug is very harmful.
Thanks,
JunQuoted 233 lines · wangjian
Hi Changwei,
I understand your idea. But we should be aware that the
cancel_convertprocess and other processes (accepting the AST process, the recovery process) are asynchronous. For example, according to your idea, check if the lock is in the grant queue before calling thedlm_send_remote_unlock_requestfunction in thedlm_proxy_ast_handlerfunction. Then decide whether to clearcancel_pending. But if the AST does not come at this time, the check passes andcancel_pendigwill not be cleared. Then AST immediately came over again, which also led to a bug. I personally think that for asynchronous processes we can't guarantee the speed of execution of each process. All we can do is to avoid the BUG scene.As for the question you said ("If you remove the BUG check why you still call
dlm_commit_pending_cancel()to move the lock back to grant on matter it's on converting list or not?").
I think we should first check if the lock is in the grant queue
(at this time,dlm->spinlockandres->spinlockhave been added), then decide whether to calldlm_commit_pending_cancelfunction.Thanks,
JianQuoted 203 lines · Changwei Ge
Hi Jian,
I suppose that the situation you described truly exists. But the way you fix the issue is not in my favor.
If you remove the BUG check why you still call
dlm_commit_pending_cancel()to move the lock back to grant on matter it's on converting list or not?So how about keeping the BUG check in
dlm_move_lockres_to_recovery_list().
If the locking _ast_ comes back very fast just check ::cancel_pending indlm_proxy_ast_handler()and clear it. Then with the logic checking if the lock is on grant list (indlmunlock_common()more less like your current method) or not we can easily tell if the cancellation succeeds or not.That complies the original dlm design, which I think is better and easier for maintainers to understand.
Thanks,
ChangweiQuoted 7 lines · wangjian
Hi Changwei,
I don't fully agree with your point of view. In my opinion, the lock cancellation process and the lock conversion process are asynchronous. We can't guarantee that the lock must be in the convert list during the lock conversion process, otherwise this BUG will not happen.
So, I think this is a meaningless BUG.Quoted 177 lines
Thanks,
JianQuoted 173 lines · Changwei Ge
Hi Jian,
I suppose you can't just remove the
BUG_ON()check. If you remove it, below code violates the original logic.'''
2141dlm_commit_pending_cancel(res, lock);
'''What's more important is *locking cancel* must be against a *locking conversion* progress. So it makes sense to check if this lock is on converting list.
So I have to NACK to this patch.
Thanks,
ChangweiQuoted 152 lines · wangjian
In the
dlm_move_lockres_to_recovery_listfunction, if the lock is in the granted queue andcancel_pendingis set, it will encounter a BUG. I think this is a meaningless BUG, so be prepared to remove it. A scenario that causes this BUG will be given below.At the beginning, Node 1 is the master and has NL lock, Node 2 has PR lock, Node 3 has PR lock too.
Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from Node 1. downconvert thread begin to cancel PR to EX conversion. In
dlmunlock_commonfunction, downconvert thread has setlock->cancel_pending, but did not enterdlm_send_remote_unlock_requestfunction.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1. change lock level to EX, move lock to granted list.
Node1 dies because
the host is powered down.In
dlm_move_lockres_to_recovery_listfunction. the lock is in the granted queue andcancel_pendingis set.BUG_ON.But after clearing this BUG, process will encounter the second BUG in the
ocfs2_unlock_astfunction. Here is a scenario that will cause the second BUG inocfs2_unlock_astas follows:At the beginning, Node 1 is the master and has NL lock, Node 2 has PR lock, Node 3 has PR lock too.
Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from
Node 1. downconvert thread begin to
cancel PR to EX conversion. Indlmunlock_commonfunction, downconvert thread has releasedlock->spinlockandres->spinlock, but did not enterdlm_send_remote_unlock_requestfunction.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1. change lock level to EX, move lock to granted list, set
lockres->l_unlock_actionasOCFS2_UNLOCK_INVALIDinocfs2_locking_astfunction.Node2 dies because
the host is powered down.Node 3 realize that Node 1 is dead, remove Node 1 from
domain_map. downconvert thread getDLM_NORMALfromdlm_send_remote_unlock_requestfunction and set*call_astas 1. Then downconvert thread meet BUG inocfs2_unlock_astfunction.To avoid meet the second BUG, function
dlmunlock_commonshuold returnDLM_CANCELGRANTif the lock is on granted list and the operation is canceled.Signed-off-by Jian Wang<[email protected]>Reviewed-by Yiwen Jiang<[email protected]>--- fs/ocfs2/dlm/dlmrecovery.c | 1 - fs/ocfs2/dlm/dlmunlock.c | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-)fs/ocfs2/dlm/dlmrecovery.c +0
-1@@ -2134,7 +2134,6 @@ void dlm_move_lockres_to_recovery_list(struct dlm_ctxt *dlm,* if this had completed successfully * before sending this lock state to the * new master */ -BUG_ON (i !=DLM_CONVERTING_LIST );mlog (0 ,"node died with cancel pending " "on %.*s. move back to granted list.\n" , res->lockname.len, res->lockname.name);fs/ocfs2/dlm/dlmunlock.c +5
-0@@ -183,6 +183,11 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm, flags, owner);spin_lock (&res->spinlock);spin_lock (&lock->spinlock); + +if ((flags &LKM_CANCEL ) && +dlm_lock_on_list (&res->granted, lock)) + status =DLM_CANCELGRANT ; +/* if the master told us the lock was already granted, * let the ast handle all of these actions */ if (status ==DLM_CANCELGRANT ) {Signature · 1 line
1.8.3.1.
Quoted 2 lines
.
_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel.
.
.
PATCH 1/1 ocfs2/dlm: return DLM_CANCELGRANT if the lock is on granted list and the operation is canceled
Hi Changwei,
Quoted 95 lines · Changwei Ge
Quoted 85 lines · piaojun
Hi Changwei,
Quoted 82 lines · Changwei Ge
Hi Jun
I just read the code around unlock/cancel.
Quoted 37 lines · piaojun
Hi Changwei,
Quoted 34 lines · Changwei Ge
Hi Jun,
Quoted 31 lines · piaojun
Hi Changwei,
Quoted 28 lines · Changwei Ge
Quoted 4 lines · piaojun
Hi Changwei,
The problem can't be solved completely if clear ::cancel_pending in
dlm_proxy_ast_handler, as AST will come at anytime just beforeSo how about also add check here bere setting ::cancel_pending in
dlmunlock_common()before invokingdlm_send_remote_unlock_request(). If already on grant list just returnDLM_CANCELGRANTThen a further reference code might look like:
root at ubuntu16:/home/chge/linux[master]# git diff
fs/ocfs2/dlm/dlmast.c +4
-1@@ -372,8 +372,11 @@ int dlm_proxy_ast_handler(struct o2net_msg *msg, u32 len, void *data, head = &res->converting; lock =NULL ;list_for_each_entry (lock, head, list) { -if (lock->ml.cookie == cookie) +if (lock->ml.cookie == cookie) { +if (lock->cancel_pending) + lock->cancel_pending =0 ; goto do_ast; + } }Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
fs/ocfs2/dlm/dlmast.c +0
-0/* if not on convert, try blocked for ast, granted for bast */ fs/ocfs2/dlm/dlmunlock.c +0
-0@@ -174,9 +174,14 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm,Quoted 8 lines
Quoted 8 lines
fs/ocfs2/dlm/dlmunlock.c static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm, · line 180
Quoted 8 lines
fs/ocfs2/dlm/dlmunlock.c +4
-1if (!master_node) { owner = res->owner;/* drop locks and send message */ -if (flags &LKM_CANCEL ) +if (flags &LKM_CANCEL ) { +if (dlm_lock_on_list (&res->granted, lock)) { + status =DLM_CANCELGRANT ; + goto leave;I found that above code should be useless.
As upstream code already take it into consideration that AST has come before cancellation. Indlm_get_cancel_actions()''' } else if (dlm_lock_on_list(&res->granted, lock)) { /* too late, already granted. */ status = DLM_CANCELGRANT; *actions = DLM_UNLOCK_CALL_AST; } else { '''Quoted 13 lines
Quoted 6 lines
Quoted 3 lines
If master dead and then lockres is moved to granted list in
dlm_move_lockres_to_recovery_list, theOCFS2_LOCK_BUSYis not cleared.
OCFS2_LOCK_BUSYshould be cleared inocfs2_locking_ast()since previous locking AST has come back(moving lock to grant list). That's why we returnDLM_CANCELGRANTto caller to avoid calling AST. Otherwiseast()will be called twice, which is obviously a BUG.I mean master is already dead and ast won't come. So the
OCFS2_LOCK_BUSYis not cleared. And there are two cases that lockres is moved to grant list:
1. AST comes back andOCFS2_LOCK_BUSYis cleared.
2. AST does not come back andOCFS2_LOCK_BUSYremains, recovery process move it to grant list. In this case, we need do AST for it.Quoted 8 lines
Quoted 2 lines
For point 2, ocfs2 can handle it, so you still don't have to worry. It's no problem. In
dlmconvert_remote()What I worry about is that
OCFS2_LOCK_BUSYwon't be cleared if remote master is dead, asOCFS2_LOCK_BUSYis cleared in two cases:
1. remote AST come, clear it indlm_proxy_ast_handler.
2. remote AST does not come when master dead, clear it ino2dlm_unlock_ast_wrapper.
Quoted 4 lines
Please don't worry about point 2.
Like my previous e-mail, after dlm recovery picking up a new master for corresponding lock resource.dlmlock()-> convert will retry and send request to new master.
Eventually, this locking(convert) will succeed andast()will be called for ocfs2 layer to clearOCFS2_LOCK_BUSY.
Perhaps you misunderstand my meaning. The AST I meant is for dlmunlock, not for dlmlock, so it won't cause retry sending request to new master.
Quoted 312 lines
Thanks,
ChangweiQuoted 18 lines
For case 2, if
DLM_CANCELGRANTis set,o2dlm_unlock_ast_wrapperjust return and won't clearOCFS2_LOCK_BUSY. So in this case, I think we should do AST again for it.Quoted 13 lines
341 if (status !=
DLM_NORMAL) {
342 if (status !=DLM_NOTQUEUED)
343dlm_error(status);
344dlm_revert_pending_convert(res, lock);
345 } else if (!lock->convert_pending) {
346 mlog(0, "%s: res %.*s, owner died and lock has been moved back "
347 "to granted list, retry convert.\n",
348dlm->name,res->lockname.len,res->lockname.name);
349 status =DLM_RECOVERING;
350 }Quoted 288 lines
Quoted 2 lines
Thus,
dlmlock()will wait until RECOVERY is done.
And for ocfs2 layer, it's apparent, it doesn't have to be aware of what happened to DLM.I do not think the waiting can solve this problem.
Quoted 282 lines
Thanks,
ChangweiQuoted 275 lines
Perhaps we need do AST again for it.
Quoted 271 lines
Quoted 3 lines
And this will cause stuck problem when
ocfs2_drop_lock. The reason is that unlock ast won't be done whenDLM_CANCELGRANTis set. So I thinkWith above elaboration, you don't have to worry the hang issue anymore.
Thanks,
ChangweiQuoted 260 lines
we need distinguish all the cases of moving lockres to grant list.
Quoted 257 lines
fs/ocfs2/dlm/dlmunlock.c +3
-1+ } + lock->cancel_pending =1 ; - else + }else lock->unlock_pending =1 ;spin_unlock (&lock->spinlock);spin_unlock (&res->spinlock);Thanks,
ChangweiQuoted 241 lines
::cancel_pendig is set. If there is not any other better solutions, could we accept this patch? This bug is very harmful.
Thanks,
JunQuoted 233 lines · wangjian
Hi Changwei,
I understand your idea. But we should be aware that the
cancel_convertprocess and other processes (accepting the AST process, the recovery process) are asynchronous. For example, according to your idea, check if the lock is in the grant queue before calling thedlm_send_remote_unlock_requestfunction in thedlm_proxy_ast_handlerfunction. Then decide whether to clearcancel_pending. But if the AST does not come at this time, the check passes andcancel_pendigwill not be cleared. Then AST immediately came over again, which also led to a bug. I personally think that for asynchronous processes we can't guarantee the speed of execution of each process. All we can do is to avoid the BUG scene.As for the question you said ("If you remove the BUG check why you still call
dlm_commit_pending_cancel()to move the lock back to grant on matter it's on converting list or not?").
I think we should first check if the lock is in the grant queue
(at this time,dlm->spinlockandres->spinlockhave been added), then decide whether to calldlm_commit_pending_cancelfunction.Thanks,
JianQuoted 203 lines · Changwei Ge
Hi Jian,
I suppose that the situation you described truly exists. But the way you fix the issue is not in my favor.
If you remove the BUG check why you still call
dlm_commit_pending_cancel()to move the lock back to grant on matter it's on converting list or not?So how about keeping the BUG check in
dlm_move_lockres_to_recovery_list().
If the locking _ast_ comes back very fast just check ::cancel_pending indlm_proxy_ast_handler()and clear it. Then with the logic checking if the lock is on grant list (indlmunlock_common()more less like your current method) or not we can easily tell if the cancellation succeeds or not.That complies the original dlm design, which I think is better and easier for maintainers to understand.
Thanks,
ChangweiQuoted 7 lines · wangjian
Hi Changwei,
I don't fully agree with your point of view. In my opinion, the lock cancellation process and the lock conversion process are asynchronous. We can't guarantee that the lock must be in the convert list during the lock conversion process, otherwise this BUG will not happen.
So, I think this is a meaningless BUG.Quoted 177 lines
Thanks,
JianQuoted 173 lines · Changwei Ge
Hi Jian,
I suppose you can't just remove the
BUG_ON()check. If you remove it, below code violates the original logic.'''
2141dlm_commit_pending_cancel(res, lock);
'''What's more important is *locking cancel* must be against a *locking conversion* progress. So it makes sense to check if this lock is on converting list.
So I have to NACK to this patch.
Thanks,
ChangweiQuoted 152 lines · wangjian
In the dlm_move_lockres_to_recovery_list function, if the lock
is in the granted queue and cancel_pending is set, it will
encounter a BUG. I think this is a meaningless BUG,
so be prepared to remove it. A scenario that causes
this BUG will be given below.At the beginning, Node 1 is the master and has NL lock,
Node 2 has PR lock, Node 3 has PR lock too.Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from
Node 1. downconvert
thread begin to
cancel PR to EX conversion.
In dlmunlock_common function,
downconvert thread has set
lock->cancel_pending,
but did not enter
dlm_send_remote_unlock_request
function.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1.
change lock level to EX,
move lock to granted list.Node1 dies because
the host is powered down.In dlm_move_lockres_to_recovery_list
function. the lock is in the
granted queue and cancel_pending
is set. BUG_ON.But after clearing this BUG, process will encounter
the second BUG in the ocfs2_unlock_ast function.
Here is a scenario that will cause the second BUG
in ocfs2_unlock_ast as follows:At the beginning, Node 1 is the master and has NL lock,
Node 2 has PR lock, Node 3 has PR lock too.Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from
Node 1. downconvert
thread begin to
cancel PR to EX conversion.
In dlmunlock_common function,
downconvert thread has released
lock->spinlock and res->spinlock,
but did not enter
dlm_send_remote_unlock_request
function.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1.
change lock level to EX,
move lock to granted list,
set lockres->l_unlock_action
as OCFS2_UNLOCK_INVALID
in ocfs2_locking_ast function.Node2 dies because
the host is powered down.Node 3 realize that Node 1
is dead, remove Node 1 from
domain_map. downconvert thread
get DLM_NORMAL from
dlm_send_remote_unlock_request
function and set *call_ast as 1.
Then downconvert thread meet
BUG in ocfs2_unlock_ast function.To avoid meet the second BUG, function dlmunlock_common shuold
return DLM_CANCELGRANT if the lock is on granted list and
the operation is canceled.Signed-off-by: Jian Wang<[email protected]>
Reviewed-by: Yiwen Jiang<[email protected]>
---
fs/ocfs2/dlm/dlmrecovery.c | 1 -
fs/ocfs2/dlm/dlmunlock.c | 5 +++++
2 files changed, 5 insertions(+), 1 deletion(-)diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c
index 802636d..7489652 100644
--- a/fs/ocfs2/dlm/dlmrecovery.c
+++ b/fs/ocfs2/dlm/dlmrecovery.c
@@ -2134,7 +2134,6 @@ void dlm_move_lockres_to_recovery_list(struct dlm_ctxt *dlm,
* if this had completed successfully
* before sending this lock state to the
* new master */
- BUG_ON(i != DLM_CONVERTING_LIST);
mlog(0, "node died with cancel pending "
"on %.*s. move back to granted list.\n",
res->lockname.len, res->lockname.name);
diff --git a/fs/ocfs2/dlm/dlmunlock.c b/fs/ocfs2/dlm/dlmunlock.c
index 63d701c..505bb6c 100644
--- a/fs/ocfs2/dlm/dlmunlock.c
+++ b/fs/ocfs2/dlm/dlmunlock.c
@@ -183,6 +183,11 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm,
flags, owner);
spin_lock(&res->spinlock);
spin_lock(&lock->spinlock);
+
+ if ((flags & LKM_CANCEL) &&
+ dlm_lock_on_list(&res->granted, lock))
+ status = DLM_CANCELGRANT;
+
/* if the master told us the lock was already granted,
* let the ast handle all of these actions */
if (status == DLM_CANCELGRANT) {
--
1.8.3.1.
Quoted 2 lines
.
_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel.
.
.
.
PATCH 1/1 ocfs2/dlm: return DLM_CANCELGRANT if the lock is on granted list and the operation is canceled
Hi Jun,
Quoted 97 lines · piaojun
Hi Changwei,
Quoted 94 lines · Changwei Ge
Quoted 93 lines · piaojun
Hi Changwei,
Quoted 82 lines · Changwei Ge
Hi Jun
I just read the code around unlock/cancel.
Quoted 37 lines · piaojun
Hi Changwei,
Quoted 34 lines · Changwei Ge
Hi Jun,
Quoted 31 lines · piaojun
Hi Changwei,
Quoted 28 lines · Changwei Ge
Quoted 4 lines · piaojun
Hi Changwei,
The problem can't be solved completely if clear ::cancel_pending in
dlm_proxy_ast_handler, as AST will come at anytime just beforeSo how about also add check here bere setting ::cancel_pending in
dlmunlock_common()before invokingdlm_send_remote_unlock_request(). If already on grant list just returnDLM_CANCELGRANTThen a further reference code might look like:
root at ubuntu16:/home/chge/linux[master]# git diff
fs/ocfs2/dlm/dlmast.c +4
-1@@ -372,8 +372,11 @@ int dlm_proxy_ast_handler(struct o2net_msg *msg, u32 len, void *data, head = &res->converting; lock =NULL ;list_for_each_entry (lock, head, list) { -if (lock->ml.cookie == cookie) +if (lock->ml.cookie == cookie) { +if (lock->cancel_pending) + lock->cancel_pending =0 ; goto do_ast; + } }Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
fs/ocfs2/dlm/dlmast.c +0
-0/* if not on convert, try blocked for ast, granted for bast */ fs/ocfs2/dlm/dlmunlock.c +0
-0@@ -174,9 +174,14 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm,Quoted 8 lines
Quoted 8 lines
fs/ocfs2/dlm/dlmunlock.c static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm, · line 180
Quoted 8 lines
fs/ocfs2/dlm/dlmunlock.c +4
-1if (!master_node) { owner = res->owner;/* drop locks and send message */ -if (flags &LKM_CANCEL ) +if (flags &LKM_CANCEL ) { +if (dlm_lock_on_list (&res->granted, lock)) { + status =DLM_CANCELGRANT ; + goto leave;I found that above code should be useless.
As upstream code already take it into consideration that AST has come before cancellation. Indlm_get_cancel_actions()''' } else if (dlm_lock_on_list(&res->granted, lock)) { /* too late, already granted. */ status = DLM_CANCELGRANT; *actions = DLM_UNLOCK_CALL_AST; } else { '''Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
If master dead and then lockres is moved to granted list in
dlm_move_lockres_to_recovery_list, theOCFS2_LOCK_BUSYis not cleared.
OCFS2_LOCK_BUSYshould be cleared inocfs2_locking_ast()since previous locking AST has come back(moving lock to grant list). That's why we returnDLM_CANCELGRANTto caller to avoid calling AST. Otherwiseast()will be called twice, which is obviously a BUG.Quoted 6 lines
I mean master is already dead and ast won't come. So the
OCFS2_LOCK_BUSYis not cleared. And there are two cases that lockres is moved to grant list:
1. AST comes back andOCFS2_LOCK_BUSYis cleared.
2. AST does not come back andOCFS2_LOCK_BUSYremains, recovery process move it to grant list. In this case, we need do AST for it.Quoted 2 lines
For point 2, ocfs2 can handle it, so you still don't have to worry. It's no problem. In
dlmconvert_remote()What I worry about is that
OCFS2_LOCK_BUSYwon't be cleared if remote master is dead, asOCFS2_LOCK_BUSYis cleared in two cases:
1. remote AST come, clear it indlm_proxy_ast_handler.
2. remote AST does not come when master dead, clear it ino2dlm_unlock_ast_wrapper.
If AST doesn't manage to get back to requested node, why must flag OCFS2_LOCK_BUSY be cleared in o2dlm_unlock_ast_wrapper?
Yes, OCFS2_LOCK_BUSY can be cleared it either o2dlm_unlock_ast_wrapper() or o2dlm_lock_ast_wrapper() with o2cb stack applied.
If we return DLM_CANCELGRANT from ocfs2/dlm to dlm, then we must know that AST has ever come back or master node has moved the lock to grant list itself, thus we clear flag OCFS2_LOCK_BUSY in o2dlm_lock_ast_wrapper(). Otherwise we ascertain that we can stop current ongoing locking procedure and must clear OCFS2_LOCK_BUSY in o2dlm_unlock_ast_wrapper() (*synchronized*).
Let's summarize this, OCFS2_LOCK_BUSY should be cleared whether by locking success or cancellation success.
And my way already check if the lock is granted then return DLM_CANCELGRANT or not.
Quoted 8 lines
Quoted 5 lines
Please don't worry about point 2.
Like my previous e-mail, after dlm recovery picking up a new master for corresponding lock resource.dlmlock()-> convert will retry and send request to new master.
Eventually, this locking(convert) will succeed andast()will be called for ocfs2 layer to clearOCFS2_LOCK_BUSY.Perhaps you misunderstand my meaning. The AST I meant is for dlmunlock, not for dlmlock, so it won't cause retry sending request to new master.
If the unlocking AST is not back then dlm_send_remote_unlock_request() returns NORMAL.
Because unlocking AST is synchronized with unlocking request, which means master won't sent back a separated message back(proxy ast type). That means *status* returned from dlm_send_remote_unlock_request() indicates AST for unlocking should be called or not. How can AST for unlocking can't be invoked.
You really make me puzzled. :- (((
Thanks,
Changwei
Quoted 314 lines
Quoted 313 lines
Thanks,
ChangweiQuoted 18 lines
For case 2, if
DLM_CANCELGRANTis set,o2dlm_unlock_ast_wrapperjust return and won't clearOCFS2_LOCK_BUSY. So in this case, I think we should do AST again for it.Quoted 13 lines
341 if (status !=
DLM_NORMAL) {
342 if (status !=DLM_NOTQUEUED)
343dlm_error(status);
344dlm_revert_pending_convert(res, lock);
345 } else if (!lock->convert_pending) {
346 mlog(0, "%s: res %.*s, owner died and lock has been moved back "
347 "to granted list, retry convert.\n",
348dlm->name,res->lockname.len,res->lockname.name);
349 status =DLM_RECOVERING;
350 }Quoted 288 lines
Quoted 2 lines
Thus,
dlmlock()will wait until RECOVERY is done.
And for ocfs2 layer, it's apparent, it doesn't have to be aware of what happened to DLM.I do not think the waiting can solve this problem.
Quoted 282 lines
Thanks,
ChangweiQuoted 275 lines
Perhaps we need do AST again for it.
Quoted 271 lines
Quoted 3 lines
And this will cause stuck problem when
ocfs2_drop_lock. The reason is that unlock ast won't be done whenDLM_CANCELGRANTis set. So I thinkWith above elaboration, you don't have to worry the hang issue anymore.
Thanks,
ChangweiQuoted 260 lines
we need distinguish all the cases of moving lockres to grant list.
Quoted 257 lines
fs/ocfs2/dlm/dlmunlock.c +3
-1+ } + lock->cancel_pending =1 ; - else + }else lock->unlock_pending =1 ;spin_unlock (&lock->spinlock);spin_unlock (&res->spinlock);Thanks,
ChangweiQuoted 241 lines
::cancel_pendig is set. If there is not any other better solutions, could we accept this patch? This bug is very harmful.
Thanks,
JunQuoted 233 lines · wangjian
Hi Changwei,
I understand your idea. But we should be aware that the
cancel_convertprocess and other processes (accepting the AST process, the recovery process) are asynchronous. For example, according to your idea, check if the lock is in the grant queue before calling thedlm_send_remote_unlock_requestfunction in thedlm_proxy_ast_handlerfunction. Then decide whether to clearcancel_pending. But if the AST does not come at this time, the check passes andcancel_pendigwill not be cleared. Then AST immediately came over again, which also led to a bug. I personally think that for asynchronous processes we can't guarantee the speed of execution of each process. All we can do is to avoid the BUG scene.As for the question you said ("If you remove the BUG check why you still call
dlm_commit_pending_cancel()to move the lock back to grant on matter it's on converting list or not?").
I think we should first check if the lock is in the grant queue
(at this time,dlm->spinlockandres->spinlockhave been added), then decide whether to calldlm_commit_pending_cancelfunction.Thanks,
JianQuoted 203 lines · Changwei Ge
Hi Jian,
I suppose that the situation you described truly exists. But the way you fix the issue is not in my favor.
If you remove the BUG check why you still call
dlm_commit_pending_cancel()to move the lock back to grant on matter it's on converting list or not?So how about keeping the BUG check in
dlm_move_lockres_to_recovery_list().
If the locking _ast_ comes back very fast just check ::cancel_pending indlm_proxy_ast_handler()and clear it. Then with the logic checking if the lock is on grant list (indlmunlock_common()more less like your current method) or not we can easily tell if the cancellation succeeds or not.That complies the original dlm design, which I think is better and easier for maintainers to understand.
Thanks,
ChangweiQuoted 7 lines · wangjian
Hi Changwei,
I don't fully agree with your point of view. In my opinion, the lock cancellation process and the lock conversion process are asynchronous. We can't guarantee that the lock must be in the convert list during the lock conversion process, otherwise this BUG will not happen.
So, I think this is a meaningless BUG.Quoted 177 lines
Thanks,
JianQuoted 173 lines · Changwei Ge
Hi Jian,
I suppose you can't just remove the BUG_ON() check.
If you remove it, below code violates the original logic.'''
2141 dlm_commit_pending_cancel(res, lock);
'''What's more important is *locking cancel* must be against a *locking conversion* progress.
So it makes sense to check if this lock is on converting list.So I have to NACK to this patch.
Thanks,
ChangweiOn 2018/12/3 20:23, wangjian wrote:
In the dlm_move_lockres_to_recovery_list function, if the lock
is in the granted queue and cancel_pending is set, it will
encounter a BUG. I think this is a meaningless BUG,
so be prepared to remove it. A scenario that causes
this BUG will be given below.At the beginning, Node 1 is the master and has NL lock,
Node 2 has PR lock, Node 3 has PR lock too.Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from
Node 1. downconvert
thread begin to
cancel PR to EX conversion.
In dlmunlock_common function,
downconvert thread has set
lock->cancel_pending,
but did not enter
dlm_send_remote_unlock_request
function.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1.
change lock level to EX,
move lock to granted list.Node1 dies because
the host is powered down.In dlm_move_lockres_to_recovery_list
function. the lock is in the
granted queue and cancel_pending
is set. BUG_ON.But after clearing this BUG, process will encounter
the second BUG in the ocfs2_unlock_ast function.
Here is a scenario that will cause the second BUG
in ocfs2_unlock_ast as follows:At the beginning, Node 1 is the master and has NL lock,
Node 2 has PR lock, Node 3 has PR lock too.Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from
Node 1. downconvert
thread begin to
cancel PR to EX conversion.
In dlmunlock_common function,
downconvert thread has released
lock->spinlock and res->spinlock,
but did not enter
dlm_send_remote_unlock_request
function.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1.
change lock level to EX,
move lock to granted list,
set lockres->l_unlock_action
as OCFS2_UNLOCK_INVALID
in ocfs2_locking_ast function.Node2 dies because
the host is powered down.Node 3 realize that Node 1
is dead, remove Node 1 from
domain_map. downconvert thread
get DLM_NORMAL from
dlm_send_remote_unlock_request
function and set *call_ast as 1.
Then downconvert thread meet
BUG in ocfs2_unlock_ast function.To avoid meet the second BUG, function dlmunlock_common shuold
return DLM_CANCELGRANT if the lock is on granted list and
the operation is canceled.Signed-off-by: Jian Wang<[email protected]>
Reviewed-by: Yiwen Jiang<[email protected]>
---
fs/ocfs2/dlm/dlmrecovery.c | 1 -
fs/ocfs2/dlm/dlmunlock.c | 5 +++++
2 files changed, 5 insertions(+), 1 deletion(-)diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c
index 802636d..7489652 100644
--- a/fs/ocfs2/dlm/dlmrecovery.c
+++ b/fs/ocfs2/dlm/dlmrecovery.c
@@ -2134,7 +2134,6 @@ void dlm_move_lockres_to_recovery_list(struct dlm_ctxt *dlm,
* if this had completed successfully
* before sending this lock state to the
* new master */
- BUG_ON(i != DLM_CONVERTING_LIST);
mlog(0, "node died with cancel pending "
"on %.*s. move back to granted list.\n",
res->lockname.len, res->lockname.name);
diff --git a/fs/ocfs2/dlm/dlmunlock.c b/fs/ocfs2/dlm/dlmunlock.c
index 63d701c..505bb6c 100644
--- a/fs/ocfs2/dlm/dlmunlock.c
+++ b/fs/ocfs2/dlm/dlmunlock.c
@@ -183,6 +183,11 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm,
flags, owner);
spin_lock(&res->spinlock);
spin_lock(&lock->spinlock);
+
+ if ((flags & LKM_CANCEL) &&
+ dlm_lock_on_list(&res->granted, lock))
+ status = DLM_CANCELGRANT;
+
/* if the master told us the lock was already granted,
* let the ast handle all of these actions */
if (status == DLM_CANCELGRANT) {
--
1.8.3.1.
Quoted 2 lines
.
_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel.
.
.
.
PATCH 1/1 ocfs2/dlm: return DLM_CANCELGRANT if the lock is on granted list and the operation is canceled
Hi Changwei,
Quoted 103 lines · Changwei Ge
Hi Jun,
Quoted 97 lines · piaojun
Hi Changwei,
Quoted 94 lines · Changwei Ge
Quoted 93 lines · piaojun
Hi Changwei,
Quoted 82 lines · Changwei Ge
Hi Jun
I just read the code around unlock/cancel.
Quoted 37 lines · piaojun
Hi Changwei,
Quoted 34 lines · Changwei Ge
Hi Jun,
Quoted 31 lines · piaojun
Hi Changwei,
Quoted 28 lines · Changwei Ge
Quoted 4 lines · piaojun
Hi Changwei,
The problem can't be solved completely if clear ::cancel_pending in
dlm_proxy_ast_handler, as AST will come at anytime just beforeSo how about also add check here bere setting ::cancel_pending in
dlmunlock_common()before invokingdlm_send_remote_unlock_request(). If already on grant list just returnDLM_CANCELGRANTThen a further reference code might look like:
root at ubuntu16:/home/chge/linux[master]# git diff
fs/ocfs2/dlm/dlmast.c +4
-1@@ -372,8 +372,11 @@ int dlm_proxy_ast_handler(struct o2net_msg *msg, u32 len, void *data, head = &res->converting; lock =NULL ;list_for_each_entry (lock, head, list) { -if (lock->ml.cookie == cookie) +if (lock->ml.cookie == cookie) { +if (lock->cancel_pending) + lock->cancel_pending =0 ; goto do_ast; + } }Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
fs/ocfs2/dlm/dlmast.c +0
-0/* if not on convert, try blocked for ast, granted for bast */ fs/ocfs2/dlm/dlmunlock.c +0
-0@@ -174,9 +174,14 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm,Quoted 8 lines
Quoted 8 lines
fs/ocfs2/dlm/dlmunlock.c static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm, · line 180
Quoted 8 lines
fs/ocfs2/dlm/dlmunlock.c +4
-1if (!master_node) { owner = res->owner;/* drop locks and send message */ -if (flags &LKM_CANCEL ) +if (flags &LKM_CANCEL ) { +if (dlm_lock_on_list (&res->granted, lock)) { + status =DLM_CANCELGRANT ; + goto leave;I found that above code should be useless.
As upstream code already take it into consideration that AST has come before cancellation. Indlm_get_cancel_actions()''' } else if (dlm_lock_on_list(&res->granted, lock)) { /* too late, already granted. */ status = DLM_CANCELGRANT; *actions = DLM_UNLOCK_CALL_AST; } else { '''Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
If master dead and then lockres is moved to granted list in
dlm_move_lockres_to_recovery_list, theOCFS2_LOCK_BUSYis not cleared.
OCFS2_LOCK_BUSYshould be cleared inocfs2_locking_ast()since previous locking AST has come back(moving lock to grant list). That's why we returnDLM_CANCELGRANTto caller to avoid calling AST. Otherwiseast()will be called twice, which is obviously a BUG.Quoted 6 lines
I mean master is already dead and ast won't come. So the
OCFS2_LOCK_BUSYis not cleared. And there are two cases that lockres is moved to grant list:
1. AST comes back andOCFS2_LOCK_BUSYis cleared.
2. AST does not come back andOCFS2_LOCK_BUSYremains, recovery process move it to grant list. In this case, we need do AST for it.Quoted 2 lines
For point 2, ocfs2 can handle it, so you still don't have to worry. It's no problem. In
dlmconvert_remote()What I worry about is that
OCFS2_LOCK_BUSYwon't be cleared if remote master is dead, asOCFS2_LOCK_BUSYis cleared in two cases:
1. remote AST come, clear it indlm_proxy_ast_handler.
2. remote AST does not come when master dead, clear it ino2dlm_unlock_ast_wrapper.If AST doesn't manage to get back to requested node, why must flag
OCFS2_LOCK_BUSYbe cleared ino2dlm_unlock_ast_wrapper?
Quoted 9 lines
Yes,
OCFS2_LOCK_BUSYcan be cleared it eithero2dlm_unlock_ast_wrapper()oro2dlm_lock_ast_wrapper()with o2cb stack applied.If we return
DLM_CANCELGRANTfrom ocfs2/dlm to dlm, then we must know that AST has ever come back or master node has moved the lock to grant list itself, thus we clear flagOCFS2_LOCK_BUSYino2dlm_lock_ast_wrapper(). Otherwise we ascertain that we can stop current ongoing locking procedure and must clearOCFS2_LOCK_BUSYino2dlm_unlock_ast_wrapper()(*synchronized*).Let's summarize this,
OCFS2_LOCK_BUSYshould be cleared whether by locking success or cancellation success.And my way already check if the lock is granted then return
DLM_CANCELGRANTor not.
OCFS2_LOCK_BUSY won't be cleared if DLM_CANCELGRANT is set in o2dlm_unlock_ast_wrapper, and that's what I'm concerned about:
static void o2dlm_unlock_ast_wrapper(void *astarg, enum dlm_status status)
{
struct ocfs2_dlm_lksb *lksb = astarg;
int error = dlm_status_to_errno(status);
/*
* In o2dlm, you can get both the lock_ast() for the lock being
* granted and the unlock_ast() for the CANCEL failing. A
* successful cancel sends DLM_NORMAL here. If the
* lock grant happened before the cancel arrived, you get
* DLM_CANCELGRANT.
*
* There's no need for the double-ast. If we see DLM_CANCELGRANT,
* we just ignore it. We expect the lock_ast() to handle the
* granted lock.
*/
if (status == DLM_CANCELGRANT)
return;
lksb->lksb_conn->cc_proto->lp_unlock_ast(lksb, error);
}Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Please don't worry about point 2.
Like my previous e-mail, after dlm recovery picking up a new master for corresponding lock resource.dlmlock()-> convert will retry and send request to new master.
Eventually, this locking(convert) will succeed andast()will be called for ocfs2 layer to clearOCFS2_LOCK_BUSY.
Quoted 7 lines
Quoted 2 lines
Perhaps you misunderstand my meaning. The AST I meant is for dlmunlock, not for dlmlock, so it won't cause retry sending request to new master.
If the unlocking AST is not back then
dlm_send_remote_unlock_request()returns NORMAL.
Because unlocking AST is synchronized with unlocking request, which means master won't sent back a separated message back(proxy ast type). That means *status* returned fromdlm_send_remote_unlock_request()indicates AST for unlocking should be called or not. How can AST for unlocking can't be invoked.
Sure, unlocking AST will be invoked, but do nothing(including clear OCFS2_LOCK_BUSY).
Quoted 322 lines
You really make me puzzled. :- (((
Thanks,
ChangweiQuoted 305 lines
Quoted 305 lines
Thanks,
ChangweiQuoted 300 lines
For case 2, if
DLM_CANCELGRANTis set,o2dlm_unlock_ast_wrapperjust return and won't clearOCFS2_LOCK_BUSY. So in this case, I think we should do AST again for it.Quoted 13 lines
341 if (status !=
DLM_NORMAL) {
342 if (status !=DLM_NOTQUEUED)
343dlm_error(status);
344dlm_revert_pending_convert(res, lock);
345 } else if (!lock->convert_pending) {
346 mlog(0, "%s: res %.*s, owner died and lock has been moved back "
347 "to granted list, retry convert.\n",
348dlm->name,res->lockname.len,res->lockname.name);
349 status =DLM_RECOVERING;
350 }Quoted 2 lines
Thus,
dlmlock()will wait until RECOVERY is done.
And for ocfs2 layer, it's apparent, it doesn't have to be aware of what happened to DLM.I do not think the waiting can solve this problem.
Quoted 277 lines
Thanks,
ChangweiQuoted 272 lines
Perhaps we need do AST again for it.
Quoted 269 lines
Quoted 3 lines
And this will cause stuck problem when
ocfs2_drop_lock. The reason is that unlock ast won't be done whenDLM_CANCELGRANTis set. So I thinkWith above elaboration, you don't have to worry the hang issue anymore.
Thanks,
ChangweiQuoted 260 lines
we need distinguish all the cases of moving lockres to grant list.
Quoted 257 lines
fs/ocfs2/dlm/dlmunlock.c +3
-1+ } + lock->cancel_pending =1 ; - else + }else lock->unlock_pending =1 ;spin_unlock (&lock->spinlock);spin_unlock (&res->spinlock);Thanks,
ChangweiQuoted 241 lines
::cancel_pendig is set. If there is not any other better solutions, could we accept this patch? This bug is very harmful.
Thanks,
JunQuoted 233 lines · wangjian
Hi Changwei,
I understand your idea. But we should be aware that the
cancel_convertprocess and other processes (accepting the AST process, the recovery process) are asynchronous. For example, according to your idea, check if the lock is in the grant queue before calling thedlm_send_remote_unlock_requestfunction in thedlm_proxy_ast_handlerfunction. Then decide whether to clearcancel_pending. But if the AST does not come at this time, the check passes andcancel_pendigwill not be cleared. Then AST immediately came over again, which also led to a bug. I personally think that for asynchronous processes we can't guarantee the speed of execution of each process. All we can do is to avoid the BUG scene.As for the question you said ("If you remove the BUG check why you still call
dlm_commit_pending_cancel()to move the lock back to grant on matter it's on converting list or not?").
I think we should first check if the lock is in the grant queue
(at this time,dlm->spinlockandres->spinlockhave been added), then decide whether to calldlm_commit_pending_cancelfunction.Thanks,
JianQuoted 203 lines · Changwei Ge
Hi Jian,
I suppose that the situation you described truly exists. But the way you fix the issue is not in my favor.
If you remove the BUG check why you still call
dlm_commit_pending_cancel()to move the lock back to grant on matter it's on converting list or not?So how about keeping the BUG check in
dlm_move_lockres_to_recovery_list().
If the locking _ast_ comes back very fast just check ::cancel_pending indlm_proxy_ast_handler()and clear it. Then with the logic checking if the lock is on grant list (indlmunlock_common()more less like your current method) or not we can easily tell if the cancellation succeeds or not.That complies the original dlm design, which I think is better and easier for maintainers to understand.
Thanks,
ChangweiQuoted 184 lines · wangjian
Hi Changwei,
I don't fully agree with your point of view. In my opinion, the lock cancellation process and the lock
conversion process are asynchronous. We can't guarantee that the lock must be in the convert list
during the lock conversion process, otherwise this BUG will not happen.
So, I think this is a meaningless BUG.Thanks,
JianOn 12/5/2018 9:49 AM, Changwei Ge wrote:
Hi Jian,I suppose you can't just remove the BUG_ON() check.
If you remove it, below code violates the original logic.'''
2141 dlm_commit_pending_cancel(res, lock);
'''What's more important is *locking cancel* must be against a *locking conversion* progress.
So it makes sense to check if this lock is on converting list.So I have to NACK to this patch.
Thanks,
ChangweiOn 2018/12/3 20:23, wangjian wrote:
In the dlm_move_lockres_to_recovery_list function, if the lock
is in the granted queue and cancel_pending is set, it will
encounter a BUG. I think this is a meaningless BUG,
so be prepared to remove it. A scenario that causes
this BUG will be given below.At the beginning, Node 1 is the master and has NL lock,
Node 2 has PR lock, Node 3 has PR lock too.Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from
Node 1. downconvert
thread begin to
cancel PR to EX conversion.
In dlmunlock_common function,
downconvert thread has set
lock->cancel_pending,
but did not enter
dlm_send_remote_unlock_request
function.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1.
change lock level to EX,
move lock to granted list.Node1 dies because
the host is powered down.In dlm_move_lockres_to_recovery_list
function. the lock is in the
granted queue and cancel_pending
is set. BUG_ON.But after clearing this BUG, process will encounter
the second BUG in the ocfs2_unlock_ast function.
Here is a scenario that will cause the second BUG
in ocfs2_unlock_ast as follows:At the beginning, Node 1 is the master and has NL lock,
Node 2 has PR lock, Node 3 has PR lock too.Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from
Node 1. downconvert
thread begin to
cancel PR to EX conversion.
In dlmunlock_common function,
downconvert thread has released
lock->spinlock and res->spinlock,
but did not enter
dlm_send_remote_unlock_request
function.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1.
change lock level to EX,
move lock to granted list,
set lockres->l_unlock_action
as OCFS2_UNLOCK_INVALID
in ocfs2_locking_ast function.Node2 dies because
the host is powered down.Node 3 realize that Node 1
is dead, remove Node 1 from
domain_map. downconvert thread
get DLM_NORMAL from
dlm_send_remote_unlock_request
function and set *call_ast as 1.
Then downconvert thread meet
BUG in ocfs2_unlock_ast function.To avoid meet the second BUG, function dlmunlock_common shuold
return DLM_CANCELGRANT if the lock is on granted list and
the operation is canceled.Signed-off-by: Jian Wang<[email protected]>
Reviewed-by: Yiwen Jiang<[email protected]>
---
fs/ocfs2/dlm/dlmrecovery.c | 1 -
fs/ocfs2/dlm/dlmunlock.c | 5 +++++
2 files changed, 5 insertions(+), 1 deletion(-)diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c
index 802636d..7489652 100644
--- a/fs/ocfs2/dlm/dlmrecovery.c
+++ b/fs/ocfs2/dlm/dlmrecovery.c
@@ -2134,7 +2134,6 @@ void dlm_move_lockres_to_recovery_list(struct dlm_ctxt *dlm,
* if this had completed successfully
* before sending this lock state to the
* new master */
- BUG_ON(i != DLM_CONVERTING_LIST);
mlog(0, "node died with cancel pending "
"on %.*s. move back to granted list.\n",
res->lockname.len, res->lockname.name);
diff --git a/fs/ocfs2/dlm/dlmunlock.c b/fs/ocfs2/dlm/dlmunlock.c
index 63d701c..505bb6c 100644
--- a/fs/ocfs2/dlm/dlmunlock.c
+++ b/fs/ocfs2/dlm/dlmunlock.c
@@ -183,6 +183,11 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm,
flags, owner);
spin_lock(&res->spinlock);
spin_lock(&lock->spinlock);
+
+ if ((flags & LKM_CANCEL) &&
+ dlm_lock_on_list(&res->granted, lock))
+ status = DLM_CANCELGRANT;
+
/* if the master told us the lock was already granted,
* let the ast handle all of these actions */
if (status == DLM_CANCELGRANT) {
--
1.8.3.1.
Quoted 2 lines
.
_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel.
Quoted 9 lines
Quoted 8 lines
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines
Quoted 2 lines
.
.
.
.
PATCH 1/1 ocfs2/dlm: return DLM_CANCELGRANT if the lock is on granted list and the operation is canceled
Hi Jun,
Quoted 111 lines · piaojun
Hi Changwei,
Quoted 108 lines · Changwei Ge
Hi Jun,
Quoted 97 lines · piaojun
Hi Changwei,
Quoted 94 lines · Changwei Ge
Quoted 93 lines · piaojun
Hi Changwei,
Quoted 82 lines · Changwei Ge
Hi Jun
I just read the code around unlock/cancel.
Quoted 37 lines · piaojun
Hi Changwei,
Quoted 34 lines · Changwei Ge
Hi Jun,
Quoted 31 lines · piaojun
Hi Changwei,
Quoted 28 lines · Changwei Ge
Quoted 4 lines · piaojun
Hi Changwei,
The problem can't be solved completely if clear ::cancel_pending in
dlm_proxy_ast_handler, as AST will come at anytime just beforeSo how about also add check here bere setting ::cancel_pending in
dlmunlock_common()before invokingdlm_send_remote_unlock_request(). If already on grant list just returnDLM_CANCELGRANTThen a further reference code might look like:
root at ubuntu16:/home/chge/linux[master]# git diff
fs/ocfs2/dlm/dlmast.c +4
-1@@ -372,8 +372,11 @@ int dlm_proxy_ast_handler(struct o2net_msg *msg, u32 len, void *data, head = &res->converting; lock =NULL ;list_for_each_entry (lock, head, list) { -if (lock->ml.cookie == cookie) +if (lock->ml.cookie == cookie) { +if (lock->cancel_pending) + lock->cancel_pending =0 ; goto do_ast; + } }Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
fs/ocfs2/dlm/dlmast.c +0
-0/* if not on convert, try blocked for ast, granted for bast */ fs/ocfs2/dlm/dlmunlock.c +0
-0@@ -174,9 +174,14 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm,Quoted 8 lines
Quoted 8 lines
fs/ocfs2/dlm/dlmunlock.c static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm, · line 180
Quoted 8 lines
fs/ocfs2/dlm/dlmunlock.c +4
-1if (!master_node) { owner = res->owner;/* drop locks and send message */ -if (flags &LKM_CANCEL ) +if (flags &LKM_CANCEL ) { +if (dlm_lock_on_list (&res->granted, lock)) { + status =DLM_CANCELGRANT ; + goto leave;I found that above code should be useless.
As upstream code already take it into consideration that AST has come before cancellation. Indlm_get_cancel_actions()''' } else if (dlm_lock_on_list(&res->granted, lock)) { /* too late, already granted. */ status = DLM_CANCELGRANT; *actions = DLM_UNLOCK_CALL_AST; } else { '''Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
If master dead and then lockres is moved to granted list in
dlm_move_lockres_to_recovery_list, theOCFS2_LOCK_BUSYis not cleared.
OCFS2_LOCK_BUSYshould be cleared inocfs2_locking_ast()since previous locking AST has come back(moving lock to grant list). That's why we returnDLM_CANCELGRANTto caller to avoid calling AST. Otherwiseast()will be called twice, which is obviously a BUG.Quoted 6 lines
I mean master is already dead and ast won't come. So the
OCFS2_LOCK_BUSYis not cleared. And there are two cases that lockres is moved to grant list:
1. AST comes back andOCFS2_LOCK_BUSYis cleared.
2. AST does not come back andOCFS2_LOCK_BUSYremains, recovery process move it to grant list. In this case, we need do AST for it.Quoted 2 lines
For point 2, ocfs2 can handle it, so you still don't have to worry. It's no problem. In
dlmconvert_remote()What I worry about is that
OCFS2_LOCK_BUSYwon't be cleared if remote master is dead, asOCFS2_LOCK_BUSYis cleared in two cases:
1. remote AST come, clear it indlm_proxy_ast_handler.
2. remote AST does not come when master dead, clear it ino2dlm_unlock_ast_wrapper.If AST doesn't manage to get back to requested node, why must flag
OCFS2_LOCK_BUSYbe cleared ino2dlm_unlock_ast_wrapper?Yes,
OCFS2_LOCK_BUSYcan be cleared it eithero2dlm_unlock_ast_wrapper()oro2dlm_lock_ast_wrapper()with o2cb stack applied.If we return
DLM_CANCELGRANTfrom ocfs2/dlm to dlm, then we must know that AST has ever come back or master node has moved the lock to grant list itself, thus we clear flagOCFS2_LOCK_BUSYino2dlm_lock_ast_wrapper(). Otherwise we ascertain that we can stop current ongoing locking procedure and must clearOCFS2_LOCK_BUSYino2dlm_unlock_ast_wrapper()(*synchronized*).
Quoted 7 lines
Quoted 4 lines
Let's summarize this,
OCFS2_LOCK_BUSYshould be cleared whether by locking success or cancellation success.And my way already check if the lock is granted then return
DLM_CANCELGRANTor not.
OCFS2_LOCK_BUSYwon't be cleared ifDLM_CANCELGRANTis set ino2dlm_unlock_ast_wrapper, and that's what I'm concerned about:
But we already *ascertain* that previous locking request has been *granted* before deciding to return DLM_CANCELGRANT during cancellation to o2dlm_unlock_ast_wrapper().
If above condition stands, o2dlm_lock_ast_wrapper() must will be or have been called, which also clears OCFS2_LOCK_BUSY.
Quoted 32 lines
static void
o2dlm_unlock_ast_wrapper(void *astarg, enum dlm_status status){ struct ocfs2_dlm_lksb *lksb = astarg; int error = dlm_status_to_errno(status); /* * In o2dlm, you can get both the lock_ast() for the lock being * granted and the unlock_ast() for the CANCEL failing. A * successful cancel sends DLM_NORMAL here. If the * lock grant happened before the cancel arrived, you get * DLM_CANCELGRANT. * * There's no need for the double-ast. If we see DLM_CANCELGRANT, * we just ignore it. We expect the lock_ast() to handle the * granted lock. */ if (status == DLM_CANCELGRANT) return; lksb->lksb_conn->cc_proto->lp_unlock_ast(lksb, error); }Quoted 9 lines
Quoted 8 lines
Quoted 5 lines
Please don't worry about point 2.
Like my previous e-mail, after dlm recovery picking up a new master for corresponding lock resource.dlmlock()-> convert will retry and send request to new master.
Eventually, this locking(convert) will succeed andast()will be called for ocfs2 layer to clearOCFS2_LOCK_BUSY.Perhaps you misunderstand my meaning. The AST I meant is for dlmunlock, not for dlmlock, so it won't cause retry sending request to new master.
Quoted 7 lines
Quoted 4 lines
If the unlocking AST is not back then
dlm_send_remote_unlock_request()returns NORMAL.
Because unlocking AST is synchronized with unlocking request, which means master won't sent back a separated message back(proxy ast type). That means *status* returned fromdlm_send_remote_unlock_request()indicates AST for unlocking should be called or not. How can AST for unlocking can't be invoked.Sure, unlocking AST will be invoked, but do
nothing(including clear OCFS2_LOCK_BUSY).
Actually, it should do nothing since what we want will be done around the locking-grant code logic (including clearing OCFS2_LOCK_BUSY). Please note that we must ensure the locking can granted, which will fail relevant cancellation.
Thanks,
Changwei
Quoted 324 lines
Quoted 323 lines
You really make me puzzled. :- (((
Thanks,
ChangweiQuoted 305 lines
Quoted 305 lines
Thanks,
ChangweiQuoted 300 lines
For case 2, if
DLM_CANCELGRANTis set,o2dlm_unlock_ast_wrapperjust return and won't clearOCFS2_LOCK_BUSY. So in this case, I think we should do AST again for it.Quoted 13 lines
341 if (status !=
DLM_NORMAL) {
342 if (status !=DLM_NOTQUEUED)
343dlm_error(status);
344dlm_revert_pending_convert(res, lock);
345 } else if (!lock->convert_pending) {
346 mlog(0, "%s: res %.*s, owner died and lock has been moved back "
347 "to granted list, retry convert.\n",
348dlm->name,res->lockname.len,res->lockname.name);
349 status =DLM_RECOVERING;
350 }Quoted 2 lines
Thus,
dlmlock()will wait until RECOVERY is done.
And for ocfs2 layer, it's apparent, it doesn't have to be aware of what happened to DLM.I do not think the waiting can solve this problem.
Quoted 277 lines
Thanks,
ChangweiQuoted 272 lines
Perhaps we need do AST again for it.
Quoted 269 lines
Quoted 3 lines
And this will cause stuck problem when
ocfs2_drop_lock. The reason is that unlock ast won't be done whenDLM_CANCELGRANTis set. So I thinkWith above elaboration, you don't have to worry the hang issue anymore.
Thanks,
ChangweiQuoted 260 lines
we need distinguish all the cases of moving lockres to grant list.
Quoted 257 lines
fs/ocfs2/dlm/dlmunlock.c +3
-1+ } + lock->cancel_pending =1 ; - else + }else lock->unlock_pending =1 ;spin_unlock (&lock->spinlock);spin_unlock (&res->spinlock);Thanks,
ChangweiQuoted 241 lines
::cancel_pendig is set. If there is not any other better solutions, could we accept this patch? This bug is very harmful.
Thanks,
JunQuoted 233 lines · wangjian
Hi Changwei,
I understand your idea. But we should be aware that the
cancel_convertprocess and other processes (accepting the AST process, the recovery process) are asynchronous. For example, according to your idea, check if the lock is in the grant queue before calling thedlm_send_remote_unlock_requestfunction in thedlm_proxy_ast_handlerfunction. Then decide whether to clearcancel_pending. But if the AST does not come at this time, the check passes andcancel_pendigwill not be cleared. Then AST immediately came over again, which also led to a bug. I personally think that for asynchronous processes we can't guarantee the speed of execution of each process. All we can do is to avoid the BUG scene.As for the question you said ("If you remove the BUG check why you still call
dlm_commit_pending_cancel()to move the lock back to grant on matter it's on converting list or not?").
I think we should first check if the lock is in the grant queue
(at this time,dlm->spinlockandres->spinlockhave been added), then decide whether to calldlm_commit_pending_cancelfunction.Thanks,
JianQuoted 205 lines · Changwei Ge
Hi Jian,
I suppose that the situation you described truly exists.
But the way you fix the issue is not in my favor.If you remove the BUG check why you still call dlm_commit_pending_cancel() to
move the lock back to grant on matter it's on converting list or not?So how about keeping the BUG check in dlm_move_lockres_to_recovery_list().
If the locking _ast_ comes back very fast just check ::cancel_pending in dlm_proxy_ast_handler() and clear it.
Then with the logic checking if the lock is on grant list (in dlmunlock_common() more less like your current method)
or not we can easily tell if the cancellation succeeds or not.That complies the original dlm design, which I think is better and easier for maintainers to understand.
Thanks,
ChangweiOn 2018/12/6 20:06, wangjian wrote:
Hi Changwei,I don't fully agree with your point of view. In my opinion, the lock cancellation process and the lock
conversion process are asynchronous. We can't guarantee that the lock must be in the convert list
during the lock conversion process, otherwise this BUG will not happen.
So, I think this is a meaningless BUG.Thanks,
JianOn 12/5/2018 9:49 AM, Changwei Ge wrote:
Hi Jian,I suppose you can't just remove the BUG_ON() check.
If you remove it, below code violates the original logic.'''
2141 dlm_commit_pending_cancel(res, lock);
'''What's more important is *locking cancel* must be against a *locking conversion* progress.
So it makes sense to check if this lock is on converting list.So I have to NACK to this patch.
Thanks,
ChangweiOn 2018/12/3 20:23, wangjian wrote:
In the dlm_move_lockres_to_recovery_list function, if the lock
is in the granted queue and cancel_pending is set, it will
encounter a BUG. I think this is a meaningless BUG,
so be prepared to remove it. A scenario that causes
this BUG will be given below.At the beginning, Node 1 is the master and has NL lock,
Node 2 has PR lock, Node 3 has PR lock too.Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from
Node 1. downconvert
thread begin to
cancel PR to EX conversion.
In dlmunlock_common function,
downconvert thread has set
lock->cancel_pending,
but did not enter
dlm_send_remote_unlock_request
function.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1.
change lock level to EX,
move lock to granted list.Node1 dies because
the host is powered down.In dlm_move_lockres_to_recovery_list
function. the lock is in the
granted queue and cancel_pending
is set. BUG_ON.But after clearing this BUG, process will encounter
the second BUG in the ocfs2_unlock_ast function.
Here is a scenario that will cause the second BUG
in ocfs2_unlock_ast as follows:At the beginning, Node 1 is the master and has NL lock,
Node 2 has PR lock, Node 3 has PR lock too.Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from
Node 1. downconvert
thread begin to
cancel PR to EX conversion.
In dlmunlock_common function,
downconvert thread has released
lock->spinlock and res->spinlock,
but did not enter
dlm_send_remote_unlock_request
function.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1.
change lock level to EX,
move lock to granted list,
set lockres->l_unlock_action
as OCFS2_UNLOCK_INVALID
in ocfs2_locking_ast function.Node2 dies because
the host is powered down.Node 3 realize that Node 1
is dead, remove Node 1 from
domain_map. downconvert thread
get DLM_NORMAL from
dlm_send_remote_unlock_request
function and set *call_ast as 1.
Then downconvert thread meet
BUG in ocfs2_unlock_ast function.To avoid meet the second BUG, function dlmunlock_common shuold
return DLM_CANCELGRANT if the lock is on granted list and
the operation is canceled.Signed-off-by: Jian Wang<[email protected]>
Reviewed-by: Yiwen Jiang<[email protected]>
---
fs/ocfs2/dlm/dlmrecovery.c | 1 -
fs/ocfs2/dlm/dlmunlock.c | 5 +++++
2 files changed, 5 insertions(+), 1 deletion(-)diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c
index 802636d..7489652 100644
--- a/fs/ocfs2/dlm/dlmrecovery.c
+++ b/fs/ocfs2/dlm/dlmrecovery.c
@@ -2134,7 +2134,6 @@ void dlm_move_lockres_to_recovery_list(struct dlm_ctxt *dlm,
* if this had completed successfully
* before sending this lock state to the
* new master */
- BUG_ON(i != DLM_CONVERTING_LIST);
mlog(0, "node died with cancel pending "
"on %.*s. move back to granted list.\n",
res->lockname.len, res->lockname.name);
diff --git a/fs/ocfs2/dlm/dlmunlock.c b/fs/ocfs2/dlm/dlmunlock.c
index 63d701c..505bb6c 100644
--- a/fs/ocfs2/dlm/dlmunlock.c
+++ b/fs/ocfs2/dlm/dlmunlock.c
@@ -183,6 +183,11 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm,
flags, owner);
spin_lock(&res->spinlock);
spin_lock(&lock->spinlock);
+
+ if ((flags & LKM_CANCEL) &&
+ dlm_lock_on_list(&res->granted, lock))
+ status = DLM_CANCELGRANT;
+
/* if the master told us the lock was already granted,
* let the ast handle all of these actions */
if (status == DLM_CANCELGRANT) {
--
1.8.3.1.
.
_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel.
Quoted 9 lines
Quoted 8 lines
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines
Quoted 2 lines
.
.
.
.
PATCH 1/1 ocfs2/dlm: return DLM_CANCELGRANT if the lock is on granted list and the operation is canceled
Hi Changwei,
Quoted 119 lines · Changwei Ge
Hi Jun,
Quoted 116 lines · piaojun
Hi Changwei,
Quoted 112 lines · Changwei Ge
Hi Jun,
Quoted 97 lines · piaojun
Hi Changwei,
Quoted 94 lines · Changwei Ge
Quoted 93 lines · piaojun
Hi Changwei,
Quoted 82 lines · Changwei Ge
Hi Jun
I just read the code around unlock/cancel.
Quoted 37 lines · piaojun
Hi Changwei,
Quoted 34 lines · Changwei Ge
Hi Jun,
Quoted 31 lines · piaojun
Hi Changwei,
Quoted 28 lines · Changwei Ge
Quoted 4 lines · piaojun
Hi Changwei,
The problem can't be solved completely if clear ::cancel_pending in
dlm_proxy_ast_handler, as AST will come at anytime just beforeSo how about also add check here bere setting ::cancel_pending in
dlmunlock_common()before invokingdlm_send_remote_unlock_request(). If already on grant list just returnDLM_CANCELGRANTThen a further reference code might look like:
root at ubuntu16:/home/chge/linux[master]# git diff
fs/ocfs2/dlm/dlmast.c +4
-1@@ -372,8 +372,11 @@ int dlm_proxy_ast_handler(struct o2net_msg *msg, u32 len, void *data, head = &res->converting; lock =NULL ;list_for_each_entry (lock, head, list) { -if (lock->ml.cookie == cookie) +if (lock->ml.cookie == cookie) { +if (lock->cancel_pending) + lock->cancel_pending =0 ; goto do_ast; + } }Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
fs/ocfs2/dlm/dlmast.c +0
-0/* if not on convert, try blocked for ast, granted for bast */ fs/ocfs2/dlm/dlmunlock.c +0
-0@@ -174,9 +174,14 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm,Quoted 8 lines
Quoted 8 lines
fs/ocfs2/dlm/dlmunlock.c static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm, · line 180
Quoted 8 lines
fs/ocfs2/dlm/dlmunlock.c +4
-1if (!master_node) { owner = res->owner;/* drop locks and send message */ -if (flags &LKM_CANCEL ) +if (flags &LKM_CANCEL ) { +if (dlm_lock_on_list (&res->granted, lock)) { + status =DLM_CANCELGRANT ; + goto leave;I found that above code should be useless.
As upstream code already take it into consideration that AST has come before cancellation. Indlm_get_cancel_actions()''' } else if (dlm_lock_on_list(&res->granted, lock)) { /* too late, already granted. */ status = DLM_CANCELGRANT; *actions = DLM_UNLOCK_CALL_AST; } else { '''Quoted 7 lines
Quoted 6 lines
Quoted 3 lines
If master dead and then lockres is moved to granted list in
dlm_move_lockres_to_recovery_list, theOCFS2_LOCK_BUSYis not cleared.
OCFS2_LOCK_BUSYshould be cleared inocfs2_locking_ast()since previous locking AST has come back(moving lock to grant list). That's why we returnDLM_CANCELGRANTto caller to avoid calling AST. Otherwiseast()will be called twice, which is obviously a BUG.Quoted 6 lines
I mean master is already dead and ast won't come. So the
OCFS2_LOCK_BUSYis not cleared. And there are two cases that lockres is moved to grant list:
1. AST comes back andOCFS2_LOCK_BUSYis cleared.
2. AST does not come back andOCFS2_LOCK_BUSYremains, recovery process move it to grant list. In this case, we need do AST for it.Quoted 2 lines
For point 2, ocfs2 can handle it, so you still don't have to worry. It's no problem. In
dlmconvert_remote()What I worry about is that
OCFS2_LOCK_BUSYwon't be cleared if remote master is dead, asOCFS2_LOCK_BUSYis cleared in two cases:
1. remote AST come, clear it indlm_proxy_ast_handler.
2. remote AST does not come when master dead, clear it ino2dlm_unlock_ast_wrapper.If AST doesn't manage to get back to requested node, why must flag
OCFS2_LOCK_BUSYbe cleared ino2dlm_unlock_ast_wrapper?Yes,
OCFS2_LOCK_BUSYcan be cleared it eithero2dlm_unlock_ast_wrapper()oro2dlm_lock_ast_wrapper()with o2cb stack applied.If we return
DLM_CANCELGRANTfrom ocfs2/dlm to dlm, then we must know that AST has ever come back or master node has moved the lock to grant list itself, thus we clear flagOCFS2_LOCK_BUSYino2dlm_lock_ast_wrapper(). Otherwise we ascertain that we can stop current ongoing locking procedure and must clearOCFS2_LOCK_BUSYino2dlm_unlock_ast_wrapper()(*synchronized*).Let's summarize this,
OCFS2_LOCK_BUSYshould be cleared whether by locking success or cancellation success.And my way already check if the lock is granted then return
DLM_CANCELGRANTor not.
Quoted 7 lines
Quoted 2 lines
OCFS2_LOCK_BUSYwon't be cleared ifDLM_CANCELGRANTis set ino2dlm_unlock_ast_wrapper, and that's what I'm concerned about:But we already *ascertain* that previous locking request has been *granted* before deciding to return
DLM_CANCELGRANTduring cancellation too2dlm_unlock_ast_wrapper().If above condition stands,
o2dlm_lock_ast_wrapper()must will be or have been called, which also clearsOCFS2_LOCK_BUSY.
1. Node1 already has PR lock, and wants to get ex.
2. Node1 receive BAST and do unlock, here OCFS2_LOCK_BUSY is set.
3. Node1 can not receive the AST for unlock as master dead.
4. Then o2dlm_unlock_ast_wrapper will be called rather than o2dlm_lock_ast_wrapper.
5. Actually the *granted* lock request has nothing to do with OCFS2_LOCK_BUSY.
Quoted 372 lines
Quoted 32 lines
static void
o2dlm_unlock_ast_wrapper(void *astarg, enum dlm_status status){ struct ocfs2_dlm_lksb *lksb = astarg; int error = dlm_status_to_errno(status); /* * In o2dlm, you can get both the lock_ast() for the lock being * granted and the unlock_ast() for the CANCEL failing. A * successful cancel sends DLM_NORMAL here. If the * lock grant happened before the cancel arrived, you get * DLM_CANCELGRANT. * * There's no need for the double-ast. If we see DLM_CANCELGRANT, * we just ignore it. We expect the lock_ast() to handle the * granted lock. */ if (status == DLM_CANCELGRANT) return; lksb->lksb_conn->cc_proto->lp_unlock_ast(lksb, error); }Quoted 9 lines
Quoted 8 lines
Quoted 5 lines
Please don't worry about point 2.
Like my previous e-mail, after dlm recovery picking up a new master for corresponding lock resource.dlmlock()-> convert will retry and send request to new master.
Eventually, this locking(convert) will succeed andast()will be called for ocfs2 layer to clearOCFS2_LOCK_BUSY.Perhaps you misunderstand my meaning. The AST I meant is for dlmunlock, not for dlmlock, so it won't cause retry sending request to new master.
Quoted 7 lines
Quoted 4 lines
If the unlocking AST is not back then
dlm_send_remote_unlock_request()returns NORMAL.
Because unlocking AST is synchronized with unlocking request, which means master won't sent back a separated message back(proxy ast type). That means *status* returned fromdlm_send_remote_unlock_request()indicates AST for unlocking should be called or not. How can AST for unlocking can't be invoked.Sure, unlocking AST will be invoked, but do
nothing(including clear OCFS2_LOCK_BUSY).Actually, it should do nothing since what we want will be done around the locking-grant code logic (including clearing
OCFS2_LOCK_BUSY). Please note that we must ensure the locking can granted, which will fail relevant cancellation.Thanks,
ChangweiQuoted 315 lines
Quoted 315 lines
You really make me puzzled. :- (((
Thanks,
ChangweiQuoted 308 lines
Quoted 308 lines
Thanks,
ChangweiQuoted 303 lines
For case 2, if
DLM_CANCELGRANTis set,o2dlm_unlock_ast_wrapperjust return and won't clearOCFS2_LOCK_BUSY. So in this case, I think we should do AST again for it.Quoted 13 lines
341 if (status !=
DLM_NORMAL) {
342 if (status !=DLM_NOTQUEUED)
343dlm_error(status);
344dlm_revert_pending_convert(res, lock);
345 } else if (!lock->convert_pending) {
346 mlog(0, "%s: res %.*s, owner died and lock has been moved back "
347 "to granted list, retry convert.\n",
348dlm->name,res->lockname.len,res->lockname.name);
349 status =DLM_RECOVERING;
350 }Quoted 2 lines
Thus,
dlmlock()will wait until RECOVERY is done.
And for ocfs2 layer, it's apparent, it doesn't have to be aware of what happened to DLM.I do not think the waiting can solve this problem.
Quoted 280 lines
Thanks,
ChangweiQuoted 275 lines
Perhaps we need do AST again for it.
Quoted 271 lines
Quoted 3 lines
And this will cause stuck problem when
ocfs2_drop_lock. The reason is that unlock ast won't be done whenDLM_CANCELGRANTis set. So I thinkWith above elaboration, you don't have to worry the hang issue anymore.
Thanks,
ChangweiQuoted 260 lines
we need distinguish all the cases of moving lockres to grant list.
Quoted 257 lines
fs/ocfs2/dlm/dlmunlock.c +3
-1+ } + lock->cancel_pending =1 ; - else + }else lock->unlock_pending =1 ;spin_unlock (&lock->spinlock);spin_unlock (&res->spinlock);Thanks,
ChangweiQuoted 241 lines
::cancel_pendig is set. If there is not any other better solutions, could we accept this patch? This bug is very harmful.
Thanks,
JunQuoted 233 lines · wangjian
Hi Changwei,
I understand your idea. But we should be aware that the cancel_convert process and
other processes (accepting the AST process, the recovery process) are asynchronous.
For example, according to your idea, check if the lock is in the grant queue before
calling the dlm_send_remote_unlock_request function in the dlm_proxy_ast_handler function.
Then decide whether to clear cancel_pending. But if the AST does not come at this time,
the check passes and cancel_pendig will not be cleared. Then AST immediately came over again,
which also led to a bug. I personally think that for asynchronous processes we can't guarantee
the speed of execution of each process. All we can do is to avoid the BUG scene.As for the question you said ("If you remove the BUG check why you still call dlm_commit_pending_cancel()
to move the lock back to grant on matter it's on converting list or not?").
I think we should first check if the lock is in the grant queue
(at this time, dlm->spinlock and res->spinlock have been added), then decide whether to call
dlm_commit_pending_cancel function.Thanks,
JianOn 12/7/2018 11:12 AM, Changwei Ge wrote:
Hi Jian,I suppose that the situation you described truly exists.
But the way you fix the issue is not in my favor.If you remove the BUG check why you still call dlm_commit_pending_cancel() to
move the lock back to grant on matter it's on converting list or not?So how about keeping the BUG check in dlm_move_lockres_to_recovery_list().
If the locking _ast_ comes back very fast just check ::cancel_pending in dlm_proxy_ast_handler() and clear it.
Then with the logic checking if the lock is on grant list (in dlmunlock_common() more less like your current method)
or not we can easily tell if the cancellation succeeds or not.That complies the original dlm design, which I think is better and easier for maintainers to understand.
Thanks,
ChangweiOn 2018/12/6 20:06, wangjian wrote:
Hi Changwei,I don't fully agree with your point of view. In my opinion, the lock cancellation process and the lock
conversion process are asynchronous. We can't guarantee that the lock must be in the convert list
during the lock conversion process, otherwise this BUG will not happen.
So, I think this is a meaningless BUG.Thanks,
JianOn 12/5/2018 9:49 AM, Changwei Ge wrote:
Hi Jian,I suppose you can't just remove the BUG_ON() check.
If you remove it, below code violates the original logic.'''
2141 dlm_commit_pending_cancel(res, lock);
'''What's more important is *locking cancel* must be against a *locking conversion* progress.
So it makes sense to check if this lock is on converting list.So I have to NACK to this patch.
Thanks,
ChangweiOn 2018/12/3 20:23, wangjian wrote:
In the dlm_move_lockres_to_recovery_list function, if the lock
is in the granted queue and cancel_pending is set, it will
encounter a BUG. I think this is a meaningless BUG,
so be prepared to remove it. A scenario that causes
this BUG will be given below.At the beginning, Node 1 is the master and has NL lock,
Node 2 has PR lock, Node 3 has PR lock too.Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from
Node 1. downconvert
thread begin to
cancel PR to EX conversion.
In dlmunlock_common function,
downconvert thread has set
lock->cancel_pending,
but did not enter
dlm_send_remote_unlock_request
function.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1.
change lock level to EX,
move lock to granted list.Node1 dies because
the host is powered down.In dlm_move_lockres_to_recovery_list
function. the lock is in the
granted queue and cancel_pending
is set. BUG_ON.But after clearing this BUG, process will encounter
the second BUG in the ocfs2_unlock_ast function.
Here is a scenario that will cause the second BUG
in ocfs2_unlock_ast as follows:At the beginning, Node 1 is the master and has NL lock,
Node 2 has PR lock, Node 3 has PR lock too.Node 1 Node 2 Node 3
want to get EX lock.want to get EX lock.
Node 3 hinder
Node 2 to get
EX lock, send
Node 3 a BAST.receive BAST from
Node 1. downconvert
thread begin to
cancel PR to EX conversion.
In dlmunlock_common function,
downconvert thread has released
lock->spinlock and res->spinlock,
but did not enter
dlm_send_remote_unlock_request
function.Node2 dies because
the host is powered down.In recovery process,
clean the lock that
related to Node2.
then finish Node 3
PR to EX request.
give Node 3 a AST.receive AST from Node 1.
change lock level to EX,
move lock to granted list,
set lockres->l_unlock_action
as OCFS2_UNLOCK_INVALID
in ocfs2_locking_ast function.Node2 dies because
the host is powered down.Node 3 realize that Node 1
is dead, remove Node 1 from
domain_map. downconvert thread
get DLM_NORMAL from
dlm_send_remote_unlock_request
function and set *call_ast as 1.
Then downconvert thread meet
BUG in ocfs2_unlock_ast function.To avoid meet the second BUG, function dlmunlock_common shuold
return DLM_CANCELGRANT if the lock is on granted list and
the operation is canceled.Signed-off-by: Jian Wang<[email protected]>
Reviewed-by: Yiwen Jiang<[email protected]>
---
fs/ocfs2/dlm/dlmrecovery.c | 1 -
fs/ocfs2/dlm/dlmunlock.c | 5 +++++
2 files changed, 5 insertions(+), 1 deletion(-)diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c
index 802636d..7489652 100644
--- a/fs/ocfs2/dlm/dlmrecovery.c
+++ b/fs/ocfs2/dlm/dlmrecovery.c
@@ -2134,7 +2134,6 @@ void dlm_move_lockres_to_recovery_list(struct dlm_ctxt *dlm,
* if this had completed successfully
* before sending this lock state to the
* new master */
- BUG_ON(i != DLM_CONVERTING_LIST);
mlog(0, "node died with cancel pending "
"on %.*s. move back to granted list.\n",
res->lockname.len, res->lockname.name);
diff --git a/fs/ocfs2/dlm/dlmunlock.c b/fs/ocfs2/dlm/dlmunlock.c
index 63d701c..505bb6c 100644
--- a/fs/ocfs2/dlm/dlmunlock.c
+++ b/fs/ocfs2/dlm/dlmunlock.c
@@ -183,6 +183,11 @@ static enum dlm_status dlmunlock_common(struct dlm_ctxt *dlm,
flags, owner);
spin_lock(&res->spinlock);
spin_lock(&lock->spinlock);
+
+ if ((flags & LKM_CANCEL) &&
+ dlm_lock_on_list(&res->granted, lock))
+ status = DLM_CANCELGRANT;
+
/* if the master told us the lock was already granted,
* let the ast handle all of these actions */
if (status == DLM_CANCELGRANT) {
--
1.8.3.1.
.
_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
https://oss.oracle.com/mailman/listinfo/ocfs2-devel.
.
Quoted 9 lines
Quoted 8 lines
Quoted 6 lines
Quoted 5 lines
Quoted 3 lines
Quoted 2 lines
.
.
.
.
PATCH 1/1 ocfs2/dlm: return DLM_CANCELGRANT if the lock is on granted list and the operation is canceled
Hi jun
Good afternoon.
Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
Quoted 11 lines
If AST doesn't manage to get back to requested node, why must flag
OCFS2_LOCK_BUSYbe cleared ino2dlm_unlock_ast_wrapper?Yes,
OCFS2_LOCK_BUSYcan be cleared it eithero2dlm_unlock_ast_wrapper()oro2dlm_lock_ast_wrapper()with o2cb stack applied.If we return
DLM_CANCELGRANTfrom ocfs2/dlm to dlm, then we must know that AST has ever come back or master node has moved the lock to grant list itself, thus we clear flagOCFS2_LOCK_BUSYino2dlm_lock_ast_wrapper(). Otherwise we ascertain that we can stop current ongoing locking procedure and must clearOCFS2_LOCK_BUSYino2dlm_unlock_ast_wrapper()(*synchronized*).Let's summarize this,
OCFS2_LOCK_BUSYshould be cleared whether by locking success or cancellation success.And my way already check if the lock is granted then return
DLM_CANCELGRANTor not.
OCFS2_LOCK_BUSYwon't be cleared ifDLM_CANCELGRANTis set ino2dlm_unlock_ast_wrapper, and that's what I'm concerned about:
Quoted 6 lines
Quoted 4 lines
But we already *ascertain* that previous locking request has been *granted* before deciding to return
DLM_CANCELGRANTduring cancellation too2dlm_unlock_ast_wrapper().If above condition stands,
o2dlm_lock_ast_wrapper()must will be or have been called, which also clearsOCFS2_LOCK_BUSY.1. Node1 already has PR lock, and wants to get ex.
Well, a locking up-conversion procedure.
Quoted 1 line
2. Node1 receive BAST and do unlock, here
OCFS2_LOCK_BUSYis set.
Because there are two concurrent up-conversion, which conflict, so one of them must be canceled!
Quoted 1 line
3. Node1 can not receive the AST for unlock as master dead.
So here you mean the lock can't be granted.
Quoted 1 line
4. Then
o2dlm_unlock_ast_wrapperwill be called rather thano2dlm_lock_ast_wrapper.
Then the cancellation succeeds as the master dies.
Quoted 1 line
5. Actually the *granted* lock request has nothing to do with
OCFS2_LOCK_BUSY.
Yes, o2dlm_lock_ast_wrapper will not clear OCFS2_LOCK_BUSY.
But my suggestion was not against above timing sequence. Did you misunderstand my suggestion?
And the original logic of Jian's patch also returns DLM_CANCELGRANT.
Thanks,
Changwei
PATCH 1/1 ocfs2/dlm: return DLM_CANCELGRANT if the lock is on granted list and the operation is canceled
Hi Changwei,
Quoted 33 lines · Changwei Ge
Hi jun
Good afternoon.Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
Quoted 11 lines
If AST doesn't manage to get back to requested node, why must flag
OCFS2_LOCK_BUSYbe cleared ino2dlm_unlock_ast_wrapper?Yes,
OCFS2_LOCK_BUSYcan be cleared it eithero2dlm_unlock_ast_wrapper()oro2dlm_lock_ast_wrapper()with o2cb stack applied.If we return
DLM_CANCELGRANTfrom ocfs2/dlm to dlm, then we must know that AST has ever come back or master node has moved the lock to grant list itself, thus we clear flagOCFS2_LOCK_BUSYino2dlm_lock_ast_wrapper(). Otherwise we ascertain that we can stop current ongoing locking procedure and must clearOCFS2_LOCK_BUSYino2dlm_unlock_ast_wrapper()(*synchronized*).Let's summarize this,
OCFS2_LOCK_BUSYshould be cleared whether by locking success or cancellation success.And my way already check if the lock is granted then return
DLM_CANCELGRANTor not.
OCFS2_LOCK_BUSYwon't be cleared ifDLM_CANCELGRANTis set ino2dlm_unlock_ast_wrapper, and that's what I'm concerned about:Quoted 6 lines
Quoted 4 lines
But we already *ascertain* that previous locking request has been *granted* before deciding to return
DLM_CANCELGRANTduring cancellation too2dlm_unlock_ast_wrapper().If above condition stands,
o2dlm_lock_ast_wrapper()must will be or have been called, which also clearsOCFS2_LOCK_BUSY.1. Node1 already has PR lock, and wants to get ex.
Well, a locking up-conversion procedure.
Quoted 1 line
2. Node1 receive BAST and do unlock, here
OCFS2_LOCK_BUSYis set.Because there are two concurrent up-conversion, which conflict, so one of them must be canceled!
Quoted 1 line
3. Node1 can not receive the AST for unlock as master dead.
So here you mean the lock can't be granted.
Quoted 1 line
4. Then
o2dlm_unlock_ast_wrapperwill be called rather thano2dlm_lock_ast_wrapper.
Quoted 8 lines
Then the cancellation succeeds as the master dies.
Quoted 1 line
5. Actually the *granted* lock request has nothing to do with
OCFS2_LOCK_BUSY.Yes,
o2dlm_lock_ast_wrapperwill not clearOCFS2_LOCK_BUSY.But my suggestion was not against above timing sequence. Did you misunderstand my suggestion?
And the original logic of Jian's patch also returnsDLM_CANCELGRANT.
Yes, Jian's last patch can't solve the problem either, and I think we should find another solution for it. I'm considering deleting the check for DLM_CANCELGRANT, and clear OCFS2_LOCK_BUSY in the following process.
Thanks,
Jun
Quoted 9 lines
Thanks,
Changwei.
PATCH 1/1 ocfs2/dlm: return DLM_CANCELGRANT if the lock is on granted list and the operation is canceled
Hi Jun,
Quoted 41 lines · piaojun
Hi Changwei,
Quoted 38 lines · Changwei Ge
Hi jun
Good afternoon.Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
Quoted 11 lines
If AST doesn't manage to get back to requested node, why must flag
OCFS2_LOCK_BUSYbe cleared ino2dlm_unlock_ast_wrapper?Yes,
OCFS2_LOCK_BUSYcan be cleared it eithero2dlm_unlock_ast_wrapper()oro2dlm_lock_ast_wrapper()with o2cb stack applied.If we return
DLM_CANCELGRANTfrom ocfs2/dlm to dlm, then we must know that AST has ever come back or master node has moved the lock to grant list itself, thus we clear flagOCFS2_LOCK_BUSYino2dlm_lock_ast_wrapper(). Otherwise we ascertain that we can stop current ongoing locking procedure and must clearOCFS2_LOCK_BUSYino2dlm_unlock_ast_wrapper()(*synchronized*).Let's summarize this,
OCFS2_LOCK_BUSYshould be cleared whether by locking success or cancellation success.And my way already check if the lock is granted then return
DLM_CANCELGRANTor not.
OCFS2_LOCK_BUSYwon't be cleared ifDLM_CANCELGRANTis set ino2dlm_unlock_ast_wrapper, and that's what I'm concerned about:Quoted 6 lines
Quoted 4 lines
But we already *ascertain* that previous locking request has been *granted* before deciding to return
DLM_CANCELGRANTduring cancellation too2dlm_unlock_ast_wrapper().If above condition stands,
o2dlm_lock_ast_wrapper()must will be or have been called, which also clearsOCFS2_LOCK_BUSY.1. Node1 already has PR lock, and wants to get ex.
Well, a locking up-conversion procedure.
Quoted 1 line
2. Node1 receive BAST and do unlock, here
OCFS2_LOCK_BUSYis set.Because there are two concurrent up-conversion, which conflict, so one of them must be canceled!
Quoted 1 line
3. Node1 can not receive the AST for unlock as master dead.
So here you mean the lock can't be granted.
Quoted 1 line
4. Then
o2dlm_unlock_ast_wrapperwill be called rather thano2dlm_lock_ast_wrapper.Then the cancellation succeeds as the master dies.
Quoted 1 line
5. Actually the *granted* lock request has nothing to do with
OCFS2_LOCK_BUSY.Yes,
o2dlm_lock_ast_wrapperwill not clearOCFS2_LOCK_BUSY.
Quoted 7 lines
Quoted 3 lines
But my suggestion was not against above timing sequence. Did you misunderstand my suggestion?
And the original logic of Jian's patch also returnsDLM_CANCELGRANT.Yes, Jian's last patch can't solve the problem either, and I think we should find another solution for it. I'm considering deleting the check for
DLM_CANCELGRANT, and clearOCFS2_LOCK_BUSYin the following process.
If Jian's patch can't fix the issue either, I am going to ask Andrew to drop this patch. Hopefully, Jian or you can help post another patch for it. Then we can have another round of discussion.
Thanks,
Changwei
Quoted 14 lines
Thanks,
JunQuoted 9 lines
Thanks,
Changwei.
PATCH 1/1 ocfs2/dlm: return DLM_CANCELGRANT if the lock is on granted list and the operation is canceled
Hi Changwei,
Quoted 48 lines · Changwei Ge
Hi Jun,
Quoted 45 lines · piaojun
Hi Changwei,
Quoted 41 lines · Changwei Ge
Hi jun
Good afternoon.Quoted 15 lines
Quoted 15 lines
Quoted 14 lines
Quoted 11 lines
If AST doesn't manage to get back to requested node, why must flag
OCFS2_LOCK_BUSYbe cleared ino2dlm_unlock_ast_wrapper?Yes,
OCFS2_LOCK_BUSYcan be cleared it eithero2dlm_unlock_ast_wrapper()oro2dlm_lock_ast_wrapper()with o2cb stack applied.If we return
DLM_CANCELGRANTfrom ocfs2/dlm to dlm, then we must know that AST has ever come back or master node has moved the lock to grant list itself, thus we clear flagOCFS2_LOCK_BUSYino2dlm_lock_ast_wrapper(). Otherwise we ascertain that we can stop current ongoing locking procedure and must clearOCFS2_LOCK_BUSYino2dlm_unlock_ast_wrapper()(*synchronized*).Let's summarize this,
OCFS2_LOCK_BUSYshould be cleared whether by locking success or cancellation success.And my way already check if the lock is granted then return
DLM_CANCELGRANTor not.
OCFS2_LOCK_BUSYwon't be cleared ifDLM_CANCELGRANTis set ino2dlm_unlock_ast_wrapper, and that's what I'm concerned about:Quoted 6 lines
Quoted 4 lines
But we already *ascertain* that previous locking request has been *granted* before deciding to return
DLM_CANCELGRANTduring cancellation too2dlm_unlock_ast_wrapper().If above condition stands,
o2dlm_lock_ast_wrapper()must will be or have been called, which also clearsOCFS2_LOCK_BUSY.1. Node1 already has PR lock, and wants to get ex.
Well, a locking up-conversion procedure.
Quoted 1 line
2. Node1 receive BAST and do unlock, here
OCFS2_LOCK_BUSYis set.Because there are two concurrent up-conversion, which conflict, so one of them must be canceled!
Quoted 1 line
3. Node1 can not receive the AST for unlock as master dead.
So here you mean the lock can't be granted.
Quoted 1 line
4. Then
o2dlm_unlock_ast_wrapperwill be called rather thano2dlm_lock_ast_wrapper.Then the cancellation succeeds as the master dies.
Quoted 1 line
5. Actually the *granted* lock request has nothing to do with
OCFS2_LOCK_BUSY.Yes,
o2dlm_lock_ast_wrapperwill not clearOCFS2_LOCK_BUSY.But my suggestion was not against above timing sequence. Did you misunderstand my suggestion?
And the original logic of Jian's patch also returnsDLM_CANCELGRANT.
Quoted 6 lines
Quoted 3 lines
Yes, Jian's last patch can't solve the problem either, and I think we should find another solution for it. I'm considering deleting the check for
DLM_CANCELGRANT, and clearOCFS2_LOCK_BUSYin the following process.If Jian's patch can't fix the issue either, I am going to ask Andrew to drop this patch. Hopefully, Jian or you can help post another patch for it. Then we can have another round of discussion.
Agreed!
Quoted 20 lines
Thanks,
ChangweiQuoted 14 lines
Thanks,
JunQuoted 9 lines
Thanks,
Changwei.
.