Browse Source

When doing a controlled shutdown of corosync, we now
send out a JOIN message with our node removed. This should
speed up the case where a lot of nodes leave at the same time as
they don't need to wait for the token timeout for each node.



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

Christine Caulfield 16 năm trước cách đây
mục cha
commit
69ff770544
3 tập tin đã thay đổi với 91 bổ sung1 xóa
  1. 14 0
      exec/totemnet.c
  2. 76 0
      exec/totemsrp.c
  3. 1 1
      services/cfg.c

+ 14 - 0
exec/totemnet.c

@@ -1113,6 +1113,20 @@ int totemnet_finalize (
 
 
 	worker_thread_group_exit (&instance->worker_thread_group);
 	worker_thread_group_exit (&instance->worker_thread_group);
 
 
+	if (instance->totemnet_sockets.mcast_recv > 0) {
+		close (instance->totemnet_sockets.mcast_recv);
+	 	poll_dispatch_delete (instance->totemnet_poll_handle,
+			instance->totemnet_sockets.mcast_recv);
+	}
+	if (instance->totemnet_sockets.mcast_send > 0) {
+		close (instance->totemnet_sockets.mcast_send);
+	}
+	if (instance->totemnet_sockets.token > 0) {
+		close (instance->totemnet_sockets.token);
+		poll_dispatch_delete (instance->totemnet_poll_handle,
+			instance->totemnet_sockets.token);
+	}
+
 	hdb_handle_put (&totemnet_instance_database, handle);
 	hdb_handle_put (&totemnet_instance_database, handle);
 
 
 error_exit:
 error_exit:

+ 76 - 0
exec/totemsrp.c

@@ -91,6 +91,7 @@
 #define MAXIOVS					5
 #define MAXIOVS					5
 #define RETRANSMIT_ENTRIES_MAX			30
 #define RETRANSMIT_ENTRIES_MAX			30
 #define TOKEN_SIZE_MAX				64000 /* bytes */
 #define TOKEN_SIZE_MAX				64000 /* bytes */
+#define LEAVE_DUMMY_NODEID                      0
 
 
 /*
 /*
  * Rollover handling:
  * Rollover handling:
@@ -560,6 +561,8 @@ static void srp_addr_to_nodeid (
 
 
 static int srp_addr_equal (const struct srp_addr *a, const struct srp_addr *b);
 static int srp_addr_equal (const struct srp_addr *a, const struct srp_addr *b);
 
 
+static void memb_leave_message_send (struct totemsrp_instance *instance);
+
 static void memb_ring_id_create_or_load (struct totemsrp_instance *, struct memb_ring_id *);
 static void memb_ring_id_create_or_load (struct totemsrp_instance *, struct memb_ring_id *);
 
 
 static void token_callbacks_execute (struct totemsrp_instance *instance, enum totem_callback_token_type type);
 static void token_callbacks_execute (struct totemsrp_instance *instance, enum totem_callback_token_type type);
@@ -872,6 +875,7 @@ void totemsrp_finalize (
 	if (res != 0) {
 	if (res != 0) {
 		return;
 		return;
 	}
 	}
+	memb_leave_message_send (instance);
 
 
 	hdb_handle_put (&totemsrp_instance_database, handle);
 	hdb_handle_put (&totemsrp_instance_database, handle);
 }
 }
@@ -1096,6 +1100,9 @@ static void memb_consensus_set (
 	int found = 0;
 	int found = 0;
 	int i;
 	int i;
 
 
+	if (addr->addr[0].nodeid == LEAVE_DUMMY_NODEID)
+	        return;
+
 	for (i = 0; i < instance->consensus_list_entries; i++) {
 	for (i = 0; i < instance->consensus_list_entries; i++) {
 		if (srp_addr_equal(addr, &instance->consensus_list[i].addr)) {
 		if (srp_addr_equal(addr, &instance->consensus_list[i].addr)) {
 			found = 1;
 			found = 1;
@@ -2873,6 +2880,75 @@ static void memb_join_message_send (struct totemsrp_instance *instance)
 		addr_idx);
 		addr_idx);
 }
 }
 
 
+static void memb_leave_message_send (struct totemsrp_instance *instance)
+{
+	char memb_join_data[10000];
+	struct memb_join *memb_join = (struct memb_join *)memb_join_data;
+	char *addr;
+	unsigned int addr_idx;
+	int active_memb_entries;
+	struct srp_addr active_memb[PROCESSOR_COUNT_MAX];
+
+	log_printf (instance->totemsrp_log_level_debug,
+		"sending join/leave message\n");
+
+	/*
+	 * add us to the failed list, and remove us from
+	 * the members list
+	 */
+	memb_set_merge(
+		       &instance->my_id, 1,
+		       instance->my_failed_list, &instance->my_failed_list_entries);
+
+	memb_set_subtract (active_memb, &active_memb_entries,
+			   instance->my_proc_list, instance->my_proc_list_entries,
+			   &instance->my_id, 1);
+
+
+	memb_join->header.type = MESSAGE_TYPE_MEMB_JOIN;
+	memb_join->header.endian_detector = ENDIAN_LOCAL;
+	memb_join->header.encapsulated = 0;
+	memb_join->header.nodeid = LEAVE_DUMMY_NODEID;
+
+	memb_join->ring_seq = instance->my_ring_id.seq;
+	memb_join->proc_list_entries = active_memb_entries;
+	memb_join->failed_list_entries = instance->my_failed_list_entries;
+	srp_addr_copy (&memb_join->system_from, &instance->my_id);
+	memb_join->system_from.addr[0].nodeid = LEAVE_DUMMY_NODEID;
+
+	// TODO: CC Maybe use the actual join send routine.
+	/*
+	 * This mess adds the joined and failed processor lists into the join
+	 * message
+	 */
+	addr = (char *)memb_join;
+	addr_idx = sizeof (struct memb_join);
+	memcpy (&addr[addr_idx],
+		active_memb,
+		active_memb_entries *
+			sizeof (struct srp_addr));
+	addr_idx += 
+		active_memb_entries *
+		sizeof (struct srp_addr);
+	memcpy (&addr[addr_idx],
+		instance->my_failed_list,
+		instance->my_failed_list_entries *
+		sizeof (struct srp_addr));
+	addr_idx += 
+		instance->my_failed_list_entries *
+		sizeof (struct srp_addr);
+
+
+	if (instance->totem_config->send_join_timeout) {
+		usleep (random() % (instance->totem_config->send_join_timeout * 1000));
+	}
+
+	totemrrp_mcast_flush_send (
+		instance->totemrrp_handle,
+		memb_join,
+		addr_idx);
+}
+
 static void memb_merge_detect_transmit (struct totemsrp_instance *instance)
 static void memb_merge_detect_transmit (struct totemsrp_instance *instance)
 {
 {
 	struct memb_merge_detect memb_merge_detect;
 	struct memb_merge_detect memb_merge_detect;

+ 1 - 1
services/cfg.c

@@ -621,7 +621,7 @@ static void message_handler_req_exec_cfg_shutdown (
 
 
 	log_printf(LOGSYS_LEVEL_NOTICE, "Node %d was shut down by sysadmin\n", nodeid);
 	log_printf(LOGSYS_LEVEL_NOTICE, "Node %d was shut down by sysadmin\n", nodeid);
 	if (nodeid == api->totem_nodeid_get()) {
 	if (nodeid == api->totem_nodeid_get()) {
-		corosync_fatal_error(COROSYNC_FATAL_ERROR_EXIT);
+		api->request_shutdown();
 	}
 	}
 	LEAVE();
 	LEAVE();
 }
 }