[sheepdog] [PATCH 1/2] sheep: fix recover complete notification

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Thu Oct 18 14:01:26 CEST 2012


hdr->epoch cannot be used to notify a recovered epoch because the
field is updated in queue_request.  This patch uses hdr->obj.tgt_epoch
instead.

Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 sheep/ops.c      |   14 +++++++++-----
 sheep/recovery.c |    2 +-
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/sheep/ops.c b/sheep/ops.c
index 902de88..5e6df0e 100644
--- a/sheep/ops.c
+++ b/sheep/ops.c
@@ -577,19 +577,23 @@ static int cluster_recovery_completion(const struct sd_req *req,
 	static int latest_epoch;
 	struct vnode_info *vnode_info;
 	int i;
+	uint32_t epoch = req->obj.tgt_epoch;
 
 	node = (struct sd_node *)data;
 
-	if (latest_epoch < req->epoch) {
-		dprintf("new epoch %d\n", req->epoch);
-		latest_epoch = req->epoch;
+	if (latest_epoch > epoch)
+		return SD_RES_SUCCESS;
+
+	if (latest_epoch < epoch) {
+		dprintf("new epoch %d\n", epoch);
+		latest_epoch = epoch;
 		nr_recovereds = 0;
 	}
 
 	recovereds[nr_recovereds++] = *(struct sd_node *)node;
 	qsort(recovereds, nr_recovereds, sizeof(*recovereds), node_id_cmp);
 
-	dprintf("%s is recovered at epoch %d\n", node_to_str(node), req->epoch);
+	dprintf("%s is recovered at epoch %d\n", node_to_str(node), epoch);
 	for (i = 0; i < nr_recovereds; i++)
 		dprintf("[%x] %s\n", i, node_to_str(recovereds + i));
 
@@ -601,7 +605,7 @@ static int cluster_recovery_completion(const struct sd_req *req,
 	if (vnode_info->nr_nodes == nr_recovereds &&
 	    memcmp(vnode_info->nodes, recovereds,
 		   sizeof(*recovereds) * nr_recovereds) == 0) {
-		dprintf("all nodes are recovered at epoch %d\n", req->epoch);
+		dprintf("all nodes are recovered at epoch %d\n", epoch);
 		if (sd_store->cleanup)
 			sd_store->cleanup();
 	}
diff --git a/sheep/recovery.c b/sheep/recovery.c
index f9f36f7..9c5c712 100644
--- a/sheep/recovery.c
+++ b/sheep/recovery.c
@@ -319,7 +319,7 @@ static void notify_recovery_completion_work(struct work *work)
 	int ret;
 
 	sd_init_req(&hdr, SD_OP_COMPLETE_RECOVERY);
-	hdr.epoch = rw->epoch;
+	hdr.obj.tgt_epoch = rw->epoch;
 	hdr.flags = SD_FLAG_CMD_WRITE;
 	hdr.data_length = sizeof(sys->this_node);
 
-- 
1.7.2.5




More information about the sheepdog mailing list