Index: trunk/services/confdb.c =================================================================== --- trunk/services/confdb.c (revision 1686) +++ trunk/services/confdb.c (working copy) @@ -212,6 +212,7 @@ .id = CONFDB_SERVICE, .private_data_size = 0, .flow_control = COROSYNC_LIB_FLOW_CONTROL_NOT_REQUIRED, + .allow_inquorate = COROSYNC_LIB_ALLOW_INQUORATE, .lib_init_fn = confdb_lib_init_fn, .lib_exit_fn = confdb_lib_exit_fn, .lib_engine = confdb_lib_engine, Index: trunk/include/corosync/engine/coroapi.h =================================================================== --- trunk/include/corosync/engine/coroapi.h (revision 1686) +++ trunk/include/corosync/engine/coroapi.h (working copy) @@ -486,6 +486,8 @@ int (*sync_request) ( char *service_name); + int (*sync_primary_designated) (void); + /* * Plugin loading and unloading */ Index: trunk/exec/vsf.h =================================================================== --- trunk/exec/vsf.h (revision 1686) +++ trunk/exec/vsf.h (working copy) @@ -34,12 +34,14 @@ #ifndef VSF_H_DEFINED #define VSF_H_DEFINED +struct corosync_api_v1; struct corosync_vsf_iface_ver0 { /* * Executes a callback whenever component changes */ int (*init) ( + struct corosync_api_v1 *api, void (*primary_callback_fn) ( unsigned int *view_list, int view_list_entries, Index: trunk/exec/vsf_quorum.c =================================================================== --- trunk/exec/vsf_quorum.c (revision 1686) +++ trunk/exec/vsf_quorum.c (working copy) @@ -60,6 +60,7 @@ #include #include #include +#include #include #include "vsf.h" @@ -88,6 +89,7 @@ static struct memb_ring_id quorum_ring_id; static int quorum_view_list_entries = 0; static int quorum_view_list[PROCESSOR_COUNT_MAX]; +struct quorum_services_api_ver1 *quorum_iface = NULL; static void (*quorum_primary_callback_fn) ( unsigned int *view_list, @@ -101,7 +103,7 @@ int quorum, struct memb_ring_id *ring_id) { primary_designated = quorum; - memcpy(&quorum_ring_id, &ring_id, sizeof (quorum_ring_id)); + memcpy(&quorum_ring_id, ring_id, sizeof (quorum_ring_id)); quorum_view_list_entries = view_list_entries; memcpy(quorum_view_list, view_list, sizeof(unsigned int)*view_list_entries); @@ -114,20 +116,66 @@ send_quorum_notification(NULL); } +/* Register with sync service */ static int quorum_init ( + struct corosync_api_v1 *api, void (*primary_callback_fn) ( unsigned int *view_list, int view_list_entries, int primary_designated, struct memb_ring_id *ring_id)) { + unsigned int find_handle; + unsigned int quorum_handle = 0; + unsigned int q_handle; + char *quorum_module; + int res; + void *quorum_iface_p; + quorum_primary_callback_fn = primary_callback_fn; + /* Load the library-servicing part of this module */ + api->service_link_and_init(api, "corosync_quorum", 0); + + /* Look for a quorum provider */ + api->object_find_create(OBJECT_PARENT_HANDLE, "quorum", strlen("quorum"), &find_handle); + api->object_find_next(find_handle, &quorum_handle); + api->object_find_destroy(find_handle); + + if (quorum_handle) { + if ( !(res = api->object_key_get(quorum_handle, + "provider", + strlen("provider"), + (void *)&quorum_module, + NULL))) { + + res = lcr_ifact_reference ( + &q_handle, + quorum_module, + 0, + &quorum_iface_p, + 0); + + if (res == -1) { + log_printf (LOG_LEVEL_NOTICE, + "Couldn't load quorum provider %s\n", + quorum_module); + return (-1); + } + + log_printf (LOG_LEVEL_NOTICE, + "Using quorum provider %s\n", quorum_module); + + quorum_iface = (struct quorum_services_api_ver1 *)quorum_iface_p; + quorum_iface->init (api, quorum_api_set_quorum); + } + } + return (0); } /* - * Returns 1 if this processor is in the primary (has quorum) + * Returns 1 to sync if this processor has quorum */ static int quorum_primary (void) { @@ -142,10 +190,6 @@ .primary = quorum_primary }; -static struct quorum_services_api_ver1 quorum_service_api_v1 = { - .quorum_api_set_quorum = quorum_api_set_quorum -}; - static struct corosync_lib_handler quorum_lib_service[] = { { /* 0 */ @@ -181,7 +225,7 @@ .lib_engine_count = sizeof (quorum_lib_service) / sizeof (struct corosync_lib_handler), }; -static struct lcr_iface corosync_vsf_quorum_ver0[3] = { +static struct lcr_iface corosync_vsf_quorum_ver0[2] = { { /* the VSF handler */ .name = "corosync_vsf_quorum", .version = 0, @@ -193,18 +237,7 @@ .destructor = NULL, .interfaces = (void **)(void *)&vsf_quorum_iface_ver0, }, - { /* API for quorum users to call */ - .name = "corosync_quorum_api", - .version = 0, - .versions_replace = 0, - .versions_replace_count = 0, - .dependencies = 0, - .dependency_count = 0, - .constructor = NULL, - .destructor = NULL, - .interfaces = NULL - }, - { /* Library calls */ + { /* Library & exec calls */ .name = "corosync_quorum", .version = 0, .versions_replace = 0, @@ -224,7 +257,7 @@ } static struct lcr_comp vsf_quorum_comp_ver0 = { - .iface_count = 3, + .iface_count = 2, .ifaces = corosync_vsf_quorum_ver0 }; @@ -235,8 +268,7 @@ __attribute__ ((constructor)) static void vsf_quorum_comp_register (void) { lcr_component_register (&vsf_quorum_comp_ver0); lcr_interfaces_set (&corosync_vsf_quorum_ver0[0], &vsf_quorum_iface_ver0); - lcr_interfaces_set (&corosync_vsf_quorum_ver0[1], &quorum_service_api_v1); - lcr_interfaces_set (&corosync_vsf_quorum_ver0[2], &quorum_service_handler_iface); + lcr_interfaces_set (&corosync_vsf_quorum_ver0[1], &quorum_service_handler_iface); } /* -------------------------------------------------- */ @@ -245,6 +277,7 @@ { corosync_api = api; list_init (&trackers_list); + return (0); } Index: trunk/exec/apidef.c =================================================================== --- trunk/exec/apidef.c (revision 1686) +++ trunk/exec/apidef.c (working copy) @@ -101,6 +101,7 @@ .tpg_groups_mcast = (typedef_tpg_groups_mcast)totempg_groups_mcast_groups, .tpg_groups_send_ok = (typedef_tpg_groups_send_ok)totempg_groups_send_ok_groups, .sync_request = sync_request, + .sync_primary_designated = sync_primary_designated, .service_link_and_init = corosync_service_link_and_init, .service_unlink_and_exit = corosync_service_unlink_and_exit, .plugin_interface_reference = lcr_ifact_reference, Index: trunk/exec/Makefile =================================================================== --- trunk/exec/Makefile (revision 1686) +++ trunk/exec/Makefile (working copy) @@ -107,6 +107,9 @@ objdb.lcrso: objdb.o $(CC) -shared -Wl,-soname,objdb.lcrso objdb.o -o $@ +testquorum.lcrso: testquorum.o + $(CC) -shared -Wl,-soname,testquorum.lcrso objdb.o -o $@ + coroparse.lcrso: coroparse.o $(CC) -shared -Wl,-soname,coroparse.lcrso coroparse.o -o $@ endif @@ -160,6 +163,9 @@ objdb.o: objdb.c $(CC) $(CFLAGS) -c -o $@ $< +testquorum.o: testquorum.c + $(CC) $(CFLAGS) -c -o $@ $< + coroparse.o: coroparse.c $(CC) $(CFLAGS) -c -o $@ $< Index: trunk/exec/quorum.h =================================================================== --- trunk/exec/quorum.h (revision 1686) +++ trunk/exec/quorum.h (working copy) @@ -35,41 +35,10 @@ #ifndef QUORUM_H_DEFINED #define QUORUM_H_DEFINED -struct quorum_services_api_ver1 { - void (*quorum_api_set_quorum) (unsigned int *,int, - int, struct memb_ring_id *); - }; +typedef void (*quorum_set_quorate_fn_t) (unsigned int *view_list, int view_list_entries, + int quorate, struct memb_ring_id *); -static inline struct quorum_services_api_ver1 * -quorum_services_api_reference ( - struct corosync_api_v1 *coroapi, - unsigned int *handle) -{ - static void *quorum_services_api_p; - struct quorum_services_api_ver1 *return_api; - unsigned int res; - - res = coroapi->plugin_interface_reference ( - handle, - "quorum_services_api", - 0, - &quorum_services_api_p, - 0); - if (res == -1) { - return (NULL); - } - return_api = (struct quorum_services_api_ver1 *)quorum_services_api_p; - return (return_api); -} - -static int inline quorum_services_api_release ( - struct corosync_api_v1 *coroapi, - unsigned int handle) -{ - unsigned int res; - - res = coroapi->plugin_interface_release (handle); - return (res); -} - +struct quorum_services_api_ver1 { + void (*init) (struct corosync_api_v1 *api, quorum_set_quorate_fn_t); +}; #endif /* QUORUM_H_DEFINED */ Index: trunk/exec/vsf_ykd.c =================================================================== --- trunk/exec/vsf_ykd.c (revision 1686) +++ trunk/exec/vsf_ykd.c (working copy) @@ -499,6 +499,7 @@ }; static int ykd_init ( + struct corosync_api_v1 *api, void (*primary_callback_fn) ( unsigned int *view_list, int view_list_entries, Index: trunk/exec/sync.c =================================================================== --- trunk/exec/sync.c (revision 1686) +++ trunk/exec/sync.c (working copy) @@ -265,6 +265,7 @@ } int sync_register ( + struct corosync_api_v1 *api, int (*callbacks_retrieve) (int sync_id, struct sync_callbacks *callack), void (*synchronization_completed) (void), char *vsf_type) @@ -319,7 +320,7 @@ "Using virtual synchrony filter %s\n", corosync_vsf_type); vsf_iface = (struct corosync_vsf_iface_ver0 *)vsf_iface_p; - vsf_iface->init (sync_primary_callback_fn); + vsf_iface->init (api, sync_primary_callback_fn); } sync_callbacks_retrieve = callbacks_retrieve; Index: trunk/exec/sync.h =================================================================== --- trunk/exec/sync.h (revision 1686) +++ trunk/exec/sync.h (working copy) @@ -47,7 +47,9 @@ char *name; }; +struct corosync_api_v1; int sync_register ( + struct corosync_api_v1 *api, int (*sync_callbacks_retrieve) (int sync_id, struct sync_callbacks *callbacks), void (*synchronization_completed) (void), char *vsf_type); Index: trunk/exec/main.c