[Cluster-devel] [RESEND][PATCH] dlm: enhancing dlm_controld (pcmk) to be able to handle redundant rings
Jiaju Zhang
jjzhang.linux at gmail.com
Wed Oct 28 05:08:43 UTC 2009
On Sat, Oct 24, 2009 at 4:51 AM, David Teigland <teigland at 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 at 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;
}
More information about the Cluster-devel
mailing list