[PATCH 4/5] totemudpu: Implement member_set_active

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

 



Member active is used for sending "multicast" messages only to members
of ring. This reduces network load if some nodes are intentionally down.
Only regular multicast message load is reduced (messages sent by
totemudpu_mcast_noflush_send), because special messages (like hold
cancel, join message, ...) still have to be send to all members to
ensure correct behavior.

Signed-off-by: Jan Friesse <jfriesse@xxxxxxxxxx>
---
 exec/totemnet.c  |    3 +-
 exec/totemudpu.c |   55 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 exec/totemudpu.h |    5 ++++
 3 files changed, 59 insertions(+), 4 deletions(-)

diff --git a/exec/totemnet.c b/exec/totemnet.c
index 85e35ea..059ae77 100644
--- a/exec/totemnet.c
+++ b/exec/totemnet.c
@@ -178,7 +178,8 @@ struct transport transport_entries[] = {
 		.crypto_set = totemudpu_crypto_set,
 		.recv_mcast_empty = totemudpu_recv_mcast_empty,
 		.member_add = totemudpu_member_add,
-		.member_remove = totemudpu_member_remove
+		.member_remove = totemudpu_member_remove,
+		.member_set_active = totemudpu_member_set_active
 	},
 #ifdef HAVE_RDMA
 	{
diff --git a/exec/totemudpu.c b/exec/totemudpu.c
index f984920..ef4449f 100644
--- a/exec/totemudpu.c
+++ b/exec/totemudpu.c
@@ -92,6 +92,7 @@ struct totemudpu_member {
 	struct list_head list;
 	struct totem_ip_address member;
 	int fd;
+	int active;
 };
 
 struct totemudpu_instance {
@@ -315,7 +316,8 @@ static inline void ucast_sendmsg (
 static inline void mcast_sendmsg (
 	struct totemudpu_instance *instance,
 	const void *msg,
-	unsigned int msg_len)
+	unsigned int msg_len,
+	int only_active)
 {
 	struct msghdr msg_mcast;
 	int res = 0;
@@ -355,6 +357,9 @@ static inline void mcast_sendmsg (
 			struct totemudpu_member,
 			list);
 
+		if (only_active && !member->active)
+			continue ;
+
 		totemip_totemip_to_sockaddr_convert(&member->member,
 			instance->totem_interface->ip_port, &sockaddr, &addrlen);
 		msg_mcast.msg_name = &sockaddr;
@@ -889,7 +894,7 @@ int totemudpu_mcast_flush_send (
 	struct totemudpu_instance *instance = (struct totemudpu_instance *)udpu_context;
 	int res = 0;
 
-	mcast_sendmsg (instance, msg, msg_len);
+	mcast_sendmsg (instance, msg, msg_len, 0);
 
 	return (res);
 }
@@ -902,7 +907,7 @@ int totemudpu_mcast_noflush_send (
 	struct totemudpu_instance *instance = (struct totemudpu_instance *)udpu_context;
 	int res = 0;
 
-	mcast_sendmsg (instance, msg, msg_len);
+	mcast_sendmsg (instance, msg, msg_len, 1);
 
 	return (res);
 }
@@ -1083,12 +1088,16 @@ int totemudpu_member_add (
 	if (new_member == NULL) {
 		return (-1);
 	}
+
+	memset(new_member, 0, sizeof(*new_member));
+
 	log_printf (LOGSYS_LEVEL_NOTICE, "adding new UDPU member {%s}",
 		totemip_print(member));
 	list_init (&new_member->list);
 	list_add_tail (&new_member->list, &instance->member_list);
 	memcpy (&new_member->member, member, sizeof (struct totem_ip_address));
 	new_member->fd = totemudpu_create_sending_socket(udpu_context, member);
+	new_member->active = 0;
 
 	return (0);
 }
@@ -1168,3 +1177,43 @@ int totemudpu_member_list_rebind_ip (
 
 	return (0);
 }
+
+int totemudpu_member_set_active (
+	void *udpu_context,
+	const struct totem_ip_address *member_ip,
+	int active)
+{
+	struct list_head *list;
+	struct totemudpu_member *member;
+	int addr_found = 0;
+
+	struct totemudpu_instance *instance = (struct totemudpu_instance *)udpu_context;
+
+	/*
+	 * Find the member to set active flag
+	 */
+	for (list = instance->member_list.next; list != &instance->member_list;	list = list->next) {
+		member = list_entry (list, struct totemudpu_member, list);
+
+		if (totemip_compare (member_ip, &member->member) == 0) {
+			log_printf(LOGSYS_LEVEL_DEBUG,
+			    "Marking UDPU member %s %s",
+			    totemip_print(&member->member),
+			    (active ? "active" : "inactive"));
+
+			member->active = active;
+			addr_found = 1;
+
+			break;
+		}
+	}
+
+	if (!addr_found) {
+		log_printf(LOGSYS_LEVEL_DEBUG,
+		    "Can't find UDPU member %s (should be marked as %s)",
+			    totemip_print(member_ip),
+			    (active ? "active" : "inactive"));
+	}
+
+	return (0);
+}
diff --git a/exec/totemudpu.h b/exec/totemudpu.h
index 7e80ed7..51cd323 100644
--- a/exec/totemudpu.h
+++ b/exec/totemudpu.h
@@ -123,4 +123,9 @@ extern int totemudpu_member_remove (
 	void *udpu_context,
 	const struct totem_ip_address *member);
 
+extern int totemudpu_member_set_active (
+	void *udpu_context,
+	const struct totem_ip_address *member_ip,
+	int active);
+
 #endif /* TOTEMUDPU_H_DEFINED */
-- 
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