[sheepdog] [PATCH] sheep: don't call farm_init() for gateway-only node
Liu Yuan
namei.unix at gmail.com
Thu Jul 19 11:48:02 CEST 2012
From: Liu Yuan <tailai.ly at taobao.com>
Gateway-only node doesn't need backend at all, and we can restart it as gateway
node (has backend) again.
Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
sheep/group.c | 9 ++++++---
sheep/sheep.c | 2 ++
sheep/sheep_priv.h | 1 +
sheep/store.c | 8 +++++---
4 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/sheep/group.c b/sheep/group.c
index 4f9d196..f67600f 100644
--- a/sheep/group.c
+++ b/sheep/group.c
@@ -754,21 +754,24 @@ static void finish_join(struct join_message *msg, struct sd_node *joined,
if (msg->cluster_status != SD_STATUS_OK)
update_exceptional_node_list(get_latest_epoch(), msg);
- if (!sd_store && strlen((char *)msg->store)) {
+ /* We don't need backend for gateway-only node */
+ if (!sys->gateway_only && !sd_store && strlen((char *)msg->store)) {
sd_store = find_store_driver((char *)msg->store);
if (sd_store) {
sd_store->init(obj_path);
if (set_cluster_store(sd_store->name) != SD_RES_SUCCESS)
panic("failed to store into config file\n");
} else
- panic("backend store %s not supported\n", msg->store);
+ panic("backend store %s not supported\n",
+ msg->store);
}
/* We need to purge the stale objects for sheep joining back
* after crash
*/
if (msg->inc_epoch)
- if (sd_store->purge_obj &&
+ if (!sys->gateway_only &&
+ sd_store->purge_obj &&
sd_store->purge_obj() != SD_RES_SUCCESS)
panic("can't remove stale objects\n");
diff --git a/sheep/sheep.c b/sheep/sheep.c
index b3a12e3..2e208de 100644
--- a/sheep/sheep.c
+++ b/sheep/sheep.c
@@ -243,6 +243,8 @@ int main(int argc, char **argv)
break;
}
}
+ if (nr_vnodes == 0)
+ sys->gateway_only = 1;
if (optind != argc)
dir = argv[optind];
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index 7e89d7b..116be97 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -115,6 +115,7 @@ struct cluster_info {
uint32_t recovered_epoch;
int use_directio;
+ uint8_t gateway_only;
struct work_queue *gateway_wqueue;
struct work_queue *io_wqueue;
diff --git a/sheep/store.c b/sheep/store.c
index 17c2933..a05822d 100644
--- a/sheep/store.c
+++ b/sheep/store.c
@@ -467,9 +467,11 @@ int init_store(const char *d, int enable_write_cache)
if (ret)
return ret;
- ret = init_store_driver();
- if (ret)
- return ret;
+ if (!sys->gateway_only) {
+ ret = init_store_driver();
+ if (ret)
+ return ret;
+ }
if (enable_write_cache) {
sys->enable_write_cache = 1;
--
1.7.10.2
More information about the sheepdog
mailing list