[sheepdog] [PATCH 6/6] sheep: don't read epoch log from local in epoch_log_read_remote
MORITA Kazutaka
morita.kazutaka at lab.ntt.co.jp
Tue Feb 26 05:06:50 CET 2013
This patch uses get_vnode_info to get the current node membership in
epoch_log_read_remote. It is because the delayed nodes don't have
epoch log in local store. This also moves epoch_log_read_remote to
group.c since it is not a function to access local store.
Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
sheep/group.c | 43 +++++++++++++++++++++++++++++++++++++++++++
sheep/store.c | 39 ---------------------------------------
2 files changed, 43 insertions(+), 39 deletions(-)
diff --git a/sheep/group.c b/sheep/group.c
index 49ba642..c2070b4 100644
--- a/sheep/group.c
+++ b/sheep/group.c
@@ -390,6 +390,11 @@ static bool add_delayed_node(uint32_t epoch, const struct sd_node *node)
return true;
}
+static bool is_delayed_node(const struct sd_node *node)
+{
+ return !!find_entry_list(node, &sys->delayed_nodes);
+}
+
/*
* For a node that failed to join check if was part of the original
* epoch, and if so add it to the list of node expected to be present
@@ -448,6 +453,44 @@ static void clear_exceptional_node_lists(void)
list_del(&n->list);
}
+int epoch_log_read_remote(uint32_t epoch, struct sd_node *nodes, int len)
+{
+ int i, nr, ret;
+ struct vnode_info *vinfo = get_vnode_info();
+
+ nr = vinfo->nr_vnodes;
+ for (i = 0; i < nr; i++) {
+ struct sd_req hdr;
+ struct sd_rsp *rsp = (struct sd_rsp *)&hdr;
+ const struct sd_node *node = vinfo->nodes + i;
+
+ if (node_is_local(node))
+ continue;
+
+ /* delayed nodes don't have epoch log */
+ if (is_delayed_node(node))
+ continue;
+
+ sd_init_req(&hdr, SD_OP_GET_EPOCH);
+ hdr.data_length = len;
+ hdr.obj.tgt_epoch = epoch;
+ hdr.epoch = sys_epoch();
+ ret = sheep_exec_req(&node->nid, &hdr, nodes);
+ if (ret != SD_RES_SUCCESS)
+ continue;
+
+ put_vnode_info(vinfo);
+ return rsp->data_length / sizeof(*nodes);
+ }
+
+ /*
+ * If no node has targeted epoch log, return 0 here to at least
+ * allow reading older epoch logs.
+ */
+ put_vnode_info(vinfo);
+ return 0;
+}
+
static int cluster_sanity_check(struct join_message *jm)
{
uint64_t local_ctime = get_cluster_ctime();
diff --git a/sheep/store.c b/sheep/store.c
index 7f3b5cd..dbc687b 100644
--- a/sheep/store.c
+++ b/sheep/store.c
@@ -75,45 +75,6 @@ err_open:
return -1;
}
-int epoch_log_read_remote(uint32_t epoch, struct sd_node *nodes, int len)
-{
- int i, ret;
- unsigned int nr, le;
- struct sd_node local_nodes[SD_MAX_NODES];
-
- le = get_latest_epoch();
- if (!le)
- return 0;
-
- nr = epoch_log_read(le, local_nodes, sizeof(local_nodes));
- if (nr < 0)
- return -1;
-
- for (i = 0; i < nr; i++) {
- struct sd_req hdr;
- struct sd_rsp *rsp = (struct sd_rsp *)&hdr;
-
- if (node_is_local(&local_nodes[i]))
- continue;
-
- sd_init_req(&hdr, SD_OP_GET_EPOCH);
- hdr.data_length = len;
- hdr.obj.tgt_epoch = epoch;
- hdr.epoch = sys_epoch();
- ret = sheep_exec_req(&local_nodes[i].nid, &hdr, nodes);
- if (ret != SD_RES_SUCCESS)
- continue;
-
- return rsp->data_length / sizeof(*nodes);
- }
-
- /*
- * If no node has targeted epoch log, return 0 here to at least
- * allow reading older epoch logs.
- */
- return 0;
-}
-
int epoch_log_read(uint32_t epoch, struct sd_node *nodes, int len)
{
int fd;
--
1.8.1.3.566.gaa39828
More information about the sheepdog
mailing list