[sheepdog] [PATCH 1/2] sheep: change terminology for vdi state synchronization during node joining

Hitoshi Mitake mitake.hitoshi at lab.ntt.co.jp
Mon Jun 8 15:34:44 CEST 2015


Currently, sheepdog is using a word "snapshot" as a terminology for
vdi state synchronization during node joining
(e.g. SD_OP_VDI_STATE_SNAPSHOT_CTL). It is confusing because the word
snapshot resembles snapshot of VDIs.

This patch changes the terminology to checkpoint based on the famous
textbook:
http://www.cs.cornell.edu/projects/quicksilver/public_pdfs/History.pdf

Signed-off-by: Hitoshi Mitake <mitake.hitoshi at lab.ntt.co.jp>
---
 include/internal_proto.h |  2 +-
 include/sheepdog_proto.h |  2 +-
 sheep/group.c            | 24 +++++++++---------
 sheep/ops.c              | 22 ++++++++---------
 sheep/sheep_priv.h       |  8 +++---
 sheep/vdi.c              | 63 ++++++++++++++++++++++++------------------------
 6 files changed, 61 insertions(+), 60 deletions(-)

diff --git a/include/internal_proto.h b/include/internal_proto.h
index a1a073d..b3cbbc5 100644
--- a/include/internal_proto.h
+++ b/include/internal_proto.h
@@ -108,7 +108,7 @@
 #define SD_OP_ALLOW_INODE_UPDATE      0xC4
 #define SD_OP_REPAIR_REPLICA	0xC5
 #define SD_OP_OIDS_EXIST	0xC6
-#define SD_OP_VDI_STATE_SNAPSHOT_CTL  0xC7
+#define SD_OP_VDI_STATE_CHECKPOINT_CTL  0xC7
 #define SD_OP_INODE_COHERENCE 0xC8
 #define SD_OP_READ_DEL_VDIS  0xC9
 #define SD_OP_GET_RECOVERY      0xCA
