Jelajahi Sumber

totemsrp: Allocate new buffer for recovery message

Previously when recovery message was converted into regular
message original pointer was lost. This is not correct, because it
makes impossible to free message correctly.

Solution is to allocate new message which doesn't contain extra recovery
message mcast header and copy recovery message there.

Lucas Zampieri fixed original patch because
deliver_messages_from_recovery_to_regular compared my_old_ring_id and
checked regular sort queue using header of the recovery message instead
of the encapsulated one. Recovery message always carries ring id of the
new ring, so check never matched and no message was moved to the regular
sort queue. Node which missed message on the old ring never delivered
it.

With fragmented cpg messages this showed up as cpgverify "incorrect
hash" after membership change.

Solution was to point mcast to the encapsulated message before the
checks, as it was before.

Signed-off-by: Lucas Zampieri <lcasmz54@gmail.com>
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Lucas Zampieri <lcasmz54@gmail.com>
Jan Friesse 7 tahun lalu
induk
melakukan
9a7360150f
1 mengubah file dengan 14 tambahan dan 11 penghapusan
  1. 14 11
      exec/totemsrp.c

+ 14 - 11
exec/totemsrp.c

@@ -1877,23 +1877,19 @@ static void deliver_messages_from_recovery_to_regular (struct totemsrp_instance
 		 * Convert recovery message into regular message
 		 */
 		mcast = recovery_message_item->mcast;
-		if (mcast->header.encapsulated == MESSAGE_ENCAPSULATED) {
-			/*
-			 * Message is a recovery message encapsulated
-			 * in a new ring message
-			 */
-			regular_message_item.mcast =
-				(struct mcast *)(((char *)recovery_message_item->mcast) + sizeof (struct mcast));
-			regular_message_item.msg_len =
-			recovery_message_item->msg_len - sizeof (struct mcast);
-			mcast = regular_message_item.mcast;
-		} else {
+		if (mcast->header.encapsulated != MESSAGE_ENCAPSULATED) {
 			/*
 			 * TODO this case shouldn't happen
 			 */
 			continue;
 		}
 
+		/*
+		 * Message is a recovery message encapsulated
+		 * in a new ring message
+		 */
+		mcast = (struct mcast *)(((char *)recovery_message_item->mcast) + sizeof (struct mcast));
+
 		log_printf (instance->totemsrp_log_level_debug,
 			"comparing if ring id is for this processors old ring seqno " CS_PRI_RING_ID_SEQ,
 			 (uint64_t)mcast->seq);
@@ -1908,6 +1904,13 @@ static void deliver_messages_from_recovery_to_regular (struct totemsrp_instance
 
 			res = sq_item_inuse (&instance->regular_sort_queue, mcast->seq);
 			if (res == 0) {
+				regular_message_item.mcast = totemsrp_buffer_alloc (instance);
+				assert(regular_message_item.mcast != NULL);
+
+				regular_message_item.msg_len = recovery_message_item->msg_len - sizeof (struct mcast);
+
+				memcpy(regular_message_item.mcast, mcast, regular_message_item.msg_len);
+
 				sq_item_add (&instance->regular_sort_queue,
 					&regular_message_item, mcast->seq);
 				if (sq_lt_compare (instance->old_ring_state_high_seq_received, mcast->seq)) {