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

Liu Yuan namei.unix at gmail.com
Wed Oct 19 12:06:21 CEST 2011


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


Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
 sheep/sheep_priv.h |    2 ++
 sheep/store.c      |   37 +++++++++++++++++++++++++++++++++++++
 2 files changed, 39 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..c7fcdbf 100644
--- a/sheep/store.c
+++ b/sheep/store.c
@@ -2063,3 +2063,40 @@ 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;
+
+	close(fd);
+out:
+	return SD_RES_SUCCESS;
+}
-- 
1.7.6.1




More information about the sheepdog mailing list