[PATCH 1/4] Store rrp faulty status of ring in cmap

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

 



New key with faulty status of ring is created in cmap as name
runtime.totem.pg.mrp.rrp.$ring_number.faulty

Signed-off-by: Jan Friesse <jfriesse@xxxxxxxxxx>
---
 exec/totemrrp.c |   46 ++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 44 insertions(+), 2 deletions(-)

diff --git a/exec/totemrrp.c b/exec/totemrrp.c
index 452a1e6..99a9774 100644
--- a/exec/totemrrp.c
+++ b/exec/totemrrp.c
@@ -65,6 +65,7 @@
 #include <qb/qbloop.h>
 #define LOGSYS_UTILS_ONLY 1
 #include <corosync/engine/logsys.h>
+#include <corosync/engine/icmap.h>
 
 #include "totemnet.h"
 #include "totemrrp.h"
@@ -251,6 +252,8 @@ struct totemrrp_instance {
 	qb_loop_timer_handle timer_active_test_ring_timeout[INTERFACE_MAX];
 };
 
+static void icmap_set_interface_faulty(unsigned int iface_no, int is_faulty);
+
 /*
  * None Replication Forward Declerations
  */
@@ -597,6 +600,17 @@ do {								\
 		format, ##args);				\
 } while (0);
 
+static void icmap_set_interface_faulty(unsigned int iface_no, int is_faulty)
+{
+	uint8_t u8;
+	char key_name[ICMAP_KEYNAME_MAXLEN];
+
+	u8 = (is_faulty ? 1 : 0);
+
+	snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "runtime.totem.pg.mrp.rrp.%u.faulty", iface_no);
+	icmap_set_uint8(key_name, u8);
+}
+
 static void test_active_msg_endian_convert(const struct message_header *in, struct message_header *out)
 {
 	out->type = in->type;
@@ -775,6 +789,7 @@ void *passive_instance_initialize (
 	int interface_count)
 {
 	struct passive_instance *instance;
+	int i;
 
 	instance = malloc (sizeof (struct passive_instance));
 	if (instance == 0) {
@@ -790,6 +805,10 @@ void *passive_instance_initialize (
 	}
 	memset (instance->faulty, 0, sizeof (int) * interface_count);
 
+	for (i = 0; i < interface_count; i++) {
+		icmap_set_interface_faulty (i, 0);
+	}
+
 	instance->token_recv_count = malloc (sizeof (int) * interface_count);
 	if (instance->token_recv_count == 0) {
 		free (instance->faulty);
@@ -966,6 +985,7 @@ static void passive_monitor (
 		if ((passive_instance->faulty[i] == 0) &&
 		    (max - recv_count[i] > threshold)) {
 			passive_instance->faulty[i] = 1;
+
 			qb_loop_timer_add (rrp_instance->poll_handle,
 				QB_LOOP_MED,
 				rrp_instance->totem_config->rrp_autorecovery_check_timeout*QB_TIME_NS_IN_MSEC,
@@ -973,6 +993,8 @@ static void passive_monitor (
 				timer_function_test_ring_timeout,
 				&rrp_instance->timer_active_test_ring_timeout[i]);
 
+			icmap_set_interface_faulty (i, passive_instance->faulty[i]);
+
 			sprintf (rrp_instance->status[i],
 				"Marking ringid %u interface %s FAULTY",
 				i,
@@ -1206,6 +1228,7 @@ static void passive_ring_reenable (
 	unsigned int iface_no)
 {
 	struct passive_instance *rrp_algo_instance = (struct passive_instance *)instance->rrp_algo_instance;
+	int i;
 
 	memset (rrp_algo_instance->mcast_recv_count, 0, sizeof (unsigned int) *
 		instance->interface_count);
@@ -1215,8 +1238,12 @@ static void passive_ring_reenable (
 	if (iface_no == instance->interface_count) {
 		memset (rrp_algo_instance->faulty, 0, sizeof (unsigned int) *
 			instance->interface_count);
+		for (i = 0; i < instance->interface_count; i++) {
+			icmap_set_interface_faulty (i, 0);
+		}
 	} else {
 		rrp_algo_instance->faulty[iface_no] = 0;
+		icmap_set_interface_faulty (iface_no, 0);
 	}
 }
 
@@ -1228,6 +1255,7 @@ void *active_instance_initialize (
 	int interface_count)
 {
 	struct active_instance *instance;
+	int i;
 
 	instance = malloc (sizeof (struct active_instance));
 	if (instance == 0) {
@@ -1243,6 +1271,10 @@ void *active_instance_initialize (
 	}
 	memset (instance->faulty, 0, sizeof (unsigned int) * interface_count);
 
+	for (i = 0; i < interface_count; i++) {
+		icmap_set_interface_faulty (i, 0);
+	}
+
 	instance->last_token_recv = malloc (sizeof (int) * interface_count);
 	if (instance->last_token_recv == 0) {
 		free (instance->faulty);
@@ -1333,9 +1365,10 @@ static void timer_function_active_token_expired (void *context)
 		}
 	}
 	for (i = 0; i < rrp_instance->interface_count; i++) {
-		if (active_instance->counter_problems[i] >= rrp_instance->totem_config->rrp_problem_count_threshold)
-		{
+		if (active_instance->counter_problems[i] >= rrp_instance->totem_config->rrp_problem_count_threshold &&
+		    active_instance->faulty[i] == 0) {
 			active_instance->faulty[i] = 1;
+
 			qb_loop_timer_add (rrp_instance->poll_handle,
 				QB_LOOP_MED,
 				rrp_instance->totem_config->rrp_autorecovery_check_timeout*QB_TIME_NS_IN_MSEC,
@@ -1343,6 +1376,8 @@ static void timer_function_active_token_expired (void *context)
 				timer_function_test_ring_timeout,
 				&rrp_instance->timer_active_test_ring_timeout[i]);
 
+			icmap_set_interface_faulty (i, active_instance->faulty[i]);
+
 			sprintf (rrp_instance->status[i],
 				"Marking seqid %d ringid %u interface %s FAULTY",
 				active_instance->last_token_seq,
@@ -1621,6 +1656,7 @@ static void active_ring_reenable (
 	unsigned int iface_no)
 {
 	struct active_instance *rrp_algo_instance = (struct active_instance *)instance->rrp_algo_instance;
+	int i;
 
 	if (iface_no == instance->interface_count) {
 		memset (rrp_algo_instance->last_token_recv, 0, sizeof (unsigned int) *
@@ -1629,10 +1665,16 @@ static void active_ring_reenable (
 			instance->interface_count);
 		memset (rrp_algo_instance->counter_problems, 0, sizeof (unsigned int) *
 			instance->interface_count);
+
+		for (i = 0; i < instance->interface_count; i++) {
+			icmap_set_interface_faulty (i, 0);
+		}
 	} else {
 		rrp_algo_instance->last_token_recv[iface_no] = 0;
 		rrp_algo_instance->faulty[iface_no] = 0;
 		rrp_algo_instance->counter_problems[iface_no] = 0;
+
+		icmap_set_interface_faulty (iface_no, 0);
 	}
 }
 
-- 
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