[sheepdog] [PATCH] PATCH[1/2] sheep: always write store farm to config file
Jens Weber
jweber at tek2b.org
Sat Aug 11 15:26:17 CEST 2012
This patch "sheep: always write store farm to config file" fix that config file has always the same size, gateway_only or not.
Signed-off-by: Jens Weber <jweber at tek2b.org>
---
sheep/group.c | 5 ++---
sheep/sheep_priv.h | 2 +-
sheep/store.c | 23 +++++++++++++++--------
3 files changed, 18 insertions(+), 12 deletions(-)
diff --git a/sheep/group.c b/sheep/group.c
index 05ffb3e..b82a081 100644
--- a/sheep/group.c
+++ b/sheep/group.c
@@ -728,13 +728,12 @@ 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);
- /* We don't need backend for gateway-only node */
- if (!sys->gateway_only && !sd_store && strlen((char *)msg->store)) {
+ if (!sd_store && strlen((char *)msg->store)) {
sd_store = find_store_driver((char *)msg->store);
if (sd_store) {
if (sd_store->init(obj_path) != SD_RES_SUCCESS)
panic("failed to initialize store\n");
- if (set_cluster_store(sd_store->name) != SD_RES_SUCCESS)
+ if (set_cluster_store(sd_store->name, sys->gateway_only) != SD_RES_SUCCESS)
panic("failed to store into config file\n");
} else
panic("backend store %s not supported\n",
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index 857cf87..46fd89f 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -240,7 +240,7 @@ int set_cluster_copies(uint8_t copies);
int get_cluster_copies(uint8_t *copies);
int set_cluster_flags(uint16_t flags);
int get_cluster_flags(uint16_t *flags);
-int set_cluster_store(const char *name);
+int set_cluster_store(const char *name, uint8_t gateway_only);
int get_cluster_store(char *buf);
int set_cluster_space(uint64_t space);
int get_cluster_space(uint64_t *space);
diff --git a/sheep/store.c b/sheep/store.c
index b093916..0a68d1e 100644
--- a/sheep/store.c
+++ b/sheep/store.c
@@ -705,7 +705,7 @@ out:
return ret;
}
-int set_cluster_store(const char *name)
+int set_cluster_store(const char *name, uint8_t gateway_only)
{
int fd, ret = SD_RES_EIO, len;
void *jd;
@@ -717,19 +717,26 @@ int set_cluster_store(const char *name)
len = strlen(name) + 1;
if (len > STORE_LEN)
goto err;
- jd = jrnl_begin(name, len,
- offsetof(struct sheepdog_config, store),
- config_path, jrnl_path);
- if (!jd) {
- ret = SD_RES_EIO;
- goto err;
+
+ /* We don't need this for gateway-only node */
+ if (!gateway_only) {
+ jd = jrnl_begin(name, len,
+ offsetof(struct sheepdog_config, store),
+ config_path, jrnl_path);
+ if (!jd) {
+ ret = SD_RES_EIO;
+ goto err;
+ }
}
+
ret = xpwrite(fd, name, len, offsetof(struct sheepdog_config, store));
if (ret != len)
ret = SD_RES_EIO;
else
ret = SD_RES_SUCCESS;
- jrnl_end(jd);
+
+ /* We don't need this for gateway-only node */
+ if (!gateway_only) jrnl_end(jd);
err:
close(fd);
out:
--
1.7.10.4
More information about the sheepdog
mailing list