All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cluster-devel] [RESEND][PATCH] dlm: enhancing dlm_controld (pcmk) to be able to handle redundant rings
@ 2009-10-28  5:08 Jiaju Zhang
  2009-11-04 21:26 ` [Cluster-devel] " David Teigland
  0 siblings, 1 reply; 3+ messages in thread
From: Jiaju Zhang @ 2009-10-28  5:08 UTC (permalink / raw)
  To: cluster-devel.redhat.com

On Sat, Oct 24, 2009 at 4:51 AM, David Teigland <teigland@redhat.com>
wrote:
> On Fri, Oct 23, 2009 at 12:18:09PM -0700, Steven Dake wrote:
>> On Fri, 2009-10-23 at 12:55 -0500, David Teigland wrote:
>> > On Fri, Oct 23, 2009 at 09:23:20PM +0800, Jiaju Zhang wrote:
>> > +    result = corosync_cfg_ring_status_get(handle,
>> > +                                       &interface_names,
>> > +                                       &interface_status,
>> > +                                       &interface_count);
>> > +    if (result != CS_OK) {
>> > +       log_error("Failed to get the ring status (error=%d)",
>> > result);
>> > +       (void)corosync_cfg_finalize(handle);
>> > +       return -1;
>> > +    }
>> > +
>> > +    (void)corosync_cfg_finalize(handle);
>> > +    return interface_count;
>> >
>> > What is interface_count if there's one ring up but rrp is
>> > configured?
>> > Could we read the totem/rrp config value from the objdb?
>
>
>> Dave,
>>
>> The rrp mode can be read from the confdb currently.
>
> Ah, yeah, that's what I meant.

Hello David,

Per the discussion we had before, could we agree on the implementation
like below? Or what other aspect I need to improve?

BTW, if the auto-detect bits can't be merged into upstream, can the
command-line option bits be merged? Thanks a lot :-)

Thanks,
Jiaju

Signed-off-by: Jiaju Zhang <jjzhang.linux@gmail.com>
---
 configure.ac                   |    1 +
 group/dlm_controld/Makefile.am |    4 ++-
 group/dlm_controld/main.c      |    9 +++++-
 group/dlm_controld/pacemaker.c |   69 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 81 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac
index d50de87..3d9aaf6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -131,6 +131,7 @@ if test "x${enable_pacemaker}" = xyes; then
 	PKG_CHECK_MODULES([totempg],[libtotem_pg])
 	PKG_CHECK_MODULES([xml],[libxml-2.0])
 	PKG_CHECK_MODULES([glib],[glib-2.0])
+	PKG_CHECK_MODULES([confdb],[libconfdb])
 	check_lib_no_libs cib cib_new
 	check_lib_no_libs crmcluster crm_set_status_callback
 	check_lib_no_libs crmcommon init_server_ipc_comms
diff --git a/group/dlm_controld/Makefile.am b/group/dlm_controld/Makefile.am
index c14ab89..815ba53 100644
--- a/group/dlm_controld/Makefile.am
+++ b/group/dlm_controld/Makefile.am
@@ -62,12 +62,14 @@ dlm_controld_pcmk_CPPFLAGS= $(shared_CPPFLAGS) \
 dlm_controld_pcmk_CFLAGS  = $(shared_CFLAGS) \
 			    $(glib_CFLAGS) \
 			    $(xml_CFLAGS) \
-			    $(totempg_CFLAGS)
+			    $(totempg_CFLAGS) \
+			    $(confdb_CFLAGS)
 
 dlm_controld_pcmk_LDFLAGS = $(shared_LIBS) \
 			    $(glib_LIBS) \
 			    $(xml_LIBS) \
 			    $(totempg_LIBS) \
+			    $(confdb_LIBS) \
 			    -lcib -lcrmcommon -lcrmcluster
 
 dlm_controld_pcmk_LDADD	  = $(shared_LDADD)
diff --git a/group/dlm_controld/main.c b/group/dlm_controld/main.c
index f90cd21..5120866 100644
--- a/group/dlm_controld/main.c
+++ b/group/dlm_controld/main.c
@@ -1058,11 +1058,13 @@ static void print_usage(void)
 	printf("		Default is %u\n", DEFAULT_DROP_RESOURCES_COUNT);
 	printf("  -a <ms>	plock ownership drop resources age (milliseconds)\n");
 	printf("		Default is %u\n", DEFAULT_DROP_RESOURCES_AGE);
+	printf("  -r <num>      DLM in-kernel communication protocols: TCP(0), SCTP(1), DETECT(2)\n");
+	printf("                Default is auto-detect (2)");
 	printf("  -h		Print this help, then exit\n");
 	printf("  -V		Print program version information, then exit\n");
 }
 
-#define OPTION_STRING "LDKf:q:d:p:Pl:o:t:c:a:hV"
+#define OPTION_STRING "LDKf:q:d:p:Pl:o:t:c:a:r:hV"
 
 static void read_arguments(int argc, char **argv)
 {
@@ -1142,6 +1144,11 @@ static void read_arguments(int argc, char **argv)
 			cfgd_drop_resources_age = atoi(optarg);
 			break;
 
+		case 'r':
+			optk_protocol = 1;
+			cfgk_protocol = atoi(optarg);
+			break;
+
 		case 'h':
 			print_usage();
 			exit(EXIT_SUCCESS);
diff --git a/group/dlm_controld/pacemaker.c b/group/dlm_controld/pacemaker.c
index 810c644..9a5649a 100644
--- a/group/dlm_controld/pacemaker.c
+++ b/group/dlm_controld/pacemaker.c
@@ -22,7 +22,61 @@
 #include <pacemaker/crm/msg_xml.h>
 #include <pacemaker/crm/cib.h>
 
+#include <corosync/corotypes.h>
+#include <corosync/confdb.h>
+
 #define COMMS_DIR     "/sys/kernel/config/dlm/cluster/comms"
+#define PROTO_TCP     0
+#define PROTO_SCTP    1
+#define PROTO_DETECT  2
+
+static const char *get_rrp_mode(void)
+{
+    const char *rrp_mode = NULL;
+    int result;
+    confdb_handle_t handle;
+    hdb_handle_t totem_handle;
+    char key_value[256];
+    size_t value_len;
+    confdb_callbacks_t callbacks = {
+	.confdb_key_change_notify_fn = NULL,
+	.confdb_object_create_change_notify_fn = NULL,
+	.confdb_object_delete_change_notify_fn = NULL
+    };
+
+    result = confdb_initialize(&handle, &callbacks);
+    if (result != CS_OK) {
+	log_error("Could not initialize Cluster Configuration Database API instance error %d", result);
+	errno = EINVAL;
+	return NULL;
+    }
+
+    result = confdb_object_find_start(handle, OBJECT_PARENT_HANDLE);
+    if (result != CS_OK) {
+	log_error("Could not start object_find %d", result);
+	goto out;
+    }
+
+    result = confdb_object_find(handle, OBJECT_PARENT_HANDLE, "totem", strlen("totem"), &totem_handle);
+    if (result != CS_OK) {
+	log_error("Could not object_find \"totem\": %d", result);
+	goto out;
+    }
+
+    result = confdb_key_get(handle, totem_handle, "rrp_mode", strlen("rrp_mode"), key_value, &value_len);
+    if (result != CS_OK) {
+	log_error("Could not get \"rrp_mode\" key: %d", result);
+	goto out;
+    }
+    key_value[value_len] = '\0';
+    log_debug("totem/rrp_mode = '%s'", key_value);
+    
+    rrp_mode = strdup(key_value);
+
+out:
+    confdb_finalize(handle);
+    return rrp_mode;
+}
 
 int setup_ccs(void)
 {
@@ -30,6 +84,21 @@ int setup_ccs(void)
      * only allow configuration from the command-line until CoroSync is stable
      * enough to be used with Pacemaker
      */
+    if (cfgk_protocol != -1 && cfgk_protocol != PROTO_TCP &&
+	cfgk_protocol != PROTO_SCTP && cfgk_protocol != PROTO_DETECT) {
+	log_error("ignore invalid value %d for dlm protocol", cfgk_protocol);
+	cfgk_protocol = -1;
+    }
+
+    if (cfgk_protocol == PROTO_DETECT || cfgk_protocol == -1) {
+	const char *rrp_mode = get_rrp_mode();
+	if (strcmp(rrp_mode, "none"))
+	    cfgk_protocol = PROTO_SCTP;
+	else
+	    cfgk_protocol = PROTO_TCP;
+	free((void *)rrp_mode);
+    }
+
     return 0;
 }
 



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Cluster-devel] Re: [RESEND][PATCH] dlm: enhancing dlm_controld (pcmk) to be able to handle redundant rings
  2009-10-28  5:08 [Cluster-devel] [RESEND][PATCH] dlm: enhancing dlm_controld (pcmk) to be able to handle redundant rings Jiaju Zhang
@ 2009-11-04 21:26 ` David Teigland
  2009-11-05  9:18   ` Jiaju Zhang
  0 siblings, 1 reply; 3+ messages in thread
From: David Teigland @ 2009-11-04 21:26 UTC (permalink / raw)
  To: cluster-devel.redhat.com

On Wed, Oct 28, 2009 at 01:08:43PM +0800, Jiaju Zhang wrote:
> Hello David,
> 
> Per the discussion we had before, could we agree on the implementation
> like below? Or what other aspect I need to improve?
> 
> BTW, if the auto-detect bits can't be merged into upstream, can the
> command-line option bits be merged? Thanks a lot :-)

Hi, I've made some changes to the patch, and only tested that rrp_mode
none still results in tcp.  This patch is also for cluster.git STABLE3
branch, but I'll also push it to dlm.git if this works for you.
Dave


From e8c2ab811f02e891d6bc374b0d9aa43408d90456 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Wed, 4 Nov 2009 15:20:47 -0600
Subject: [PATCH] dlm_controld: detect lowcomms protocol

based on value of totem/rrp_mode in confdb.
Also allow protocol to be set on command line.

Based on initial patch from Jiaju Zhang <jjzhang.linux@gmail.com>

Signed-off-by: Jiaju Zhang <jjzhang.linux@gmail.com>
Signed-off-by: David Teigland <teigland@redhat.com>
---
 group/dlm_controld/action.c     |   64 ++++++++++++++++++++++++++++++++++++++-
 group/dlm_controld/config.c     |    7 ++--
 group/dlm_controld/dlm_daemon.h |    6 ++++
 group/dlm_controld/main.c       |   16 ++++++----
 4 files changed, 82 insertions(+), 11 deletions(-)

diff --git a/group/dlm_controld/action.c b/group/dlm_controld/action.c
index 229823b..1069418 100644
--- a/group/dlm_controld/action.c
+++ b/group/dlm_controld/action.c
@@ -1,6 +1,9 @@
 #include "dlm_daemon.h"
 #include "config.h"
 
+#include <corosync/corotypes.h>
+#include <corosync/confdb.h>
+
 static int dir_members[MAX_NODES];
 static int dir_members_count;
 static int comms_nodes[MAX_NODES];
@@ -12,6 +15,58 @@ static char mg_name[DLM_LOCKSPACE_LEN+1];
 #define SPACES_DIR    "/sys/kernel/config/dlm/cluster/spaces"
 #define COMMS_DIR     "/sys/kernel/config/dlm/cluster/comms"
 
+static int detect_protocol(void)
+{
+	confdb_handle_t handle;
+	hdb_handle_t totem_handle;
+	char key_value[256];
+	size_t value_len;
+	int rv, proto = -1;
+	confdb_callbacks_t callbacks = {
+		.confdb_key_change_notify_fn = NULL,
+		.confdb_object_create_change_notify_fn = NULL,
+		.confdb_object_delete_change_notify_fn = NULL
+	};
+
+	rv = confdb_initialize(&handle, &callbacks);
+	if (rv != CS_OK) {
+		log_error("confdb_initialize error %d", rv);
+		return -1; 
+	}
+
+	rv = confdb_object_find_start(handle, OBJECT_PARENT_HANDLE);
+	if (rv != CS_OK) {
+		log_error("confdb_object_find_start error %d", rv);
+		goto out;
+	}
+
+	rv = confdb_object_find(handle, OBJECT_PARENT_HANDLE,
+				"totem", strlen("totem"), &totem_handle);
+	if (rv != CS_OK) {
+		log_error("confdb_object_find error %d", rv);
+		goto out;
+	}
+
+	rv = confdb_key_get(handle, totem_handle,
+			    "rrp_mode", strlen("rrp_mode"),
+			    key_value, &value_len);
+	if (rv != CS_OK) {
+		log_error("confdb_key_get error %d", rv);
+		goto out;
+	}
+
+	key_value[value_len] = '\0';
+	log_debug("totem/rrp_mode = '%s'", key_value);
+
+	if (!strcmp(key_value, "none"))
+		proto = PROTO_TCP;
+	else
+		proto = PROTO_SCTP;
+ out:
+	confdb_finalize(handle);
+	return proto;
+}
+
 /* look for an id that matches in e.g. /sys/fs/gfs/bull\:x/lock_module/id
    and then extract the "x" as the name */
 
@@ -824,7 +879,14 @@ int setup_configfs(void)
 		set_configfs_debug(cfgk_debug);
 	if (cfgk_timewarn != -1)
 		set_configfs_timewarn(cfgk_timewarn);
-	if (cfgk_protocol != -1)
+
+	if (cfgk_protocol == PROTO_DETECT) {
+		rv = detect_protocol();
+		if (rv == PROTO_TCP || rv == PROTO_SCTP)
+			cfgk_protocol = rv;
+	}
+
+	if (cfgk_protocol == PROTO_TCP || cfgk_protocol == PROTO_SCTP)
 		set_configfs_protocol(cfgk_protocol);
 
 	return 0;
diff --git a/group/dlm_controld/config.c b/group/dlm_controld/config.c
index 16c4efb..1720e7a 100644
--- a/group/dlm_controld/config.c
+++ b/group/dlm_controld/config.c
@@ -25,9 +25,6 @@
 #include "config.h"
 #include "ccs.h"
 
-#define PROTO_TCP  0
-#define PROTO_SCTP 1
-
 int ccs_handle;
 
 /* when not set in cluster.conf, a node's default weight is 1 */
@@ -199,6 +196,8 @@ static void read_ccs_protocol(const char *path, int *config_val)
 		val = PROTO_TCP;
 	else if (!strncasecmp(str, "sctp", 4))
 		val = PROTO_SCTP;
+	else if (!strncasecmp(str, "detect", 6))
+		val = PROTO_DETECT;
 	else {
 		log_error("ignore invalid value %s for %s", str, path);
 		return;
@@ -235,6 +234,7 @@ int setup_ccs(void)
 {
 	int cd, rv;
 
+	/* skip things that cannot be changed while running */
 	if (ccs_handle)
 		goto update;
 
@@ -270,7 +270,6 @@ int setup_ccs(void)
 			read_ccs_int(GFS_PLOCK_OWNERSHIP_PATH, &cfgd_plock_ownership);
 	}
 
-
 	/* The following can be changed while running */
  update:
 	if (!optd_plock_debug) {
diff --git a/group/dlm_controld/dlm_daemon.h b/group/dlm_controld/dlm_daemon.h
index 0ca895a..dd6c7cc 100644
--- a/group/dlm_controld/dlm_daemon.h
+++ b/group/dlm_controld/dlm_daemon.h
@@ -66,6 +66,12 @@
 #define GROUP_LIBGROUP	2
 #define GROUP_LIBCPG	3
 
+/* cfgk_protocol */
+
+#define PROTO_TCP  0
+#define PROTO_SCTP 1
+#define PROTO_DETECT 2
+
 extern int daemon_debug_opt;
 extern int daemon_quit;
 extern int cluster_down;
diff --git a/group/dlm_controld/main.c b/group/dlm_controld/main.c
index 712bed6..af96527 100644
--- a/group/dlm_controld/main.c
+++ b/group/dlm_controld/main.c
@@ -1089,6 +1089,9 @@ static void print_usage(void)
 	printf("  -D		Enable debugging to stderr and don't fork\n");
 	printf("  -L		Enable debugging to log file\n");
 	printf("  -K		Enable kernel dlm debugging messages\n");
+	printf("  -r <num>	dlm kernel lowcomms protocol, 0 tcp, 1 sctp, 2 detect\n");
+	printf("                2 selects tcp if corosync rrp_mode is \"none\", otherwise sctp\n");
+	printf("                Default is 2\n");
 	printf("  -g <num>	groupd compatibility mode, 0 off, 1 on, 2 detect\n");
 	printf("		0: use libcpg, no backward compat, best performance\n");
 	printf("		1: use libgroup for compat with cluster2/rhel5\n");
@@ -1118,17 +1121,13 @@ static void print_usage(void)
 	printf("  -V		Print program version information, then exit\n");
 }
 
-#define OPTION_STRING "LDKg:f:q:d:p:Pl:o:t:c:a:hV"
+#define OPTION_STRING "LDKg:f:q:d:p:Pl:o:t:c:a:hVr:"
 
 static void read_arguments(int argc, char **argv)
 {
 	int cont = 1;
 	int optchar;
 
-	/* we don't allow these to be set on command line, should we? */
-	optk_timewarn = 0;
-	optk_timewarn = 0;
-
 	while (cont) {
 		optchar = getopt(argc, argv, OPTION_STRING);
 
@@ -1153,6 +1152,11 @@ static void read_arguments(int argc, char **argv)
 			cfgk_debug = 1;
 			break;
 
+		case 'r':
+			optk_protocol = 1;
+			cfgk_protocol = atoi(optarg);
+			break;
+
 		case 'f':
 			optd_enable_fencing = 1;
 			cfgd_enable_fencing = atoi(optarg);
@@ -1359,7 +1363,7 @@ int optd_drop_resources_age;
 
 int cfgk_debug                  = -1;
 int cfgk_timewarn               = -1;
-int cfgk_protocol               = -1;
+int cfgk_protocol               = PROTO_DETECT;
 int cfgd_groupd_compat          = DEFAULT_GROUPD_COMPAT;
 int cfgd_debug_logfile		= DEFAULT_DEBUG_LOGFILE;
 int cfgd_enable_fencing         = DEFAULT_ENABLE_FENCING;
-- 
1.5.5.6



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Cluster-devel] Re: [RESEND][PATCH] dlm: enhancing dlm_controld (pcmk) to be able to handle redundant rings
  2009-11-04 21:26 ` [Cluster-devel] " David Teigland
