[sheepdog] [PATCH 2/9] sheep: recover from local if possible

MORITA Kazutaka morita.kazutaka at gmail.com
Mon May 6 19:45:49 CEST 2013


From: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>

Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 sheep/recovery.c |   17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/sheep/recovery.c b/sheep/recovery.c
index dc38dac..688058a 100644
--- a/sheep/recovery.c
+++ b/sheep/recovery.c
@@ -141,7 +141,7 @@ static int do_recover_object(struct recovery_work *rw)
 	struct vnode_info *old;
 	uint64_t oid = rw->oids[rw->done];
 	uint32_t epoch = rw->epoch, tgt_epoch = rw->epoch;
-	int nr_copies, ret, i;
+	int nr_copies, ret, i, start = 0;
 
 	old = grab_vnode_info(rw->old_vinfo);
 
@@ -149,13 +149,26 @@ again:
 	sd_dprintf("try recover object %"PRIx64" from epoch %"PRIu32, oid,
 		   tgt_epoch);
 
-	/* Let's do a breadth-first search */
 	nr_copies = get_obj_copy_number(oid, old->nr_zones);
+	/* find local node first to try to recover from local */
 	for (i = 0; i < nr_copies; i++) {
 		const struct sd_vnode *tgt_vnode;
 
 		tgt_vnode = oid_to_vnode(old->vnodes, old->nr_vnodes, oid, i);
 
+		if (vnode_is_local(tgt_vnode)) {
+			start = i;
+			break;
+		}
+	}
+
+	/* Let's do a breadth-first search */
+	for (i = 0; i < nr_copies; i++) {
+		const struct sd_vnode *tgt_vnode;
+		int idx = (i + start) % nr_copies;
+
+		tgt_vnode = oid_to_vnode(old->vnodes, old->nr_vnodes, oid, idx);
+
 		if (is_invalid_vnode(tgt_vnode, rw->cur_vinfo->nodes,
 				     rw->cur_vinfo->nr_nodes))
 			continue;
-- 
1.7.9.5




More information about the sheepdog mailing list