[PATCH 1/5] totem: Inform RRP about membership changes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Services are informed about membership changes, but if same information
is needed inside totemrrp or totemnet, it's impossible to gather this
information.

Patch makes this possible for now only for RRP with empty callbacks.

Signed-off-by: Jan Friesse <jfriesse@xxxxxxxxxx>
---
 exec/totemrrp.c |   91 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
 exec/totemrrp.h |   17 ++++++++++
 exec/totemsrp.c |   26 ++++++++++++----
 3 files changed, 125 insertions(+), 9 deletions(-)

diff --git a/exec/totemrrp.c b/exec/totemrrp.c
index b1c9f75..7e70dd6 100644
--- a/exec/totemrrp.c
+++ b/exec/totemrrp.c
@@ -178,6 +178,13 @@ struct rrp_algo {
 		const struct totem_ip_address *member,
 		unsigned int iface_no);
 
+	void (*membership_changed) (
+		struct totemrrp_instance *instance,
+	        enum totem_configuration_type configuration_type,
+		const struct srp_addr *member_list, size_t member_list_entries,
+		const struct srp_addr *left_list, size_t left_list_entries,
+		const struct srp_addr *joined_list, size_t joined_list_entries,
+		const struct memb_ring_id *ring_id);
 };
 
 #define STATUS_STR_LEN 512
@@ -324,6 +331,15 @@ static int none_member_remove (
 	struct totemrrp_instance *instance,
 	const struct totem_ip_address *member,
 	unsigned int iface_no);
+
+static void none_membership_changed (
+	struct totemrrp_instance *instance,
+	enum totem_configuration_type configuration_type,
+	const struct srp_addr *member_list, size_t member_list_entries,
+	const struct srp_addr *left_list, size_t left_list_entries,
+	const struct srp_addr *joined_list, size_t joined_list_entries,
+	const struct memb_ring_id *ring_id);
+
 /*
  * Passive Replication Forward Declerations
  */
@@ -400,6 +416,15 @@ static int passive_member_remove (
 	struct totemrrp_instance *instance,
 	const struct totem_ip_address *member,
 	unsigned int iface_no);
+
+static void passive_membership_changed (
+	struct totemrrp_instance *instance,
+	enum totem_configuration_type configuration_type,
+	const struct srp_addr *member_list, size_t member_list_entries,
+	const struct srp_addr *left_list, size_t left_list_entries,
+	const struct srp_addr *joined_list, size_t joined_list_entries,
+	const struct memb_ring_id *ring_id);
+
 /*
  * Active Replication Forward Definitions
  */
@@ -472,6 +497,14 @@ static int active_member_remove (
 	const struct totem_ip_address *member,
 	unsigned int iface_no);
 
+static void active_membership_changed (
+	struct totemrrp_instance *instance,
+	enum totem_configuration_type configuration_type,
+	const struct srp_addr *member_list, size_t member_list_entries,
+	const struct srp_addr *left_list, size_t left_list_entries,
+	const struct srp_addr *joined_list, size_t joined_list_entries,
+	const struct memb_ring_id *ring_id);
+
 static void active_timer_expired_token_start (
 	struct active_instance *active_instance);
 
