Patchwork [v2,6/7] sheep: remove duplicate recovery complete notification

login
register
mail settings
Submitter namei.unix@gmail.com
Date March 29, 2013, 5:42 a.m.
Message ID <1364535744-8707-7-git-send-email-namei.unix@gmail.com>
Download mbox | patch
Permalink /patch/232293/
State New
Headers show

Comments

namei.unix@gmail.com - March 29, 2013, 5:42 a.m.
From: Liu Yuan <tailai.ly@taobao.com>

Signed-off-by: Liu Yuan <tailai.ly@taobao.com>
---
 sheep/ops.c |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

Patch

diff --git a/sheep/ops.c b/sheep/ops.c
index 3839437..204befd 100644
--- a/sheep/ops.c
+++ b/sheep/ops.c
@@ -624,7 +624,19 @@  static int cluster_recovery_completion(const struct sd_req *req,
 		nr_recovereds = 0;
 	}
 
-	recovereds[nr_recovereds++] = *(struct sd_node *)node;
+	/*
+	 * Disk failure might send duplicate notication, ingore it.
+	 *
+	 * We can't simply stop disk recovery from sending notication because
+	 * disk recovery might supersed node recovery, which indeed need
+	 * to send notication
+	 */
+	for (i = 0; i < nr_recovereds; i++)
+		if (!node_id_cmp(&node->nid, &recovereds[i].nid)) {
+			sd_dprintf("duplicate %s", node_to_str(node));
+			return SD_RES_SUCCESS;
+		}
+	recovereds[nr_recovereds++] = *node;
 	qsort(recovereds, nr_recovereds, sizeof(*recovereds), node_id_cmp);
 
 	sd_dprintf("%s is recovered at epoch %d", node_to_str(node), epoch);