[Sheepdog] [PATCH 6/8] sheep: fix retry conditions of forwarding operations
MORITA Kazutaka
morita.kazutaka at lab.ntt.co.jp
Sat Aug 28 22:55:32 CEST 2010
We must take into account the following cases:
- the target node is down and epoch will change soon
- the target node does not finish join operations
Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
sheep/sdnet.c | 6 ++++--
sheep/sheep_priv.h | 2 ++
sheep/store.c | 10 +++++-----
3 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/sheep/sdnet.c b/sheep/sdnet.c
index ae1c3b5..c8cbd87 100644
--- a/sheep/sdnet.c
+++ b/sheep/sdnet.c
@@ -123,8 +123,10 @@ static void __done(struct work *work, int idx)
if (!(req->rq.flags & SD_FLAG_CMD_DIRECT) &&
(req->rp.result == SD_RES_OLD_NODE_VER ||
- req->rp.result == SD_RES_NEW_NODE_VER)) {
-
+ req->rp.result == SD_RES_NEW_NODE_VER ||
+ req->rp.result == SD_RES_NETWORK_ERROR ||
+ req->rp.result == SD_RES_WAIT_FOR_JOIN ||
+ req->rp.result == SD_RES_WAIT_FOR_FORMAT)) {
req->rq.epoch = sys->epoch;
req->nr_nodes = setup_ordered_sd_node_list(req);
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index 05c0052..c66baf4 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -38,6 +38,8 @@
#define SD_STATUS_SHUTDOWN 0x03
#define SD_STATUS_JOIN_FAILED 0x04
+#define SD_RES_NETWORK_ERROR 0x81 /* Network error between sheeps */
+
enum cpg_event_type {
CPG_EVENT_CONCHG,
CPG_EVENT_DELIVER,
diff --git a/sheep/store.c b/sheep/store.c
index 2952c4e..a4d6155 100644
--- a/sheep/store.c
+++ b/sheep/store.c
@@ -431,7 +431,7 @@ static int forward_read_obj_req(struct request *req)
fd = connect_to(name, e[n].port);
if (fd < 0) {
- ret = SD_RES_EIO;
+ ret = SD_RES_NETWORK_ERROR;
goto out;
}
@@ -443,7 +443,7 @@ static int forward_read_obj_req(struct request *req)
close(fd);
if (ret) /* network errors */
- ret = SD_RES_EIO;
+ ret = SD_RES_NETWORK_ERROR;
else {
memcpy(&req->rp, rsp, sizeof(*rsp));
ret = rsp->result;
@@ -504,13 +504,13 @@ static int forward_write_obj_req(struct request *req)
fd = connect_to(name, e[n].port);
if (fd < 0) {
eprintf("failed to connect to %s:%"PRIu32"\n", name, e[n].port);
- ret = SD_RES_EIO;
+ ret = SD_RES_NETWORK_ERROR;
goto out;
}
ret = send_req(fd, (struct sd_req *)hdr, req->data, &wlen);
if (ret) { /* network errors */
- ret = SD_RES_EIO;
+ ret = SD_RES_NETWORK_ERROR;
dprintf("fail %"PRIu32"\n", ret);
goto out;
}
@@ -562,7 +562,7 @@ again:
if (ret) {
eprintf("failed to get a rsp, %m\n");
- ret = SD_RES_EIO;
+ ret = SD_RES_NETWORK_ERROR;
goto out;
}
--
1.5.6.5
More information about the sheepdog
mailing list