[sheepdog] [PATCH v1 1/5] sheep: add new option for configure

Robin Dong robin.k.dong at gmail.com
Tue Apr 29 04:53:41 CEST 2014


From: Robin Dong <sanbai at taobao.com>

Add new configure option '--enable-diskvnodes' so we can
start sheep cluster by using disk as vnodes.

Signed-off-by: Robin Dong <sanbai at taobao.com>
---
 configure.ac             | 10 ++++++++++
 include/internal_proto.h |  1 +
 sheep/config.c           |  9 ++++++++-
 sheep/sheep.c            |  6 ++++++
 4 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index a3abb7b..7e6691f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -255,6 +255,12 @@ AC_ARG_ENABLE([nfs],
 	[ enable_nfs="no" ],)
 AM_CONDITIONAL(BUILD_NFS, test x$enable_nfs = xyes)
 
+AC_ARG_ENABLE([diskvnodes],
+	[ --enable-diskvnodes : enable disk as vnodes (default no) ],,
+	[ enable_diskvnodes="no" ],)
+AM_CONDITIONAL(BUILD_DISKVNODES, test x$enable_diskvnodes = xyes)
+
+
 CP=cp
 OS_LDL="-ldl"
 case "$host_os" in
@@ -367,6 +373,10 @@ if test "x${enable_nfs}" = xyes; then
 	PACKAGE_FEATURES="$PACKAGE_FEATURES nfs"
 fi
 
+if test "x${enable_diskvnodes}" = xyes; then
+	AC_DEFINE_UNQUOTED(HAVE_DISKVNODES, 1, [have diskvnodes])
+fi
+
 # extra warnings
 EXTRA_WARNINGS=""
 
diff --git a/include/internal_proto.h b/include/internal_proto.h
index 0eb7227..7db3769 100644
--- a/include/internal_proto.h
+++ b/include/internal_proto.h
@@ -172,6 +172,7 @@ struct cluster_info {
 	uint8_t nr_copies;
 	uint8_t copy_policy;
 	enum sd_status status : 8;
+	uint8_t disk_as_vnode;
 	uint32_t __pad;
 	uint8_t store[STORE_LEN];
 
diff --git a/sheep/config.c b/sheep/config.c
index 9a0217b..1b89a94 100644
--- a/sheep/config.c
+++ b/sheep/config.c
@@ -21,7 +21,7 @@ static struct sheepdog_config {
 	uint8_t store[STORE_LEN];
 	uint8_t shutdown;
 	uint8_t copy_policy;
-	uint8_t __pad;
+	uint8_t disk_as_vnode;
 	uint16_t version;
 	uint64_t space;
 } config;
@@ -64,6 +64,7 @@ static int get_cluster_config(struct cluster_info *cinfo)
 	cinfo->nr_copies = config.copies;
 	cinfo->flags = config.flags;
 	cinfo->copy_policy = config.copy_policy;
+	cinfo->disk_as_vnode = config.disk_as_vnode;
 	memcpy(cinfo->store, config.store, sizeof(config.store));
 
 	return SD_RES_SUCCESS;
@@ -120,9 +121,14 @@ int init_config_file(void)
 		goto out;
 	}
 
+
 reload:
 	ret = 0;
 	get_cluster_config(&sys->cinfo);
+	if (config.disk_as_vnode !=  sys->cinfo.disk_as_vnode) {
+		sd_err("This sheep can't run because exists data format mismatch");
+		return -1;
+	}
 out:
 	close(fd);
 
@@ -148,6 +154,7 @@ int set_cluster_config(const struct cluster_info *cinfo)
 	config.ctime = cinfo->ctime;
 	config.copies = cinfo->nr_copies;
 	config.copy_policy = cinfo->copy_policy;
+	config.disk_as_vnode = cinfo->disk_as_vnode;
 	config.flags = cinfo->flags;
 	memset(config.store, 0, sizeof(config.store));
 	pstrcpy((char *)config.store, sizeof(config.store),
diff --git a/sheep/sheep.c b/sheep/sheep.c
index 74d1aaf..1551088 100644
--- a/sheep/sheep.c
+++ b/sheep/sheep.c
@@ -753,6 +753,12 @@ int main(int argc, char **argv)
 		}
 	}
 
+	#ifdef HAVE_DISKVNODES
+	sys->cinfo.disk_as_vnode = 1;
+	#else
+	sys->cinfo.disk_as_vnode = 0;
+	#endif
+
 	sheep_info.port = port;
 	early_log_init(log_format, &sheep_info);
 
-- 
1.7.12.4




More information about the sheepdog mailing list