[Sheepdog] [PATCH v5 03/17] sheep: transfer store backend for newly joined node
Liu Yuan
namei.unix at gmail.com
Fri Dec 30 14:06:58 CET 2011
From: Liu Yuan <tailai.ly at taobao.com>
When the new node joins the cluster, it doesn't know what kind of
backend store the cluster uses, so we need to transfer this information
by master node in the join phase.
Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
sheep/group.c | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
diff --git a/sheep/group.c b/sheep/group.c
index 115c965..239f311 100644
--- a/sheep/group.c
+++ b/sheep/group.c
@@ -27,6 +27,8 @@
static int cdrv_fd;
static struct coroutine *cdrv_co;
+extern struct store_driver *sd_store;
+extern char *obj_path;
struct node {
struct sd_node ent;
@@ -44,7 +46,8 @@ struct join_message {
uint64_t ctime;
uint32_t result;
uint8_t inc_epoch; /* set non-zero when we increment epoch of all nodes */
- uint8_t pad[3];
+ uint8_t store[10];
+ uint8_t pad[1];
union {
struct sd_node nodes[0];
struct sd_node leave_nodes[0];
@@ -448,6 +451,8 @@ static void join(struct sd_node *joining, struct join_message *msg)
msg->nr_sobjs = sys->nr_sobjs;
msg->cluster_flags = sys->flags;
msg->ctime = get_cluster_ctime();
+ if (sd_store)
+ strcpy((char *)msg->store, sd_store->name);
}
static int get_vdi_bitmap_from(struct sd_node *node)
@@ -561,6 +566,12 @@ static void update_cluster_info(struct join_message *msg,
&& msg->inc_epoch)
update_epoch_log(sys->epoch);
+ if (!sd_store && strlen((char *)msg->store)) {
+ sd_store = find_store_driver((char *)msg->store);
+ if (sd_store)
+ sd_store->init(obj_path);
+ }
+
join_finished:
sys->nodes[sys->nr_nodes++] = *joined;
qsort(sys->nodes, sys->nr_nodes, sizeof(*sys->nodes), node_cmp);
--
1.7.8.rc3
More information about the sheepdog
mailing list