[sheepdog] [PATCH] recovery: check node before try to connect to
Liu Yuan
namei.unix at gmail.com
Mon Jul 22 07:31:28 CEST 2013
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>
---
sheep/recovery.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/sheep/recovery.c b/sheep/recovery.c
index df785ee..dd4c403 100644
--- a/sheep/recovery.c
+++ b/sheep/recovery.c
@@ -168,6 +168,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)
@@ -198,6 +210,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.7.9.5
More information about the sheepdog
mailing list