[sheepdog] [PATCH v2 03/10] sheep: recover from local if possible
MORITA Kazutaka
morita.kazutaka at gmail.com
Thu May 9 04:38:52 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 | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git a/sheep/recovery.c b/sheep/recovery.c
index bf54b63..46c167c 100644
--- a/sheep/recovery.c
+++ b/sheep/recovery.c
@@ -91,6 +91,23 @@ static int recover_object_from_replica(uint64_t oid, struct vnode_info *old,
void *buf = NULL;
struct siocb iocb = { 0 };
+ nr_copies = get_obj_copy_number(oid, old->nr_zones);
+
+ /* find local node first to try to recover from local */
+ for (int i = 0; i < nr_copies; i++) {
+ const struct sd_vnode *vnode;
+
+ vnode = oid_to_vnode(old->vnodes, old->nr_vnodes, oid, i);
+
+ if (vnode_is_local(vnode)) {
+ if (tgt_epoch < sys_epoch())
+ ret = sd_store->link(oid, tgt_epoch);
+ else
+ ret = SD_RES_NO_OBJ;
+ goto out;
+ }
+ }
+
rlen = get_objsize(oid);
buf = valloc(rlen);
if (!buf) {
@@ -100,7 +117,6 @@ static int recover_object_from_replica(uint64_t oid, struct vnode_info *old,
}
/* Let's do a breadth-first search */
- nr_copies = get_obj_copy_number(oid, old->nr_zones);
for (int i = 0; i < nr_copies; i++) {
const struct sd_vnode *vnode;
@@ -109,13 +125,8 @@ static int recover_object_from_replica(uint64_t oid, struct vnode_info *old,
if (is_invalid_vnode(vnode, cur->nodes, cur->nr_nodes))
continue;
- if (vnode_is_local(vnode)) {
- if (tgt_epoch < sys_epoch())
- ret = sd_store->link(oid, tgt_epoch);
- else
- ret = SD_RES_NO_OBJ;
- goto out;
- }
+ if (vnode_is_local(vnode))
+ continue;
sd_init_req(&hdr, SD_OP_READ_PEER);
hdr.epoch = epoch;
--
1.7.9.5
More information about the sheepdog
mailing list