[sheepdog] [PATCH v3 3/8] recovery: start tgt_epoch with rw->epoch instead of 'rw->epoch - 1'

Liu Yuan namei.unix at gmail.com
Wed Mar 27 10:11:31 CET 2013


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

MD recovery will start recovery without epoch lifted. This will cause troulbe
when sys_epoch = 1, which will result in tgt_target = 0, and wrap around later
to be a very large but valid epoch to the recovery code and cause trouble.

This is a prepare patch for MD recovery.

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

diff --git a/sheep/recovery.c b/sheep/recovery.c
index 7388564..1877b74 100644
--- a/sheep/recovery.c
+++ b/sheep/recovery.c
@@ -77,7 +77,7 @@ static int recover_object_from_replica(uint64_t oid,
 	void *buf = NULL;
 	struct siocb iocb = { 0 };
 
-	if (vnode_is_local(vnode)) {
+	if (vnode_is_local(vnode) && tgt_epoch < sys_epoch()) {
 		ret = sd_store->link(oid, tgt_epoch);
 		goto out;
 	}
@@ -136,7 +136,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 - 1;
+	uint32_t epoch = rw->epoch, tgt_epoch = rw->epoch;
 	int nr_copies, ret, i;
 
 	old = grab_vnode_info(rw->old_vinfo);
-- 
1.7.9.5




More information about the sheepdog mailing list