Christine Caulfield wrote:
> In the light of comments I've made some changes to the quorum service.
>
> 1. It now loads it's provider module. using the key
> quorum.provider: name
> 2. Removed the internal API and added it to corosync_api_v1
> 3. It also loads its 'alter-ego' module that provides the library
> service so it doesn't need to be added to corosync.conf - simply
> specifying 'vsftype: quorum' will now work.
>
> Also attached, though not as part of the patch, is an example simple
> quorum service provider that changes quorum based on the quorum.quorate
> objdb variable. This can be toggled with corosync-objctl to test the
> features.
Hi Steve, I know you've been busy, but I held off submitting this until
I'd had feedback from you. Do you have any comments ?
Here's an updated patch but it's functionally identical to the previous one.
--
Chrissie
Index: trunk/services/confdb.c
===================================================================
--- trunk/services/confdb.c (revision 1690)
+++ trunk/services/confdb.c (working copy)
@@ -212,6 +212,7 @@
.id = CONFDB_SERVICE,
.private_data_size = 0,
.flow_control = CS_LIB_FLOW_CONTROL_NOT_REQUIRED,
+ .allow_inquorate = CS_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 1690)
+++ trunk/include/corosync/engine/coroapi.h (working copy)
@@ -495,6 +495,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 1690)
+++ 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 1690)
+++ trunk/exec/vsf_quorum.c (working copy)
@@ -60,6 +60,7 @@
#include <corosync/ipc_gen.h>
#include <corosync/ipc_quorum.h>
#include <corosync/lcr/lcr_comp.h>
+#include <corosync/lcr/lcr_ifact.h>
#include <corosync/engine/coroapi.h>
#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);
}
/* -------------------------------------------------- */
Index: trunk/exec/apidef.c
===================================================================
--- trunk/exec/apidef.c (revision 1690)
+++ 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/quorum.h
===================================================================
--- trunk/exec/quorum.h (revision 1690)
+++ 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 1690)
+++ 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 1690)
+++ 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/logsys.c
===================================================================
--- trunk/exec/logsys.c (revision 1690)
+++ trunk/exec/logsys.c (working copy)
@@ -436,6 +436,12 @@
pthread_mutex_unlock (&logsys_cond_mutex);
}
+static inline void wthread_wait_locked (void)
+{
+ pthread_cond_wait (&logsys_cond, &logsys_cond_mutex);
+ pthread_mutex_unlock (&logsys_cond_mutex);
+}
+
static void *logsys_worker_thread (void *data)
{
int log_msg;
@@ -503,13 +509,15 @@
pthread_mutex_init (&logsys_cond_mutex, NULL);
pthread_cond_init (&logsys_cond, NULL);
+ pthread_mutex_lock (&logsys_cond_mutex);
res = pthread_create (&logsys_thread_id, NULL,
logsys_worker_thread, NULL);
+
/*
* Wait for thread to be started
*/
- wthread_wait ();
+ wthread_wait_locked ();
}
/*
Index: trunk/exec/sync.h
===================================================================
--- trunk/exec/sync.h (revision 1690)
+++ 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
===================================================================
--- trunk/exec/main.c (revision 1690)
+++ trunk/exec/main.c (working copy)
@@ -709,7 +709,7 @@
}
- sync_register (corosync_sync_callbacks_retrieve, corosync_sync_completed,
+ sync_register (api, corosync_sync_callbacks_retrieve, corosync_sync_completed,
totem_config.vsf_type);
_______________________________________________
Openais mailing list
[email protected]
https://lists.linux-foundation.org/mailman/listinfo/openais