[sheepdog] [PATCH 2/2] corosync: detect network partition based on left_list_entries
Hitoshi Mitake
mitake.hitoshi at lab.ntt.co.jp
Tue Sep 30 10:01:26 CEST 2014
Corosync passes a number of leaving node with the parameter
left_list_entries of confchg callback. It can be used for detecting
network partition.
Cc: Masahiro Tsuji <tuji at atworks.co.jp>
Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
sheep/cluster/corosync.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/sheep/cluster/corosync.c b/sheep/cluster/corosync.c
index 477e442..f876112 100644
--- a/sheep/cluster/corosync.c
+++ b/sheep/cluster/corosync.c
@@ -17,6 +17,7 @@
#include "cluster.h"
#include "event.h"
#include "work.h"
+#include "sheep_priv.h"
#define CPG_INIT_RETRY_CNT 10
#define COROSYNC_MAX_NODES 1024
@@ -530,6 +531,7 @@ static void cdrv_cpg_confchg(cpg_handle_t handle,
struct cpg_node joined_sheep[COROSYNC_MAX_NODES];
struct cpg_node left_sheep[COROSYNC_MAX_NODES];
bool promote = true;
+ struct vnode_info *vinfo;
sd_debug("mem:%zu, joined:%zu, left:%zu", member_list_entries,
joined_list_entries, left_list_entries);
@@ -539,6 +541,17 @@ static void cdrv_cpg_confchg(cpg_handle_t handle,
build_cpg_node_list(left_sheep, left_list, left_list_entries);
build_cpg_node_list(joined_sheep, joined_list, joined_list_entries);
+ vinfo = get_vnode_info();
+ if (vinfo) {
+ /* !vinfo is true during joining */
+ if (vinfo->nr_nodes / 2 + 1 <= left_list_entries)
+ panic("a number of leaving node (%zu) is larger than"
+ " majority (%d), network partition",
+ left_list_entries, vinfo->nr_nodes / 2 + 1);
+ else
+ put_vnode_info(vinfo);
+ }
+
/* dispatch leave_handler */
for (i = 0; i < left_list_entries; i++) {
cevent = find_event(COROSYNC_EVENT_TYPE_JOIN, left_sheep + i);
--
1.8.3.2
More information about the sheepdog
mailing list