[sheepdog] [PATCH] sheep: define DEFAULT_CLUSTER_DRIVER

MORITA Kazutaka morita.kazutaka at gmail.com
Fri Jul 12 22:17:04 CEST 2013


From: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>

This simplifies group.c a bit and corrects the help message about the
default cluster driver when we don't compile a corosync driver.  In
addition, this would help us to switch the default driver easily if we
would change the default in future.

Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 sheep/cluster.h |    7 +++++++
 sheep/group.c   |   11 +++--------
 sheep/sheep.c   |    3 ++-
 3 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/sheep/cluster.h b/sheep/cluster.h
index 3760001..041578b 100644
--- a/sheep/cluster.h
+++ b/sheep/cluster.h
@@ -22,6 +22,7 @@
 #include "sheepdog_proto.h"
 #include "sheep.h"
 #include "logger.h"
+#include "config.h"
 
 /* maximum payload size sent in ->notify and ->unblock */
 #define SD_MAX_EVENT_BUF_SIZE (128 * 1024) /* 128k */
@@ -117,6 +118,12 @@ struct cluster_driver {
 
 extern struct list_head cluster_drivers;
 
+#ifdef HAVE_COROSYNC
+#define DEFAULT_CLUSTER_DRIVER "corosync"
+#else
+#define DEFAULT_CLUSTER_DRIVER "local"
+#endif /* HAVE_COROSYNC */
+
 #define cdrv_register(driver)						\
 static void __attribute__((constructor)) regist_ ## driver(void)	\
 {									\
diff --git a/sheep/group.c b/sheep/group.c
index 473c8d8..35eaf68 100644
--- a/sheep/group.c
+++ b/sheep/group.c
@@ -1126,14 +1126,9 @@ int create_cluster(int port, int64_t zone, int nr_vnodes,
 	int ret;
 
 	if (!sys->cdrv) {
-		sys->cdrv = find_cdrv("corosync");
-		if (sys->cdrv)
-			sd_dprintf("use corosync cluster driver as default");
-		else {
-			/* corosync cluster driver is not compiled */
-			sys->cdrv = find_cdrv("local");
-			sd_dprintf("use local cluster driver as default");
-		}
+		sys->cdrv = find_cdrv(DEFAULT_CLUSTER_DRIVER);
+		sd_dprintf("use %s cluster driver as default",
+			   DEFAULT_CLUSTER_DRIVER);
 	}
 
 	ret = sys->cdrv->init(sys->cdrv_option);
diff --git a/sheep/sheep.c b/sheep/sheep.c
index 64a7298..b1d8294 100644
--- a/sheep/sheep.c
+++ b/sheep/sheep.c
@@ -98,7 +98,8 @@ static const char cache_help[] =
 static struct sd_option sheep_options[] = {
 	{'b', "bindaddr", true, "specify IP address of interface to listen on",
 	 bind_help},
-	{'c', "cluster", true, "specify the cluster driver (default: corosync)",
+	{'c', "cluster", true,
+	 "specify the cluster driver (default: "DEFAULT_CLUSTER_DRIVER")",
 	 cluster_help},
 	{'d', "debug", false, "include debug messages in the log"},
 	{'D', "directio", false, "use direct IO for backend store"},
-- 
1.7.9.5




More information about the sheepdog mailing list