[Sheepdog] [PATCH 1/4] move check_epoch() out of store_queue_request
FUJITA Tomonori
fujita.tomonori at lab.ntt.co.jp
Mon Dec 21 09:04:14 CET 2009
Signed-off-by: FUJITA Tomonori <fujita.tomonori at lab.ntt.co.jp>
---
collie/collie.h | 2 +-
collie/store.c | 32 ++++++++++++++++++++++----------
2 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/collie/collie.h b/collie/collie.h
index 5bdbe3c..0980ebc 100644
--- a/collie/collie.h
+++ b/collie/collie.h
@@ -63,7 +63,7 @@ struct cluster_info {
uint32_t this_pid;
struct sheepdog_node_list_entry this_node;
- uint64_t epoch;
+ uint32_t epoch;
struct list_head node_list;
struct list_head vm_list;
diff --git a/collie/store.c b/collie/store.c
index 6b66a92..30bb115 100644
--- a/collie/store.c
+++ b/collie/store.c
@@ -132,6 +132,26 @@ static int read_from_other_sheeps(struct cluster_info *cluster,
return ret;
}
+static int check_epoch(struct cluster_info *cluster, struct request *req)
+{
+ struct sd_req *hdr = (struct sd_req *)&req->rq;
+ uint32_t req_epoch = hdr->epoch;
+ uint32_t opcode = hdr->opcode;
+ int ret = SD_RES_SUCCESS;
+
+ if (before(req_epoch, cluster->epoch)) {
+ ret = SD_RES_OLD_NODE_VER;
+ eprintf("old node version %u %u, %x\n",
+ cluster->epoch, req_epoch, opcode);
+ } else if (after(req_epoch, cluster->epoch)) {
+ ret = SD_RES_NEW_NODE_VER;
+ eprintf("new node version %u %u %x\n",
+ cluster->epoch, req_epoch, opcode);
+ }
+
+ return ret;
+}
+
void store_queue_request(struct work *work, int idx)
{
struct request *req = container_of(work, struct request, work);
@@ -163,17 +183,9 @@ void store_queue_request(struct work *work, int idx)
}
if (opcode != SD_OP_GET_NODE_LIST) {
- if (before(req_epoch, epoch)) {
- ret = SD_RES_OLD_NODE_VER;
- eprintf("old node version %u %u, %x %" PRIx64 "\n",
- epoch, req_epoch, opcode, oid);
+ ret = check_epoch(cluster, req);
+ if (ret != SD_RES_SUCCESS)
goto out;
- } else if (after(req_epoch, epoch)) {
- ret = SD_RES_NEW_NODE_VER;
- eprintf("new node version %u %u %x %" PRIx64 "\n",
- epoch, req_epoch, opcode, oid);
- goto out;
- }
}
switch (opcode) {
--
1.5.6.5
More information about the sheepdog
mailing list