[sheepdog] [PATCH v4 1/6] sheep: add new option for configure

Robin Dong robin.k.dong at gmail.com
Tue May 20 10:40:29 CEST 2014


From: Robin Dong <sanbai at taobao.com>

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

Signed-off-by: Robin Dong <sanbai at taobao.com>
---
 configure.ac             | 10 ++++++++++
 include/internal_proto.h |  3 ++-
 sheep/config.c           |  6 ++++++
 sheep/sheep.c            |  4 ++++
 4 files changed, 22 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..628bde7 100644
--- a/include/internal_proto.h
+++ b/include/internal_proto.h
@@ -131,7 +131,8 @@
 #define SD_RES_VDI_NOT_EMPTY    0x92 /* VDI is not empty */
 #define SD_RES_NOT_FOUND	0x93 /* Cannot found target */
 
-#define SD_CLUSTER_FLAG_STRICT  0x0001 /* Strict mode for write */
+#define SD_CLUSTER_FLAG_STRICT		0x0001 /* Strict mode for write */
+#define SD_CLUSTER_FLAG_DISKMODE	0x0002 /* Disk mode for cluster */
 
 enum sd_status {
 	SD_STATUS_OK = 1,
diff --git a/sheep/config.c b/sheep/config.c
index 9a0217b..77c6135 100644
--- a/sheep/config.c
+++ b/sheep/config.c
@@ -123,6 +123,12 @@ int init_config_file(void)
 reload:
 	ret = 0;
 	get_cluster_config(&sys->cinfo);
+	if ((config.flags & SD_CLUSTER_FLAG_DISKMODE) !=
+	    (sys->cinfo.flags & SD_CLUSTER_FLAG_DISKMODE)) {
+		sd_err("This sheep can't run because "
+		       "exists data format mismatch");
+		return -1;
+	}
 out:
 	close(fd);
 
diff --git a/sheep/sheep.c b/sheep/sheep.c
index 74d1aaf..c3b4c86 100644
--- a/sheep/sheep.c
+++ b/sheep/sheep.c
@@ -753,6 +753,10 @@ int main(int argc, char **argv)
 		}
 	}
 
+	#ifdef HAVE_DISKVNODES
+	sys->cinfo.flags |= SD_CLUSTER_FLAG_DISKMODE;
+	#endif
+
 	sheep_info.port = port;
 	early_log_init(log_format, &sheep_info);
 
-- 
1.7.12.4




More information about the sheepdog mailing list