[sheepdog] [PATCH] recovery: reorder recover_object_from_replica()

Liu Yuan namei.unix at gmail.com
Mon Sep 17 04:42:24 CEST 2012


From: Liu Yuan <tailai.ly at taobao.com>

Move valloc() after store->link() operation will save us one glibc call for
recovering local objects.

Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
 sheep/recovery.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/sheep/recovery.c b/sheep/recovery.c
index 23a2f7e..c263d5d 100644
--- a/sheep/recovery.c
+++ b/sheep/recovery.c
@@ -70,12 +70,6 @@ static int recover_object_from_replica(uint64_t oid, struct sd_vnode *vnode,
 	struct siocb iocb = { 0 };
 
 	rlen = get_objsize(oid);
-	buf = valloc(rlen);
-	if (!buf) {
-		eprintf("%m\n");
-		goto out;
-	}
-
 	if (vnode_is_local(vnode)) {
 		iocb.epoch = epoch;
 		iocb.length = rlen;
@@ -83,6 +77,12 @@ static int recover_object_from_replica(uint64_t oid, struct sd_vnode *vnode,
 		goto out;
 	}
 
+	buf = valloc(rlen);
+	if (!buf) {
+		eprintf("%m\n");
+		goto out;
+	}
+
 	sd_init_req(&hdr, SD_OP_READ_PEER);
 	hdr.epoch = epoch;
 	hdr.flags = SD_FLAG_CMD_RECOVERY;
-- 
1.7.10.2




More information about the sheepdog mailing list