[Sheepdog] [PATCH v5 6/7 Updated] sheep: add set/get_cluster_status()

Liu Yuan namei.unix at gmail.com
Wed Oct 19 14:38:26 CEST 2011


From: Liu Yuan <tailai.ly at taobao.com>

Hi kazum,

Sorry for the noise.
Again, I forgot run guilt refresh. Sorry for the noise.

Please apply this one.

Yuan
--->8--->8-------

Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
 sheep/sheep_priv.h |    2 ++
 sheep/store.c      |   39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 41 insertions(+), 0 deletions(-)

diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index 7646168..24d6a7d 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -211,6 +211,8 @@ int update_epoch_store(uint32_t epoch);
 
 int set_global_nr_copies(uint32_t copies);
 int get_global_nr_copies(uint32_t *copies);
+int set_cluster_flags(uint16_t flags);
+int get_cluster_flags(uint16_t *flags);
 
 #define NR_GW_WORKER_THREAD 4
 #define NR_IO_WORKER_THREAD 4
diff --git a/sheep/store.c b/sheep/store.c
index 407337d..af8ecd0 100644
--- a/sheep/store.c
+++ b/sheep/store.c
@@ -2063,3 +2063,42 @@ int get_global_nr_copies(uint32_t *copies)
 
 	return SD_RES_SUCCESS;
 }
+
+int set_cluster_flags(uint16_t flags)
+{
+	int fd, ret = SD_RES_EIO;
+
+	fd = open(config_path, O_SYNC | O_WRONLY);
+	if (fd < 0)
+		goto out;
+
+	ret = jrnl_perform(fd, &flags, sizeof(flags),
+			offsetof(struct sheepdog_config, flags),
+			config_path, jrnl_path);
+	if (ret != 0)
+		ret = SD_RES_EIO;
+
+	close(fd);
+out:
+	return ret;
+}
+
+int get_cluster_flags(uint16_t *flags)
+{
+	int fd, ret = SD_RES_EIO;
+
+	fd = open(config_path, O_RDONLY);
+	if (fd < 0)
+		goto out;
+
+	ret = pread64(fd, flags, sizeof(*flags),
+			offsetof(struct sheepdog_config, flags));
+	if (ret != sizeof(*flags))
+		ret = SD_RES_EIO;
+	else
+		ret = SD_RES_SUCCESS;
+
+	close(fd);
+out:
+	return ret;
+}
-- 
1.7.6.1




More information about the sheepdog mailing list