[sheepdog] [PATCH stable-0.6] recovery: check node before try to connect to

Hitoshi Mitake mitake.hitoshi at gmail.com
Sat Aug 31 09:50:00 CEST 2013


From: Liu Yuan <namei.unix at gmail.com>

This check exist in the old code but was accidentally refactored out by some
ghost commit.

Check node validity before connecting will save a lot of unnecessary network
traffic during recovery. Let's summon it back.

Signed-off-by: Liu Yuan <namei.unix at gmail.com>
Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 sheep/recovery.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/sheep/recovery.c b/sheep/recovery.c
index 6a0efac..1172584 100644
--- a/sheep/recovery.c
+++ b/sheep/recovery.c
@@ -173,6 +173,18 @@ static int recover_object_from(struct recovery_obj_work *row,
 	return ret;
 }
 
+/*
+ * A virtual node that does not match any node in current node list
+ * means the node has left the cluster, then it's an invalid virtual node.
+ */
+static bool invalid_vnode(const struct sd_vnode *v, struct vnode_info *info)
+{
+
+	if (xbsearch(v, info->nodes, info->nr_nodes, node_id_cmp))
+		return false;
+	return true;
+}
+
 static int recover_object_from_replica(struct recovery_obj_work *row,
 				       struct vnode_info *old,
 				       uint32_t tgt_epoch)
@@ -203,6 +215,9 @@ static int recover_object_from_replica(struct recovery_obj_work *row,
 
 		vnode = oid_to_vnode(old->vnodes, old->nr_vnodes, oid, idx);
 
+		if (invalid_vnode(vnode, row->base.cur_vinfo))
+			continue;
+
 		ret = recover_object_from(row, vnode, tgt_epoch);
 		switch (ret) {
 		case SD_RES_SUCCESS:
-- 
1.8.1.2




More information about the sheepdog mailing list