[sheepdog] [PATCH 1/2] sheep/recovery: get recovering local object right

Liu Yuan namei.unix at gmail.com
Mon Mar 2 09:02:37 CET 2015


From: Liu Yuan <liuyuan at cmss.chinamobile.com>

One of the acceleration for recovery is we try to recover the object from local
node as much as possible. It is straightforward implemented:

1 firstly get the hash of the object to be recoveried from stale directry if any
2 then compare the fingerprint to the remote node
3 if identical, then we can safely recover it from local stale directory.

But this logic is never executed in the following case:

0 sheep try to recover object A at from epoch 5, we note it as A.5
1 but sheep find we have a local copy A.2 due to a multiple node events
2 then sheep get the fingerprint of A.2 and then compare to remote node.
3 the figerprints are identical, so this sheep tries to recover it from A.2
4 if, unfortunately, A.5 is as well calcuated onto this node, even though this
  sheep dosen't have it, our code will first try to link A.5
5 unfortunately, A.5 is never out there and before we really try to link A.2,
  sheep fail out because ->link(A.5) return error.

The fix is easy, just try to ->link(A.2) before ->link(A.5).

Signed-off-by: Liu Yuan <liuyuan at cmss.chinamobile.com>
---
 sheep/recovery.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/sheep/recovery.c b/sheep/recovery.c
index 8d94d4f..36ef8a0 100644
--- a/sheep/recovery.c
+++ b/sheep/recovery.c
@@ -265,13 +265,6 @@ static int recover_object_from(struct recovery_obj_work *row,
 	struct sd_rsp *rsp = (struct sd_rsp *)&hdr;
 	struct siocb iocb = { 0 };
 
-	if (node_is_local(node)) {
-		if (tgt_epoch < sys_epoch())
-			return sd_store->link(oid, tgt_epoch);
-
-		return SD_RES_NO_OBJ;
-	}
-
 	/* compare sha1 hash value first */
 	if (local_epoch > 0) {
 		sd_init_req(&hdr, SD_OP_GET_HASH);
@@ -290,6 +283,13 @@ static int recover_object_from(struct recovery_obj_work *row,
 		}
 	}
 
+	if (node_is_local(node)) {
+		if (tgt_epoch < sys_epoch())
+			return sd_store->link(oid, tgt_epoch);
+
+		return SD_RES_NO_OBJ;
+	}
+
 	rlen = get_store_objsize(oid);
 	buf = xvalloc(rlen);
 
-- 
1.9.1




More information about the sheepdog mailing list