@@ -546,7 +579,8 @@ struct rrp_algo none_algo = {
 	.ring_reenable		= none_ring_reenable,
 	.mcast_recv_empty	= none_mcast_recv_empty,
 	.member_add		= none_member_add,
-	.member_remove		= none_member_remove
+	.member_remove		= none_member_remove,
+	.membership_changed	= none_membership_changed
 };
 
 struct rrp_algo passive_algo = {
@@ -565,7 +599,8 @@ struct rrp_algo passive_algo = {
 	.ring_reenable		= passive_ring_reenable,
 	.mcast_recv_empty	= passive_mcast_recv_empty,
 	.member_add		= passive_member_add,
-	.member_remove		= passive_member_remove
+	.member_remove		= passive_member_remove,
+	.membership_changed	= passive_membership_changed
 };
 
 struct rrp_algo active_algo = {
@@ -584,7 +619,8 @@ struct rrp_algo active_algo = {
 	.ring_reenable		= active_ring_reenable,
 	.mcast_recv_empty	= active_mcast_recv_empty,
 	.member_add		= active_member_add,
-	.member_remove		= active_member_remove
+	.member_remove		= active_member_remove,
+	.membership_changed	= active_membership_changed
 };
 
 struct rrp_algo *rrp_algos[] = {
@@ -778,6 +814,16 @@ static int none_member_remove (
 	return (res);
 }
 
+static void none_membership_changed (
+	struct totemrrp_instance *instance,
+        enum totem_configuration_type configuration_type,
+	const struct srp_addr *member_list, size_t member_list_entries,
+	const struct srp_addr *left_list, size_t left_list_entries,
+	const struct srp_addr *joined_list, size_t joined_list_entries,
+	const struct memb_ring_id *ring_id)
+{
+
+}
 
 /*
  * Passive Replication Implementation
@@ -1220,6 +1266,16 @@ static int passive_member_remove (
 	return (res);
 }
 
+static void passive_membership_changed (
+	struct totemrrp_instance *instance,
+        enum totem_configuration_type configuration_type,
+	const struct srp_addr *member_list, size_t member_list_entries,
+	const struct srp_addr *left_list, size_t left_list_entries,
+	const struct srp_addr *joined_list, size_t joined_list_entries,
+	const struct memb_ring_id *ring_id)
+{
+
+}
 
 static void passive_ring_reenable (
 	struct totemrrp_instance *instance,
@@ -1592,6 +1648,17 @@ static int active_member_remove (
 	return (res);
 }
 
+static void active_membership_changed (
+	struct totemrrp_instance *instance,
+        enum totem_configuration_type configuration_type,
+	const struct srp_addr *member_list, size_t member_list_entries,
+	const struct srp_addr *left_list, size_t left_list_entries,
+	const struct srp_addr *joined_list, size_t joined_list_entries,
+	const struct memb_ring_id *ring_id)
+{
+
+}
+
 static void active_iface_check (struct totemrrp_instance *instance)
 {
 	struct active_instance *rrp_algo_instance = (struct active_instance *)instance->rrp_algo_instance;
@@ -2157,3 +2224,21 @@ int totemrrp_member_remove (
 
 	return (res);
 }
+
+void totemrrp_membership_changed (
+        void *rrp_context,
+        enum totem_configuration_type configuration_type,
+	const struct srp_addr *member_list, size_t member_list_entries,
+	const struct srp_addr *left_list, size_t left_list_entries,
+	const struct srp_addr *joined_list, size_t joined_list_entries,
+	const struct memb_ring_id *ring_id)
+{
+	struct totemrrp_instance *instance = (struct totemrrp_instance *)rrp_context;
+
+	instance->rrp_algo->membership_changed (instance,
+	    configuration_type,
+	    member_list, member_list_entries,
+	    left_list, left_list_entries,
+	    joined_list, joined_list_entries,
+	    ring_id);
+}
diff --git a/exec/totemrrp.h b/exec/totemrrp.h
index db32cda..ca57051 100644
--- a/exec/totemrrp.h
+++ b/exec/totemrrp.h
@@ -51,6 +51,15 @@
 #define TOTEMRRP_NOFLUSH	0
 #define TOTEMRRP_FLUSH		1
 
+/*
+ * SRP address. Used mainly in totemsrp.c, but we need it here to inform RRP about
+ * membership change.
+ */
+struct srp_addr {
+	uint8_t no_addrs;
+	struct totem_ip_address addr[INTERFACE_MAX];
+};
+
 /**
  * Create an instance
  */
@@ -150,4 +159,12 @@ extern int totemrrp_member_remove (
         const struct totem_ip_address *member,
 	int iface_no);
 
+extern void totemrrp_membership_changed (
+	void *rrp_context,
+	enum totem_configuration_type configuration_type,
+	const struct srp_addr *member_list, size_t member_list_entries,
+	const struct srp_addr *left_list, size_t left_list_entries,
+	const struct srp_addr *joined_list, size_t joined_list_entries,
+	const struct memb_ring_id *ring_id);
+
 #endif /* TOTEMRRP_H_DEFINED */
diff --git a/exec/totemsrp.c b/exec/totemsrp.c
index 3b8d56b..95736b1 100644
--- a/exec/totemsrp.c
+++ b/exec/totemsrp.c
@@ -153,12 +153,6 @@ enum encapsulation_type {
 /*
  * New membership algorithm local variables
  */
-struct srp_addr {
-	uint8_t no_addrs;
-	struct totem_ip_address addr[INTERFACE_MAX];
-};
-
-
 struct consensus_list_item {
 	struct srp_addr addr;
 	int set;
@@ -1877,6 +1871,16 @@ static void memb_state_operational_enter (struct totemsrp_instance *instance)
 	instance->my_set_retrans_flg = 0;
 
 	/*
+	 * Inform RRP about transitional change
+	 */
+	totemrrp_membership_changed (
+		instance->totemrrp_context,
+		TOTEM_CONFIGURATION_TRANSITIONAL,
+		instance->my_trans_memb_list, instance->my_trans_memb_entries,
+		instance->my_left_memb_list, instance->my_left_memb_entries,
+		NULL, 0,
+		&instance->my_ring_id);
+	/*
 	 * Deliver transitional configuration to application
 	 */
 	srp_addr_to_nodeid (left_list, instance->my_left_memb_list,
@@ -1897,6 +1901,16 @@ static void memb_state_operational_enter (struct totemsrp_instance *instance)
 	instance->my_aru = aru_save;
 
 	/*
+	 * Inform RRP about regular membership change
+	 */
+	totemrrp_membership_changed (
+		instance->totemrrp_context,
+		TOTEM_CONFIGURATION_REGULAR,
+		instance->my_new_memb_list, instance->my_new_memb_entries,
+		NULL, 0,
+		joined_list, joined_list_entries,
+		&instance->my_ring_id);
+	/*
 	 * Deliver regular configuration to application
 	 */
 	srp_addr_to_nodeid (new_memb_list_totemip,
-- 
1.7.1

_______________________________________________
discuss mailing list
discuss@xxxxxxxxxxxx
http://lists.corosync.org/mailman/listinfo/discuss




[Index of Archives]     [Linux Clusters]     [Corosync Project]     [Linux USB Devel]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Linux Kernel]     [Linux SCSI]     [X.Org]

  Powered by Linux