@ 2009-11-05  9:18   ` Jiaju Zhang
  0 siblings, 0 replies; 3+ messages in thread
From: Jiaju Zhang @ 2009-11-05  9:18 UTC (permalink / raw)
  To: cluster-devel.redhat.com

On Thu, Nov 5, 2009 at 5:26 AM, David Teigland <teigland@redhat.com> wrote:
> On Wed, Oct 28, 2009 at 01:08:43PM +0800, Jiaju Zhang wrote:
>> Hello David,
>>
>> Per the discussion we had before, could we agree on the implementation
>> like below? Or what other aspect I need to improve?
>>
>> BTW, if the auto-detect bits can't be merged into upstream, can the
>> command-line option bits be merged? Thanks a lot :-)
>
> Hi, I've made some changes to the patch, and only tested that rrp_mode
> none still results in tcp. ?This patch is also for cluster.git STABLE3
> branch, but I'll also push it to dlm.git if this works for you.

Thanks Dave! It works for me:-)

Thanks,
Jiaju



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-11-05  9:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-28  5:08 [Cluster-devel] [RESEND][PATCH] dlm: enhancing dlm_controld (pcmk) to be able to handle redundant rings Jiaju Zhang
2009-11-04 21:26 ` [Cluster-devel] " David Teigland
2009-11-05  9:18   ` Jiaju Zhang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.