aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuoqing Jiang <gqjiang@suse.com>2015-07-10 05:01:15 -0400
committerNeilBrown <neilb@suse.com>2015-08-31 13:41:41 -0400
commit66099bb0ee6c20f91ace3fa5f82202fbceb67d8e (patch)
tree9b5be424509589322b12a9a6d1571e0b32111731
parentdc737d7c3d62d2cd2b62c7739aaa7604330c3dd8 (diff)
md-cluster: fix deadlock issue on message lock
There is problem with previous communication mechanism, and we got below deadlock scenario with cluster which has 3 nodes. Sender Receiver Receiver token(EX) message(EX) writes message downconverts message(CR) requests ack(EX) get message(CR) gets message(CR) reads message reads message requests EX on message requests EX on message To fix this problem, we do the following changes: 1. the sender downconverts MESSAGE to CW rather than CR. 2. and the receiver request PR lock not EX lock on message. And in case we failed to down-convert EX to CW on message, it is better to unlock message otherthan still hold the lock. Reviewed-by: Goldwyn Rodrigues <rgoldwyn@suse.com> Signed-off-by: Lidong Zhong <ldzhong@suse.com> Signed-off-by: Guoqing Jiang <gqjiang@suse.com> Signed-off-by: NeilBrown <neilb@suse.com>
-rw-r--r--Documentation/md-cluster.txt4
-rw-r--r--drivers/md/md-cluster.c14
2 files changed, 9 insertions, 9 deletions
diff --git a/Documentation/md-cluster.txt b/Documentation/md-cluster.txt
index de1af7db3355..1b794369e03a 100644
--- a/Documentation/md-cluster.txt
+++ b/Documentation/md-cluster.txt
@@ -91,7 +91,7 @@ The algorithm is:
91 this message inappropriate or redundant. 91 this message inappropriate or redundant.
92 92
93 3. sender write LVB. 93 3. sender write LVB.
94 sender down-convert MESSAGE from EX to CR 94 sender down-convert MESSAGE from EX to CW
95 sender try to get EX of ACK 95 sender try to get EX of ACK
96 [ wait until all receiver has *processed* the MESSAGE ] 96 [ wait until all receiver has *processed* the MESSAGE ]
97 97
@@ -112,7 +112,7 @@ The algorithm is:
112 sender down-convert ACK from EX to CR 112 sender down-convert ACK from EX to CR
113 sender release MESSAGE 113 sender release MESSAGE
114 sender release TOKEN 114 sender release TOKEN
115 receiver upconvert to EX of MESSAGE 115 receiver upconvert to PR of MESSAGE
116 receiver get CR of ACK 116 receiver get CR of ACK
117 receiver release MESSAGE 117 receiver release MESSAGE
118 118
diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c
index 47199addae04..85b7836fb4b5 100644
--- a/drivers/md/md-cluster.c
+++ b/drivers/md/md-cluster.c
@@ -488,8 +488,8 @@ static void recv_daemon(struct md_thread *thread)
488 488
489 /*release CR on ack_lockres*/ 489 /*release CR on ack_lockres*/
490 dlm_unlock_sync(ack_lockres); 490 dlm_unlock_sync(ack_lockres);
491 /*up-convert to EX on message_lockres*/ 491 /*up-convert to PR on message_lockres*/
492 dlm_lock_sync(message_lockres, DLM_LOCK_EX); 492 dlm_lock_sync(message_lockres, DLM_LOCK_PR);
493 /*get CR on ack_lockres again*/ 493 /*get CR on ack_lockres again*/
494 dlm_lock_sync(ack_lockres, DLM_LOCK_CR); 494 dlm_lock_sync(ack_lockres, DLM_LOCK_CR);
495 /*release CR on message_lockres*/ 495 /*release CR on message_lockres*/
@@ -522,7 +522,7 @@ static void unlock_comm(struct md_cluster_info *cinfo)
522 * The function: 522 * The function:
523 * 1. Grabs the message lockresource in EX mode 523 * 1. Grabs the message lockresource in EX mode
524 * 2. Copies the message to the message LVB 524 * 2. Copies the message to the message LVB
525 * 3. Downconverts message lockresource to CR 525 * 3. Downconverts message lockresource to CW
526 * 4. Upconverts ack lock resource from CR to EX. This forces the BAST on other nodes 526 * 4. Upconverts ack lock resource from CR to EX. This forces the BAST on other nodes
527 * and the other nodes read the message. The thread will wait here until all other 527 * and the other nodes read the message. The thread will wait here until all other
528 * nodes have released ack lock resource. 528 * nodes have released ack lock resource.
@@ -543,12 +543,12 @@ static int __sendmsg(struct md_cluster_info *cinfo, struct cluster_msg *cmsg)
543 543
544 memcpy(cinfo->message_lockres->lksb.sb_lvbptr, (void *)cmsg, 544 memcpy(cinfo->message_lockres->lksb.sb_lvbptr, (void *)cmsg,
545 sizeof(struct cluster_msg)); 545 sizeof(struct cluster_msg));
546 /*down-convert EX to CR on Message*/ 546 /*down-convert EX to CW on Message*/
547 error = dlm_lock_sync(cinfo->message_lockres, DLM_LOCK_CR); 547 error = dlm_lock_sync(cinfo->message_lockres, DLM_LOCK_CW);
548 if (error) { 548 if (error) {
549 pr_err("md-cluster: failed to convert EX to CR on MESSAGE(%d)\n", 549 pr_err("md-cluster: failed to convert EX to CW on MESSAGE(%d)\n",
550 error); 550 error);
551 goto failed_message; 551 goto failed_ack;
552 } 552 }
553 553
554 /*up-convert CR to EX on Ack*/ 554 /*up-convert CR to EX on Ack*/