[sheepdog] [PATCH v2 08/21] recovery: mark last gathered epoch

Liu Yuan namei.unix at gmail.com
Wed Oct 16 07:50:34 CEST 2013


The last gathered epoch is the epoch at which all the nodes complete the
recovery and purge the stale objects. So this means we don't need to go
the epoch history below last_gathered_epoch.

This is a preparation patch.

Signed-off-by: Liu Yuan <namei.unix at gmail.com>
---
 sheep/ops.c        |    7 +++++++
 sheep/sheep_priv.h |    2 ++
 2 files changed, 9 insertions(+)

diff --git a/sheep/ops.c b/sheep/ops.c
index d46d10e..72ccefb 100644
--- a/sheep/ops.c
+++ b/sheep/ops.c
@@ -46,6 +46,12 @@ struct sd_op_template {
 	int (*process_main)(const struct sd_req *req, struct sd_rsp *rsp, void *data);
 };
 
+/*
+ * The last gathered epoch is the epoch at which all the nodes complete the
+ * recovery and purge the stale objects.
+ */
+uint32_t last_gathered_epoch = 1;
+
 static int stat_sheep(uint64_t *store_size, uint64_t *store_free,
 		      uint32_t epoch)
 {
@@ -668,6 +674,7 @@ static int cluster_recovery_completion(const struct sd_req *req,
 		}
 		if (i == nr_recovereds) {
 			sd_debug("all nodes are recovered, epoch %d", epoch);
+			last_gathered_epoch = epoch;
 			/* sd_store can be NULL if this node is a gateway */
 			if (sd_store && sd_store->cleanup)
 				sd_store->cleanup();
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index 99bf676..bcb260e 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -391,6 +391,8 @@ int do_process_main(const struct sd_op_template *op, const struct sd_req *req,
 int sheep_do_op_work(const struct sd_op_template *op, struct request *req);
 int gateway_to_peer_opcode(int opcode);
 
+extern uint32_t last_gathered_epoch;
+
 static inline bool vnode_is_local(const struct sd_vnode *v)
 {
 	return node_id_cmp(&v->node->nid, &sys->this_node.nid) == 0;
-- 
1.7.9.5




More information about the sheepdog mailing list