Pārlūkot izejas kodu

scale part 3
componentize YKD dynamic linear voting algorithm


git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@982 fd59a12c-fef9-0310-b244-a6a79926bd2f

Steven Dake 20 gadi atpakaļ
vecāks
revīzija
dd18b864d8
6 mainītis faili ar 92 papildinājumiem un 81 dzēšanām
  1. 16 6
      exec/Makefile
  2. 1 2
      exec/main.c
  3. 28 8
      exec/sync.c
  4. 2 0
      exec/sync.h
  5. 45 13
      exec/vsf_ykd.c
  6. 0 52
      exec/ykd.h

+ 16 - 6
exec/Makefile

@@ -52,15 +52,15 @@ TOTEM_SRC = aispoll.c totemip.c totemnet.c totemrrp.c totemsrp.c totemmrp.c tote
 TOTEM_OBJS = aispoll.o totemip.o totemnet.o totemrrp.o totemsrp.o totemmrp.o totempg.o tlist.o crypto.o wthread.o
 EXEC_LIBS = libtotem_pg.a
 
-# service handler objects
-SERV_SRC = evs.c clm.c amf.c ckpt.c evt.c lck.c msg.c cfg.c cpg.c amfconfig.c aisparser.c
-SERV_OBJS = evs.o clm.o amf.o ckpt.o evt.o lck.o msg.o cfg.o cpg.o amfconfig.o aisparser.o
+# LCR objects
+LCR_SRC = evs.c clm.c amf.c ckpt.c evt.c lck.c msg.c cfg.c cpg.c amfconfig.c aisparser.c vsf_ykd.c
+LCR_OBJS = evs.o clm.o amf.o ckpt.o evt.o lck.o msg.o cfg.o cpg.o amfconfig.o aisparser.o vsf_ykd.o
 
 # main executive objects
 MAIN_SRC = main.c print.c mempool.c \
 		util.c sync.c ykd.c service.c totemconfig.c mainconfig.c
 MAIN_OBJS = main.o print.o mempool.o \
-		util.o sync.o ykd.o  service.o totemconfig.o mainconfig.o ../lcr/lcr_ifact.o
+		util.o sync.o service.o totemconfig.o mainconfig.o ../lcr/lcr_ifact.o
 OTHER_OBJS = objdb.o
 
 ifeq (${BUILD_DYNAMIC}, 1) 
@@ -72,9 +72,9 @@ all:libtotem_pg.a libtotem_pg.so.1.0 ../lcr/lcr_ifact.o \
 	service_evs.lcrso service_clm.lcrso service_amf.lcrso \
 	service_ckpt.lcrso service_evt.lcrso service_lck.lcrso \
 	service_msg.lcrso service_cfg.lcrso service_cpg.lcrso \
-	objdb.lcrso aisparser.lcrso keygen openais-instantiate
+	objdb.lcrso aisparser.lcrso vsf_ykd.lcrso keygen openais-instantiate
 else
-EXEC_OBJS = $(TOTEM_OBJS) $(MAIN_OBJS) $(OTHER_OBJS) $(SERV_OBJS)
+EXEC_OBJS = $(TOTEM_OBJS) $(MAIN_OBJS) $(OTHER_OBJS) $(LCR_OBJS)
 all: libtotem_pg.a aisexec keygen openais-instantiate
 endif
 
@@ -114,6 +114,10 @@ aisparser.lcrso: aisparser.o
 objdb.lcrso: objdb.o
 	$(CC) -bundle -bundle_loader ./aisexec -bind_at_load objdb.o -o $@
 
+vsf_ykd.lcrso: vsf_ykd.o
+	$(CC) $(LDFLAGS) -bundle $(LDFLAGS) -bundle_loader ./aisexec -bind_at_load vsf_ykd.o -o $@
+
+
 else
 
 service_evs.lcrso: evs.o
@@ -146,6 +150,9 @@ service_cpg.lcrso: cpg.o
 aisparser.lcrso: aisparser.o
 	$(CC) -shared -Wl,-soname,aisparser.lcrso aisparser.o -o $@
 
+vsf_ykd.lcrso: vsf_ykd.o
+	$(CC) -shared -Wl,-soname,vsf_ykd.lcrso vsf_ykd.o -o $@
+
 objdb.lcrso: objdb.o
 	$(CC) -shared -Wl,-soname,objdb.lcrso objdb.o -o $@
 
@@ -218,6 +225,9 @@ cfg.o: cfg.c
 aisparser.o: aisparser.c
 	$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $(*F).c
 
+vsf_ykd.o: vsf_ykd.c
+	$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $(*F).c
+
 cpg.o: cpg.c
 	$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $(*F).c
 

+ 1 - 2
exec/main.c

@@ -69,7 +69,6 @@
 #include "main.h"
 #include "service.h"
 #include "sync.h"
