On 1/16/2012 8:59 AM, Fabio M. Di Nitto wrote: > The patch works but it introduces a regression. I´ll send you another > one soon. > > Fabio This one in attachment should do. Fabio
commit 892d883b5c4eb5719f2c0dcf6863baf9986158d4 Author: Fabio M. Di Nitto <fdinitto@xxxxxxxxxx> Date: Mon Jan 16 09:20:30 2012 +0100 Finish quorum module support changes based on Steven's patch, this one adds a better API to call into votequorum_init and fixes a regression in vsf_quorum init ordering Signed-off-by: Fabio M. Di Nitto <fdinitto@xxxxxxxxxx> diff --git a/exec/Makefile.am b/exec/Makefile.am index 0bb3a64..ae28f31 100644 --- a/exec/Makefile.am +++ b/exec/Makefile.am @@ -67,7 +67,7 @@ noinst_HEADERS = apidef.h crypto.h mainconfig.h main.h \ quorum.h service.h sync.h timer.h totemconfig.h \ totemmrp.h totemnet.h totemudp.h totemiba.h totemrrp.h \ totemudpu.h totemsrp.h util.h vsf.h schedwrk.h \ - evil.h syncv2.h fsm.h + evil.h syncv2.h fsm.h votequorum.h if BUILD_DARWIN libtotem_pg.so.$(SONAME): $(TOTEM_OBJS) diff --git a/exec/service.c b/exec/service.c index 787b289..ed2f3fb 100644 --- a/exec/service.c +++ b/exec/service.c @@ -99,13 +99,16 @@ static struct default_service default_services[] = { .loader = wd_get_service_engine_ver0 }, #endif -#ifdef HAVE_VOTEQUORUM { - .name = "corosync_quorum", + .name = "corosync_votequorum", .ver = 0, .loader = votequorum_get_service_engine_ver0 }, -#endif + { + .name = "corosync_quorum", + .ver = 0, + .loader = vsf_quorum_get_service_engine_ver0 + }, { .name = "corosync_cmap", .ver = 0, diff --git a/exec/service.h b/exec/service.h index 33d6053..5309174 100644 --- a/exec/service.h +++ b/exec/service.h @@ -77,6 +77,8 @@ extern const char *service_stats_rx[SERVICE_HANDLER_MAXIMUM_COUNT][64]; extern const char *service_stats_tx[SERVICE_HANDLER_MAXIMUM_COUNT][64]; struct corosync_service_engine *votequorum_get_service_engine_ver0 (void); +struct corosync_service_engine *vsf_quorum_get_service_engine_ver0 (void); +struct corosync_service_engine *quorum_get_service_handler_ver0 (void); struct corosync_service_engine *pload_get_service_engine_ver0 (void); struct corosync_service_engine *cfg_get_service_engine_ver0 (void); struct corosync_service_engine *evs_get_service_engine_ver0 (void); diff --git a/exec/votequorum.c b/exec/votequorum.c index 6e7d852..773454b 100644 --- a/exec/votequorum.c +++ b/exec/votequorum.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2011 Red Hat, Inc. + * Copyright (c) 2009-2012 Red Hat, Inc. * * All rights reserved. * @@ -71,6 +71,8 @@ #include <corosync/icmap.h> #include <corosync/ipc_votequorum.h> +#include "votequorum.h" + #define VOTEQUORUM_MAJOR_VERSION 7 #define VOTEQUORUM_MINOR_VERSION 0 #define VOTEQUORUM_PATCH_VERSION 0 @@ -161,9 +163,6 @@ struct quorum_pd { * Service Interfaces required by service_message_handler struct */ -static void votequorum_init(struct corosync_api_v1 *api, - quorum_set_quorate_fn_t report); - static void quorum_confchg_fn ( enum totem_configuration_type configuration_type, const unsigned int *member_list, size_t member_list_entries, @@ -300,11 +299,15 @@ struct corosync_service_engine *votequorum_get_service_engine_ver0 (void) return (&quorum_service_handler); } -static void votequorum_init(struct corosync_api_v1 *api, +cs_error_t votequorum_init(struct corosync_api_v1 *api, quorum_set_quorate_fn_t report) { ENTER(); + if ((!api) || (!report)) { + return CS_ERR_INVALID_PARAM; + } + set_quorum = report; icmap_get_uint8("quorum.wait_for_all", &wait_for_all); @@ -325,10 +328,9 @@ static void votequorum_init(struct corosync_api_v1 *api, wait_for_all_status = 1; } - /* Load the library-servicing part of this module */ - api->service_link_and_init(api, "corosync_votequorum_iface", 0); - LEAVE(); + + return CS_OK; } struct req_exec_quorum_nodeinfo { diff --git a/exec/votequorum.h b/exec/votequorum.h new file mode 100644 index 0000000..fbeaada --- /dev/null +++ b/exec/votequorum.h @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2012 Red Hat, Inc. + * + * All rights reserved. + * + * Author: Fabio M. Di Nitto (fdinitto@xxxxxxxxxx) + * + * This software licensed under BSD license, the text of which follows: + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * - Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * - Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * - Neither the name of the MontaVista Software, Inc. nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef VOTEQUORUM_H_DEFINED +#define VOTEQUORUM_H_DEFINED + +#include <corosync/logsys.h> +#include <corosync/list.h> +#include <corosync/coroapi.h> + +extern cs_error_t votequorum_init(struct corosync_api_v1 *api, + quorum_set_quorate_fn_t report); + +#endif /* VOTEQUORUM_H_DEFINED */ diff --git a/exec/vsf_quorum.c b/exec/vsf_quorum.c index bef65fd..c258c14 100644 --- a/exec/vsf_quorum.c +++ b/exec/vsf_quorum.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009 Red Hat, Inc. + * Copyright (c) 2008, 2009, 2012 Red Hat, Inc. * * All rights reserved. * @@ -67,6 +67,8 @@ #include <corosync/engine/quorum.h> #include <corosync/icmap.h> +#include "votequorum.h" + LOGSYS_DECLARE_SUBSYS ("QUORUM"); struct quorum_pd { @@ -193,7 +195,7 @@ static struct corosync_service_engine quorum_service_handler = { .sync_mode = CS_SYNC_V1 }; -static struct corosync_service_engine *quorum_get_service_handler_ver0 (void) +struct corosync_service_engine *vsf_quorum_get_service_engine_ver0 (void) { return (&quorum_service_handler); } @@ -250,17 +252,11 @@ static struct quorum_callin_functions callins = { static int quorum_exec_init_fn (struct corosync_api_v1 *api) { - hdb_handle_t q_handle; char *quorum_module; - int res; - void *quorum_iface_p; - void* _start; - void* _stop; #ifdef COROSYNC_SOLARIS logsys_subsys_init(); #endif -#ifdef SDAKE corosync_api = api; list_init (&lib_trackers_list); list_init (&internal_trackers_list); @@ -274,45 +270,25 @@ static int quorum_exec_init_fn (struct corosync_api_v1 *api) * Look for a quorum provider */ if (icmap_get_string("quorum.provider", &quorum_module) == CS_OK) { - res = lcr_ifact_reference ( - &q_handle, - quorum_module, - 0, - &quorum_iface_p, - 0); - - if (res == -1) { - log_printf (LOGSYS_LEVEL_NOTICE, - "Couldn't load quorum provider %s\n", - quorum_module); - free(quorum_module); - return (-1); - } - log_printf (LOGSYS_LEVEL_NOTICE, "Using quorum provider %s\n", quorum_module); - /* - * Register the log sites with libqb - */ - _start = lcr_ifact_addr_get(q_handle, "__start___verbose"); - _stop = lcr_ifact_addr_get(q_handle, "__stop___verbose"); - qb_log_callsites_register(_start, _stop); - - quorum_iface = (struct quorum_services_api_ver1 *)quorum_iface_p; - quorum_iface->init (api, quorum_api_set_quorum); - quorum_type = 1; - free(quorum_module); + if (strcmp (quorum_module, "corosync_votequorum") == 0) { + if (votequorum_init (api, quorum_api_set_quorum) == CS_OK) { + quorum_type = 1; + } + } } - if (!quorum_iface) { - /* - * With no quorum provider, we are always quorate - */ + + /* + * setting quorum_type and primary_designated in the right order is important + * always try to lookup/init a quorum module, then revert back to be quorate + */ + + if (quorum_type == 0) { primary_designated = 1; - quorum_type = 0; } -#endif return (0); }
_______________________________________________ discuss mailing list discuss@xxxxxxxxxxxx http://lists.corosync.org/mailman/listinfo/discuss