[sheepdog] [PATCH 6/9] recovery: don't assume old_epoch is sys->eopch - 1

Liu Yuan namei.unix at gmail.com
Sun May 26 15:40:43 CEST 2013


When md or reweight recovery happens, old_epoch == sys->epoch

Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
 sheep/group.c       |    4 ++--
 sheep/md.c          |    2 +-
 sheep/ops.c         |    2 +-
 sheep/plain_store.c |    8 ++------
 sheep/recovery.c    |   10 +++++-----
 sheep/sheep_priv.h  |    2 +-
 6 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/sheep/group.c b/sheep/group.c
index b6a8d1b..16d54cd 100644
--- a/sheep/group.c
+++ b/sheep/group.c
@@ -919,7 +919,7 @@ static void update_cluster_info(const struct join_message *msg,
 			}
 
 			start_recovery(main_thread_get(current_vnode_info),
-				       old_vnode_info);
+				       old_vnode_info, true);
 		}
 
 		if (have_enough_zones())
@@ -1222,7 +1222,7 @@ void sd_leave_handler(const struct sd_node *left, const struct sd_node *members,
 		uatomic_inc(&sys->epoch);
 		log_current_epoch();
 		start_recovery(main_thread_get(current_vnode_info),
-			       old_vnode_info);
+			       old_vnode_info, true);
 		if (!have_enough_zones())
 			sys->status = SD_STATUS_HALT;
 		break;
diff --git a/sheep/md.c b/sheep/md.c
index 64463d9..b6579ce 100644
--- a/sheep/md.c
+++ b/sheep/md.c
@@ -417,7 +417,7 @@ static inline void kick_recover(void)
 {
 	struct vnode_info *vinfo = get_vnode_info();
 
-	start_recovery(vinfo, vinfo);
+	start_recovery(vinfo, vinfo, false);
 	put_vnode_info(vinfo);
 }
 
diff --git a/sheep/ops.c b/sheep/ops.c
index 8f798f3..07a20d9 100644
--- a/sheep/ops.c
+++ b/sheep/ops.c
@@ -575,7 +575,7 @@ static int cluster_force_recover_main(const struct sd_req *req,
 
 	vnode_info = get_vnode_info();
 	old_vnode_info = alloc_vnode_info(nodes, nr_nodes);
-	start_recovery(vnode_info, old_vnode_info);
+	start_recovery(vnode_info, old_vnode_info, true);
 	put_vnode_info(vnode_info);
 	put_vnode_info(old_vnode_info);
 	return ret;
diff --git a/sheep/plain_store.c b/sheep/plain_store.c
index 781b777..086e18e 100644
--- a/sheep/plain_store.c
+++ b/sheep/plain_store.c
@@ -442,12 +442,8 @@ static int check_stale_objects(uint64_t oid, char *wd, void *arg)
 
 int default_update_epoch(uint32_t epoch)
 {
-	uint32_t old_epoch = epoch - 1;
-
-	if (old_epoch == 0)
-		return SD_RES_SUCCESS;
-
-	return for_each_object_in_wd(check_stale_objects, false, &old_epoch);
+	assert(epoch);
+	return for_each_object_in_wd(check_stale_objects, false, &epoch);
 }
 
 int default_format(void)
diff --git a/sheep/recovery.c b/sheep/recovery.c
index d331012..ab99244 100644
--- a/sheep/recovery.c
+++ b/sheep/recovery.c
@@ -438,8 +438,7 @@ static inline bool run_next_rw(void)
 
 	free_recovery_info(main_thread_get(current_rinfo));
 
-	if (sd_store->update_epoch)
-		sd_store->update_epoch(nrinfo->epoch);
+	sd_store->update_epoch(nrinfo->epoch);
 
 	main_thread_set(current_rinfo, nrinfo);
 	wakeup_all_requests();
@@ -777,9 +776,11 @@ static inline bool node_is_gateway_only(void)
 	return sys->this_node.nr_vnodes == 0;
 }
 
-int start_recovery(struct vnode_info *cur_vinfo, struct vnode_info *old_vinfo)
+int start_recovery(struct vnode_info *cur_vinfo, struct vnode_info *old_vinfo,
+		   bool epoch_lifted)
 {
 	struct recovery_info *rinfo;
+	uint32_t old_epoch = epoch_lifted ? sys->epoch - 1 : sys->epoch;
 
 	if (node_is_gateway_only())
 		goto out;
@@ -792,8 +793,7 @@ int start_recovery(struct vnode_info *cur_vinfo, struct vnode_info *old_vinfo)
 	rinfo->cur_vinfo = grab_vnode_info(cur_vinfo);
 	rinfo->old_vinfo = grab_vnode_info(old_vinfo);
 
-	if (sd_store->update_epoch)
-		sd_store->update_epoch(rinfo->epoch);
+	sd_store->update_epoch(old_epoch);
 
 	if (main_thread_get(current_rinfo) != NULL) {
 		/* skip the previous epoch recovery */
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index febc9b9..27b1b41 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -297,7 +297,7 @@ uint64_t get_cluster_ctime(void);
 int get_obj_list(const struct sd_req *, struct sd_rsp *, void *);
 int objlist_cache_cleanup(uint32_t vid);
 
-int start_recovery(struct vnode_info *cur_vinfo, struct vnode_info *old_vinfo);
+int start_recovery(struct vnode_info *cur_vinfo, struct vnode_info *, bool);
 bool oid_in_recovery(uint64_t oid);
 bool node_in_recovery(void);
 
-- 
1.7.9.5




More information about the sheepdog mailing list