-#include "ykd.h"
 #include "swab.h"
 #include "objdb.h"
 #include "config.h"
@@ -801,7 +800,7 @@ retry_recv:
 				&send_ok_joined_iovec, 1);
 
 			send_ok =
-				(ykd_primary() == 1) && (
+				(sync_primary_designated() == 1) && (
 				(ais_service[service]->lib_service[header->id].flow_control == OPENAIS_FLOW_CONTROL_NOT_REQUIRED) ||
 				((ais_service[service]->lib_service[header->id].flow_control == OPENAIS_FLOW_CONTROL_REQUIRED) &&
 				(send_ok_joined) &&

+ 28 - 8
exec/sync.c

@@ -54,11 +54,13 @@
 #include "totempg.h"
 #include "totemip.h"
 #include "totem.h"
-#include "ykd.h"
-#include "print.h"
+#include "vsf.h"
 #include "swab.h"
 
+#include "../lcr/lcr_ifact.h"
+
 #define LOG_SERVICE LOG_SERVICE_SYNC
+#include "print.h"
 
 #define MESSAGE_REQ_SYNC_BARRIER 0
 
@@ -89,6 +91,8 @@ static int barrier_data_confchg_entries;
 
 static struct barrier_data barrier_data_process[PROCESSOR_COUNT_MAX];
 
+static struct openais_vsf_iface_ver0 *vsf_iface;
+
 static int sync_barrier_send (struct memb_ring_id *ring_id);
 
 static int sync_start_process (enum totem_callback_token_type type, void *data);
@@ -103,14 +107,14 @@ static void sync_deliver_fn (
 	int iov_len,
 	int endian_conversion_required);
 
-void sync_confchg_fn (
+static void sync_confchg_fn (
 	enum totem_configuration_type configuration_type,
 	struct totem_ip_address *member_list, int member_list_entries,
 	struct totem_ip_address *left_list, int left_list_entries,
 	struct totem_ip_address *joined_list, int joined_list_entries,
 	struct memb_ring_id *ring_id);
 
-void sync_primary_callback_fn (
+static void sync_primary_callback_fn (
 	struct totem_ip_address *view_list,
 	int view_list_entries,
 	int primary_designated,
@@ -262,6 +266,9 @@ void sync_register (
 	int (*callbacks_retrieve) (int sync_id, struct sync_callbacks *callack),
 	void (*synchronization_completed) (void))
 {
+	unsigned int res;
+	unsigned int ykd_handle;
+
 	totempg_groups_initialize (
 		&sync_group_handle,
 		sync_deliver_fn,
@@ -272,13 +279,21 @@ void sync_register (
 		&sync_group,
 		1);
 
-	ykd_init (sync_primary_callback_fn);
+
+	res = lcr_ifact_reference (
+		&ykd_handle,
+		"openais_vsf_ykd",
+		0,
+		(void **)(void *)&vsf_iface,
+		0);
+
+	vsf_iface->init (sync_primary_callback_fn);
 
 	sync_callbacks_retrieve = callbacks_retrieve;
 	sync_synchronization_completed = synchronization_completed;
 }
 
-void sync_primary_callback_fn (
+static void sync_primary_callback_fn (
 	struct totem_ip_address *view_list,
 	int view_list_entries,
 	int primary_designated,
@@ -323,7 +338,7 @@ void sync_endian_convert (struct req_exec_sync_barrier_start *req_exec_sync_barr
 
 }
 
-void sync_deliver_fn (
+static void sync_deliver_fn (
 	struct totem_ip_address *source_addr,
 	struct iovec *iovec,
 	int iov_len,
@@ -400,7 +415,7 @@ void sync_deliver_fn (
 	return;
 }
 
-void sync_confchg_fn (
+static void sync_confchg_fn (
 	enum totem_configuration_type configuration_type,
 	struct totem_ip_address *member_list, int member_list_entries,
 	struct totem_ip_address *left_list, int left_list_entries,
@@ -415,3 +430,8 @@ int sync_in_process (void)
 {
 	return (sync_processing);
 }
+
+int sync_primary_designated (void)
+{
+	return (vsf_iface->primary());
+}

+ 2 - 0
exec/sync.h

@@ -53,4 +53,6 @@ void sync_register (
 
 int sync_in_process (void);
 
+int sync_primary_designated (void);
+
 #endif /* SYNC_H_DEFINED */

+ 45 - 13
exec/ykd.c → exec/vsf_ykd.c

@@ -1,7 +1,6 @@
 /*
- * vi: set autoindent tabstop=4 shiftwidth=4 :
- *
  * Copyright (c) 2005 MontaVista Software, Inc.
+ * Copyright (c) 2006 Red Hat, Inc.
  *
  * All rights reserved.
  *
@@ -58,6 +57,9 @@
 #include "main.h"
 #include "print.h"
 #include "swab.h"
+#include "vsf.h"
+
+#include "../lcr/lcr_comp.h"
 
 #define LOG_SERVICE LOG_SERVICE_YKD
 
@@ -150,7 +152,7 @@ void ykd_state_init (void)
 	ykd_state.last_primary.member_list_entries = 0;
 }
 
-int ykd_state_send_msg (enum totem_callback_token_type type, void *context)
+static int ykd_state_send_msg (enum totem_callback_token_type type, void *context)
 {
 	struct iovec iovec[2];
 	struct ykd_header header;
@@ -169,7 +171,7 @@ int ykd_state_send_msg (enum totem_callback_token_type type, void *context)
 	return (res);
 }
 
-void ykd_state_send (void)
+static void ykd_state_send (void)
 {
         totempg_callback_token_create (
                 &ykd_state_send_callback_token_handle,
@@ -179,7 +181,7 @@ void ykd_state_send (void)
                 NULL);
 }
 
-int ykd_attempt_send_msg (enum totem_callback_token_type type, void *context)
+static int ykd_attempt_send_msg (enum totem_callback_token_type type, void *context)
 {
 	struct iovec iovec;
 	struct ykd_header header;
@@ -196,7 +198,7 @@ int ykd_attempt_send_msg (enum totem_callback_token_type type, void *context)
 	return (res);
 }
 
-void ykd_attempt_send (void)
+static void ykd_attempt_send (void)
 {
         totempg_callback_token_create (
                 &ykd_attempt_send_callback_token_handle,
@@ -206,7 +208,7 @@ void ykd_attempt_send (void)
                 NULL);
 }
 
-void compute (void)
+static void compute (void)
 {
 	int i;
 	int j;
@@ -244,7 +246,7 @@ void compute (void)
 	}
 }
 
-int subquorum (
+static int subquorum (
 	struct totem_ip_address *member_list,
 	int member_list_entries,
 	struct ykd_session *session)
@@ -277,7 +279,7 @@ int subquorum (
 	return (0);
 }
 
-int decide (void)
+static int decide (void)
 {
 	int i;
 
@@ -297,7 +299,7 @@ int decide (void)
 	return (1);
 }
 
-void ykd_session_endian_convert (struct ykd_session *ykd_session)
+static void ykd_session_endian_convert (struct ykd_session *ykd_session)
 {
 	int i;
 
@@ -308,7 +310,7 @@ void ykd_session_endian_convert (struct ykd_session *ykd_session)
 	}
 }
 
-void ykd_state_endian_convert (struct ykd_state *ykd_state)
+static void ykd_state_endian_convert (struct ykd_state *ykd_state)
 {
 	int i;
 
@@ -487,7 +489,7 @@ struct totempg_group ykd_group = {
 	.group_len	= 3
 };
 
-int ykd_init (
+static int ykd_init (
 	void (*primary_callback_fn) (
 		struct totem_ip_address *view_list,
 		int view_list_entries,
@@ -514,7 +516,37 @@ int ykd_init (
 /*
  * Returns 1 if this processor is in the primary 
  */
-int ykd_primary (void) {
+static int ykd_primary (void) {
 	return (primary_designated);
 }
 
+/*
+ * lcrso object definition
+ */
+static struct openais_vsf_iface_ver0 vsf_ykd_iface_ver0 = {
+	.init				= ykd_init,
+	.primary			= ykd_primary
+};
+
+static struct lcr_iface openais_vsf_ykd_ver0[1] = {
+	{
+		.name			= "openais_vsf_ykd",
+		.version		= 0,
+		.versions_replace	= 0,
+		.versions_replace_count	= 0,
+		.dependencies		= 0,
+		.dependency_count	= 0,
+		.constructor		= NULL,
+		.destructor		= NULL,
+		.interfaces		= (void **)(void *)&vsf_ykd_iface_ver0,
+	}
+};
+
+static struct lcr_comp vsf_ykd_comp_ver0 = {
+	.iface_count			= 1,
+	.ifaces				= openais_vsf_ykd_ver0
+};
+
+__attribute__ ((constructor)) static void vsf_ykd_comp_register (void) {
+	lcr_component_register (&vsf_ykd_comp_ver0);
+}

+ 0 - 52
exec/ykd.h

@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2005-2006 MontaVista Software, Inc.
- *
- * All rights reserved.
- *
- * Author: Steven Dake (sdake@mvista.com)
- *
- * 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 YKD_H_DEFINED
-#define YKD_H_DEFINED
-
-/*
- * Executes a callback whenever component changes
- */
-int ykd_init (
-    void (*primary_callback_fn) (
-	struct totem_ip_address *view_list,
-	int view_list_entries,
-	int primary_designated,
-	struct memb_ring_id *ring_id));
-
-/*
- * Returns 1 if we are primary component, 0 if not
- */
-int ykd_primary (void);
-
-#endif /* YKD_H_DEFINED */