[PATCH 4/6] Support udpu members in nodelist

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

 



Signed-off-by: Jan Friesse <jfriesse@xxxxxxxxxx>
---
 exec/main.c        |   11 +++++++-
 exec/totemconfig.c |   72 ++++++++++++++++++++++++++++++++++++++++++++++++---
 exec/totemconfig.h |    6 +++-
 3 files changed, 82 insertions(+), 7 deletions(-)

diff --git a/exec/main.c b/exec/main.c
index 52af1ae..7eaddff 100644
--- a/exec/main.c
+++ b/exec/main.c
@@ -1036,6 +1036,7 @@ int main (int argc, char **argv, char **envp)
 	struct stat stat_out;
 	char corosync_lib_dir[PATH_MAX];
 	enum e_corosync_done flock_err;
+	uint64_t totem_config_warnings;
 
 	/* default configuration
 	 */
@@ -1142,12 +1143,20 @@ int main (int argc, char **argv, char **envp)
 		corosync_exit_error (COROSYNC_DONE_DIR_NOT_PRESENT);
 	}
 
-	res = totem_config_read (&totem_config, &error_string);
+	res = totem_config_read (&totem_config, &error_string, &totem_config_warnings);
 	if (res == -1) {
 		log_printf (LOGSYS_LEVEL_ERROR, "%s", error_string);
 		corosync_exit_error (COROSYNC_DONE_MAINCONFIGREAD);
 	}
 
+	if (totem_config_warnings & TOTEM_CONFIG_WARNING_MEMBERS_IGNORED) {
+		log_printf (LOGSYS_LEVEL_WARNING, "member section is used together with nodelist. members ignored");
+	}
+
+	if (totem_config_warnings & TOTEM_CONFIG_WARNING_MEMBERS_DEPRECATED) {
+		log_printf (LOGSYS_LEVEL_WARNING, "member section is deprecated. Please migrate config file to nodelist");
+	}
+
 	res = totem_config_keyread (&totem_config, &error_string);
 	if (res == -1) {
 		log_printf (LOGSYS_LEVEL_ERROR, "%s", error_string);
diff --git a/exec/totemconfig.c b/exec/totemconfig.c
index 1d90417..6aa7de9 100644
--- a/exec/totemconfig.c
+++ b/exec/totemconfig.c
@@ -258,9 +258,60 @@ static int find_local_node_in_nodelist(struct totem_config *totem_config)
 	return (local_node_pos);
 }
 
+static void put_nodelist_members_to_config(struct totem_config *totem_config)
+{
+	icmap_iter_t iter, iter2;
+	const char *iter_key, *iter_key2;
+	int res = 0;
+	int node_pos;
+	char tmp_key[ICMAP_KEYNAME_MAXLEN];
+	char *node_addr_str;
+	int member_count;
+	unsigned int ringnumber = 0;
+
+	iter = icmap_iter_init("nodelist.node.");
+	while ((iter_key = icmap_iter_next(iter, NULL, NULL)) != NULL) {
+		res = sscanf(iter_key, "nodelist.node.%u.%s", &node_pos, tmp_key);
+		if (res != 2) {
+			continue;
+		}
+
+		if (strcmp(tmp_key, "ring0_addr") != 0) {
+			continue;
+		}
+
+		snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "nodelist.node.%u.", node_pos);
+		iter2 = icmap_iter_init(tmp_key);
+		while ((iter_key2 = icmap_iter_next(iter2, NULL, NULL)) != NULL) {
+			res = sscanf(iter_key2, "nodelist.node.%u.ring%u_addr", &node_pos, &ringnumber);
+			if (res != 2) {
+				continue;
+			}
+
+			if (icmap_get_string(iter_key2, &node_addr_str) != CS_OK) {
+				continue;
+			}
+
+			member_count = totem_config->interfaces[ringnumber].member_count;
+
+			res = totemip_parse(&totem_config->interfaces[ringnumber].member_list[member_count],
+						node_addr_str, 0);
+			if (res != -1) {
+				totem_config->interfaces[ringnumber].member_count++;
+			}
+			free(node_addr_str);
+		}
+
+		icmap_iter_finalize(iter2);
+	}
+
+	icmap_iter_finalize(iter);
+}
+
 extern int totem_config_read (
 	struct totem_config *totem_config,
-	const char **error_string)
+	const char **error_string,
+	uint64_t *warnings)
 {
 	int res = 0;
 	char *str;
@@ -277,6 +328,8 @@ extern int totem_config_read (
 	int i;
 	int local_node_pos;
 
+	*warnings = 0;
+
 	memset (totem_config, 0, sizeof (struct totem_config));
 	totem_config->interfaces = malloc (sizeof (struct totem_interface) * INTERFACE_MAX);
 	if (totem_config->interfaces == 0) {
@@ -410,6 +463,16 @@ extern int totem_config_read (
 		snprintf(tmp_key, ICMAP_KEYNAME_MAXLEN, "totem.interface.%u.member.", ringnumber);
 		member_iter = icmap_iter_init(tmp_key);
 		while ((member_iter_key = icmap_iter_next(member_iter, NULL, NULL)) != NULL) {
+			if (member_count == 0) {
+				if (icmap_get_string("nodelist.node.0.ring0_addr", &str) == CS_OK) {
+					free(str);
+					*warnings |= TOTEM_CONFIG_WARNING_MEMBERS_IGNORED;
+					break;
+				} else {
+					*warnings |= TOTEM_CONFIG_WARNING_MEMBERS_DEPRECATED;
+				}
+			}
+
 			if (icmap_get_string(member_iter_key, &str) == CS_OK) {
 				res = totemip_parse (&totem_config->interfaces[ringnumber].member_list[member_count++],
 						str, 0);
@@ -455,7 +518,7 @@ extern int totem_config_read (
 	free(cluster_name);
 
 	/*
-	 * If we have nodelist ...
+	 * Check existence of nodelist
 	 */
 	if (icmap_get_string("nodelist.node.0.ring0_addr", &str) == CS_OK) {
 		free(str);
@@ -464,11 +527,10 @@ extern int totem_config_read (
 		 */
 		local_node_pos = find_local_node_in_nodelist(totem_config);
 		if (local_node_pos != -1) {
-			/*
-			 * Store icmap key
-			 */
 			icmap_set_uint32("nodelist.local_node_pos", local_node_pos);
 		}
+
+		put_nodelist_members_to_config(totem_config);
 	}
 
 	add_totem_config_notification(totem_config);
diff --git a/exec/totemconfig.h b/exec/totemconfig.h
index cee52b7..8f41092 100644
--- a/exec/totemconfig.h
+++ b/exec/totemconfig.h
@@ -43,9 +43,13 @@
 
 #include "totemsrp.h"
 
+#define TOTEM_CONFIG_WARNING_MEMBERS_IGNORED		(1<<1)
+#define TOTEM_CONFIG_WARNING_MEMBERS_DEPRECATED		(1<<2)
+
 extern int totem_config_read (
 	struct totem_config *totem_config,
-	const char **error_string);
+	const char **error_string,
+	uint64_t *warnings);
 
 extern int totem_config_validate (
 	struct totem_config *totem_config,
-- 
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