[Sheepdog] [PATCH 08/10] collie: allow qemu not to set epoch field

FUJITA Tomonori fujita.tomonori at lab.ntt.co.jp
Tue Jan 26 05:34:54 CET 2010


qemu always sends requests to a local dog so and he forwards them. So
no need to require qemu to set epoch field.

Signed-off-by: FUJITA Tomonori <fujita.tomonori at lab.ntt.co.jp>
---
 collie/collie.h |    1 +
 collie/group.c  |   13 +++++++++++++
 collie/store.c  |   17 +++++++++--------
 3 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/collie/collie.h b/collie/collie.h
index f25857a..183f771 100644
--- a/collie/collie.h
+++ b/collie/collie.h
@@ -66,6 +66,7 @@ struct cluster_info {
 	uint32_t epoch;
 
 	struct list_head node_list;
+	int node_list_idx;
 	struct list_head vm_list;
 	struct list_head pending_list;
 
diff --git a/collie/group.c b/collie/group.c
index 716f52c..e763d52 100644
--- a/collie/group.c
+++ b/collie/group.c
@@ -723,6 +723,19 @@ int build_node_list(struct list_head *node_list,
 	return nr;
 }
 
+static void update_node_list_idx(struct cluster_info *ci,
+				 struct sheepdog_node_list_entry *e, int nr)
+{
+	int i;
+
+	for (i = 0; i < nr; i++) {
+		if (e->id == ci->this_node.id) {
+			ci->node_list_idx = i;
+			break;
+		}
+	}
+}
+
 struct cluster_info *create_cluster(int port)
 {
 	int fd, ret;
diff --git a/collie/store.c b/collie/store.c
index 5462d49..e280e10 100644
--- a/collie/store.c
+++ b/collie/store.c
@@ -209,7 +209,7 @@ static int read_from_other_sheeps(struct cluster_info *cluster,
 }
 
 static int store_queue_request_local(struct cluster_info *cluster,
-				     struct request *req, char *buf);
+				     struct request *req, char *buf, uint32_t epoch);
 
 static int forward_obj_req(struct cluster_info *cluster, struct request *req,
 			   char *buf)
@@ -243,8 +243,9 @@ again:
 
 		/* TODO: we can do better; we need to chech this first */
 		if (e[n].id == cluster->this_node.id) {
-			store_queue_request_local(cluster, req, buf);
+			ret = store_queue_request_local(cluster, req, buf, cluster->epoch);
 			memcpy(rsp, &req->rp, sizeof(*rsp));
+			rsp->result = ret;
 			goto done;
 		}
 
@@ -263,6 +264,7 @@ again:
 		}
 
 		hdr2.flags |= SD_FLAG_CMD_FORWARD;
+		hdr2.epoch = cluster->epoch;
 
 		ret = exec_req(fd, (struct sd_req *)&hdr2, req->data, &wlen, &rlen);
 
@@ -392,7 +394,7 @@ int update_epoch_store(struct cluster_info *ci, uint32_t epoch)
 }
 
 static int store_queue_request_local(struct cluster_info *cluster,
-				     struct request *req, char *buf)
+				     struct request *req, char *buf, uint32_t epoch)
 {
 	int fd = -1, copies;
 	int ret = SD_RES_SUCCESS;
@@ -400,7 +402,6 @@ static int store_queue_request_local(struct cluster_info *cluster,
 	struct sd_obj_rsp *rsp = (struct sd_obj_rsp *)&req->rp;
 	uint64_t oid = hdr->oid;
 	uint32_t opcode = hdr->opcode;
-	uint32_t req_epoch = hdr->epoch;
 	char path[1024];
 
 	switch (opcode) {
@@ -409,9 +410,9 @@ static int store_queue_request_local(struct cluster_info *cluster,
 	case SD_OP_READ_OBJ:
 	case SD_OP_SYNC_OBJ:
 		if (opcode == SD_OP_CREATE_AND_WRITE_OBJ)
-			fd = ob_open(req_epoch, oid, O_CREAT, &ret);
+			fd = ob_open(epoch, oid, O_CREAT, &ret);
 		else
-			fd = ob_open(req_epoch, oid, 0, &ret);
+			fd = ob_open(epoch, oid, 0, &ret);
 
 		if (fd < 0)
 			goto out;
@@ -544,7 +545,7 @@ void store_queue_request(struct work *work, int idx)
 		goto out;
 	}
 
-	if (opcode != SD_OP_GET_NODE_LIST) {
+	if (hdr->flags & SD_FLAG_CMD_FORWARD) {
 		ret = check_epoch(cluster, req);
 		if (ret != SD_RES_SUCCESS)
 			goto out;
@@ -565,7 +566,7 @@ void store_queue_request(struct work *work, int idx)
 		goto out;
 	}
 
-	ret = store_queue_request_local(cluster, req, buf);
+	ret = store_queue_request_local(cluster, req, buf, epoch);
 out:
 	if (ret != SD_RES_SUCCESS) {
 		dprintf("failed, %d, %x, %" PRIx64" , %u, %u\n",
-- 
1.5.6.5




More information about the sheepdog mailing list