diff --git a/include/sheepdog_proto.h b/include/sheepdog_proto.h
index 4a6edbe..4b9dacc 100644
--- a/include/sheepdog_proto.h
+++ b/include/sheepdog_proto.h
@@ -198,7 +198,7 @@ struct sd_req {
 		struct {
 			uint32_t        get; /* 0 means free, 1 means get */
 			uint32_t        tgt_epoch;
-		} vdi_state_snapshot;
+		} vdi_state_checkpoint;
 		struct {
 			/* 1 means validate, 0 means invalidate */
 			uint32_t        vid;
diff --git a/sheep/group.c b/sheep/group.c
index 7c7cb6d..e342453 100644
--- a/sheep/group.c
+++ b/sheep/group.c
@@ -710,18 +710,18 @@ static struct vdi_state *do_cinfo_collection_work(uint32_t epoch,
 	vs = xcalloc(rlen, sizeof(*vs));
 
 retry:
-	sd_init_req(&hdr, SD_OP_VDI_STATE_SNAPSHOT_CTL);
-	hdr.vdi_state_snapshot.get = 1;
-	hdr.vdi_state_snapshot.tgt_epoch = epoch;
+	sd_init_req(&hdr, SD_OP_VDI_STATE_CHECKPOINT_CTL);
+	hdr.vdi_state_checkpoint.get = 1;
+	hdr.vdi_state_checkpoint.tgt_epoch = epoch;
 	hdr.data_length = rlen;
 
 	ret = sheep_exec_req(&n->nid, &hdr, (char *)vs);
 	if (ret == SD_RES_SUCCESS) {
-		sd_debug("succeed to obtain snapshot of vdi states");
+		sd_debug("succeed to obtain checkpoint of vdi states");
 		*nr_vdi_states = rsp->data_length / sizeof(*vs);
 		return vs;
 	} else if (ret == SD_RES_BUFFER_SMALL) {
-		sd_debug("buffer is small for obtaining snapshot of vdi states,"
+		sd_debug("buffer is small for obtaining checkpoint of vdi states,"
 			 " doubling it (%lu -> %lu)", rlen * sizeof(*vs),
 			 rlen * 2 * sizeof(*vs));
 		rlen *= 2;
@@ -729,7 +729,7 @@ retry:
 		goto retry;
 	}
 
-	sd_err("failed to obtain snapshot of vdi states from node %s",
+	sd_err("failed to obtain checkpoint of vdi states from node %s",
 	       node_to_str(n));
 	return NULL;
 }
@@ -756,7 +756,7 @@ static void cinfo_collection_work(struct work *work)
 			goto get_succeed;
 	}
 
-	panic("getting a snapshot of vdi state at epoch %d failed", w->epoch);
+	panic("getting a checkpoint of vdi state at epoch %d failed", w->epoch);
 
 get_succeed:
 	w->nr_vdi_states = nr_vdi_states;
@@ -768,13 +768,13 @@ get_succeed:
 		if (node_is_local(n))
 			continue;
 
-		sd_init_req(&hdr, SD_OP_VDI_STATE_SNAPSHOT_CTL);
-		hdr.vdi_state_snapshot.get = 0;
-		hdr.vdi_state_snapshot.tgt_epoch = w->epoch;
+		sd_init_req(&hdr, SD_OP_VDI_STATE_CHECKPOINT_CTL);
+		hdr.vdi_state_checkpoint.get = 0;
+		hdr.vdi_state_checkpoint.tgt_epoch = w->epoch;
 
 		ret = sheep_exec_req(&n->nid, &hdr, (char *)vs);
 		if (ret != SD_RES_SUCCESS)
-			sd_err("error at freeing a snapshot of vdi state"
+			sd_err("error at freeing a checkpoint of vdi state"
 			       " at epoch %d", w->epoch);
 	}
 
@@ -906,7 +906,7 @@ static void update_cluster_info(const struct cluster_info *cinfo,
 		}
 	} else {
 		if (0 < cinfo->epoch && cinfo->status == SD_STATUS_OK)
-			take_vdi_state_snapshot(cinfo->epoch - 1);
+			create_vdi_state_checkpoint(cinfo->epoch - 1);
 	}
 
 	sockfd_cache_add(&joined->nid);
diff --git a/sheep/ops.c b/sheep/ops.c
index 7b92f8c..223994c 100644
--- a/sheep/ops.c
+++ b/sheep/ops.c
@@ -1454,30 +1454,30 @@ static int cluster_release_vdi_main(const struct sd_req *req,
 	return SD_RES_SUCCESS;
 }
 
-static int local_vdi_state_snapshot_ctl(const struct sd_req *req,
+static int local_vdi_state_checkpoint_ctl(const struct sd_req *req,
 					struct sd_rsp *rsp, void *data,
 					const struct sd_node *sender)
 {
-	bool get = !!req->vdi_state_snapshot.get;
-	int epoch = req->vdi_state_snapshot.tgt_epoch;
+	bool get = !!req->vdi_state_checkpoint.get;
+	int epoch = req->vdi_state_checkpoint.tgt_epoch;
 	int ret, length = 0;
 
-	sd_info("%s vdi state snapshot at epoch %d",
+	sd_info("%s vdi state checkpoint at epoch %d",
 		get ? "getting" : "freeing", epoch);
 
 	if (get) {
-		ret = get_vdi_state_snapshot(epoch, data, req->data_length,
-					     &length);
+		ret = get_vdi_state_checkpoint(epoch, data, req->data_length,
+					       &length);
 		if (ret == SD_RES_SUCCESS)
 			rsp->data_length = length;
 		else {
-			sd_info("failed to get vdi state snapshot: %s",
+			sd_info("failed to get vdi state checkpoint: %s",
 			       sd_strerror(ret));
 
 			return ret;
 		}
 	} else
-		free_vdi_state_snapshot(epoch);
+		free_vdi_state_checkpoint(epoch);
 
 	return SD_RES_SUCCESS;
 }
@@ -1948,10 +1948,10 @@ static struct sd_op_template sd_ops[] = {
 		.process_work = local_repair_replica,
 	},
 
-	[SD_OP_VDI_STATE_SNAPSHOT_CTL] = {
-		.name = "VDI_STATE_SNAPSHOT_CTL",
+	[SD_OP_VDI_STATE_CHECKPOINT_CTL] = {
+		.name = "VDI_STATE_CHECKPOINT_CTL",
 		.type = SD_OP_TYPE_LOCAL,
-		.process_main = local_vdi_state_snapshot_ctl,
+		.process_main = local_vdi_state_checkpoint_ctl,
 	},
 
 	[SD_OP_GET_CLUSTER_DEFAULT] = {
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index 7becf6e..8c173a9 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -371,10 +371,10 @@ int sd_create_hyper_volume(const char *name, uint32_t *vdi_id);
 bool vdi_lock(uint32_t vid, const struct node_id *owner, int type);
 bool vdi_unlock(uint32_t vid, const struct node_id *owner, int type);
 void apply_vdi_lock_state(struct vdi_state *vs);
-void take_vdi_state_snapshot(int epoch);
-int get_vdi_state_snapshot(int epoch, void *data, int data_len_max,
-			   int *data_len_result);
-void free_vdi_state_snapshot(int epoch);
+void create_vdi_state_checkpoint(int epoch);
+int get_vdi_state_checkpoint(int epoch, void *data, int data_len_max,
+			     int *data_len_result);
+void free_vdi_state_checkpoint(int epoch);
 void log_vdi_op_lock(uint32_t vid, const struct node_id *owner, int type);
 void log_vdi_op_unlock(uint32_t vid, const struct node_id *owner, int type);
 void play_logged_vdi_ops(void);
diff --git a/sheep/vdi.c b/sheep/vdi.c
index 7f6cf67..aeb6e68 100644
--- a/sheep/vdi.c
+++ b/sheep/vdi.c
@@ -2118,83 +2118,84 @@ out:
 	return ret;
 }
 
-struct vdi_state_snapshot {
+struct vdi_state_checkpoint {
 	int epoch, nr_vs;
 	struct vdi_state *vs;
 
 	struct list_node list;
 };
 
-static LIST_HEAD(vdi_state_snapshot_list);
+static LIST_HEAD(vdi_state_checkpoint_list);
 
-main_fn void take_vdi_state_snapshot(int epoch)
+main_fn void create_vdi_state_checkpoint(int epoch)
 {
 	/*
-	 * take a snapshot of current vdi state and associate it with
+	 * take a checkpoint of current vdi state and associate it with
 	 * the given epoch
 	 */
-	struct vdi_state_snapshot *snapshot;
+	struct vdi_state_checkpoint *checkpoint;
 
-	list_for_each_entry(snapshot, &vdi_state_snapshot_list, list) {
-		if (snapshot->epoch == epoch) {
-			sd_debug("duplicate snapshot of epoch %d", epoch);
+	list_for_each_entry(checkpoint, &vdi_state_checkpoint_list, list) {
+		if (checkpoint->epoch == epoch) {
+			sd_debug("duplicate checkpoint of epoch %d", epoch);
 			return;
 		}
 
 	}
 
-	snapshot = xzalloc(sizeof(*snapshot));
-	snapshot->epoch = epoch;
-	snapshot->vs = fill_vdi_state_list_with_alloc(&snapshot->nr_vs);
-	INIT_LIST_NODE(&snapshot->list);
-	list_add_tail(&snapshot->list, &vdi_state_snapshot_list);
+	checkpoint = xzalloc(sizeof(*checkpoint));
+	checkpoint->epoch = epoch;
+	checkpoint->vs = fill_vdi_state_list_with_alloc(&checkpoint->nr_vs);
+	INIT_LIST_NODE(&checkpoint->list);
+	list_add_tail(&checkpoint->list, &vdi_state_checkpoint_list);
 
-	sd_debug("taking a snapshot of vdi state at epoch %d succeed", epoch);
-	sd_debug("a number of vdi state: %d", snapshot->nr_vs);
+	sd_debug("creating a checkpoint of vdi state at epoch %d succeed",
+		 epoch);
+	sd_debug("a number of vdi state: %d", checkpoint->nr_vs);
 }
 
-main_fn int get_vdi_state_snapshot(int epoch, void *data, int data_len_max,
-				   int *data_len_result)
+main_fn int get_vdi_state_checkpoint(int epoch, void *data, int data_len_max,
+				     int *data_len_result)
 {
-	struct vdi_state_snapshot *snapshot;
+	struct vdi_state_checkpoint *checkpoint;
 	int len;
 
-	list_for_each_entry(snapshot, &vdi_state_snapshot_list, list) {
-		if (snapshot->epoch == epoch)
+	list_for_each_entry(checkpoint, &vdi_state_checkpoint_list, list) {
+		if (checkpoint->epoch == epoch)
 			goto found;
 	}
 
-	sd_info("get request for not prepared vdi state snapshot, epoch: %d",
+	sd_info("get request for not prepared vdi state checkpoint, epoch: %d",
 		epoch);
 	return SD_RES_AGAIN;
 
 found:
-	len = sizeof(*snapshot->vs) * snapshot->nr_vs;
+	len = sizeof(*checkpoint->vs) * checkpoint->nr_vs;
 	if (data_len_max < len) {
 		sd_info("maximum allowed length: %d, required length: %d",
 			data_len_max, len);
 		return SD_RES_BUFFER_SMALL;
 	}
 
-	memcpy(data, snapshot->vs, len);
+	memcpy(data, checkpoint->vs, len);
 	return SD_RES_SUCCESS;
 }
 
-main_fn void free_vdi_state_snapshot(int epoch)
+main_fn void free_vdi_state_checkpoint(int epoch)
 {
-	struct vdi_state_snapshot *snapshot;
+	struct vdi_state_checkpoint *checkpoint;
 
-	list_for_each_entry(snapshot, &vdi_state_snapshot_list, list) {
-		if (snapshot->epoch == epoch) {
-			list_del(&snapshot->list);
-			free(snapshot->vs);
-			free(snapshot);
+	list_for_each_entry(checkpoint, &vdi_state_checkpoint_list, list) {
+		if (checkpoint->epoch == epoch) {
+			list_del(&checkpoint->list);
+			free(checkpoint->vs);
+			free(checkpoint);
 
 			return;
 		}
 	}
 
-	panic("invalid free request for vdi state snapshot, epoch: %d", epoch);
+	panic("invalid free request for vdi state checkpoint, epoch: %d", epoch);
 }
 
 static int clean_matched_obj(uint64_t oid, const char *path,
-- 
1.9.1



More information about the sheepdog mailing list