[DRBD-cvs] svn commit by phil - r2830 - trunk/drbd - Improve the robustness of the UUID algorithm: 1) Before

drbd-cvs at lists.linbit.com drbd-cvs at lists.linbit.com
Thu Apr 5 22:37:53 CEST 2007


Author: phil
Date: 2007-04-05 22:37:52 +0200 (Thu, 05 Apr 2007)
New Revision: 2830

Modified:
   trunk/drbd/drbd_receiver.c
Log:
Improve the robustness of the UUID algorithm:

  1) Before this patch, the sync target set its current UUID to
     zero before it gets the sync_uuid. Then finally it writes
     to sync_uuid to its current uuid.

     Not good.

     In case we get restarted in between we end up with a current
     UUID of 0.

     Changed this, so that the sync target only updates it
     UUID set when it has got the sync_uuid.

  2) Made a current UUID of 0 to be just the same as a current UUID
     of JUST_CREATED.

  3) Removed that suspicious looking clear_bit(CRASHED_PRIMARY)
     from receive_bitmap(). Whatever it was good for, I am sure
     that it is not needed nowadays.



Modified: trunk/drbd/drbd_receiver.c
===================================================================
--- trunk/drbd/drbd_receiver.c	2007-04-05 13:24:19 UTC (rev 2829)
+++ trunk/drbd/drbd_receiver.c	2007-04-05 20:37:52 UTC (rev 2830)
@@ -1859,12 +1859,12 @@
 	    peer == UUID_JUST_CREATED) return 0;
 
 	*rule_nr = 2;
-	if (self == UUID_JUST_CREATED &&
-	    peer != UUID_JUST_CREATED) return -2;
+	if ( (self == UUID_JUST_CREATED || self == (u64)0) &&
+	     peer != UUID_JUST_CREATED) return -2;
 
 	*rule_nr = 3;
-	if (self != UUID_JUST_CREATED &&
-	    peer == UUID_JUST_CREATED) return 2;
+	if ( self != UUID_JUST_CREATED &&
+	     (peer == UUID_JUST_CREATED || peer == (u64)0) ) return 2;
 
 	*rule_nr = 4;
 	if (self == peer) { // Common power [off|failure]
@@ -2052,7 +2052,6 @@
 	if (hg > 0) { // become sync source.
 		rv = WFBitMapS;
 	} else if (hg < 0) { // become sync target
-		drbd_uuid_set(mdev,Current,mdev->p_uuid[Bitmap]);
 		rv = WFBitMapT;
 	} else {
 		rv = Connected;
@@ -2465,7 +2464,7 @@
 	if (drbd_recv(mdev, h->payload, h->length) != h->length)
 		return FALSE;
 
-	_drbd_uuid_set(mdev,Current,be64_to_cpu(p->uuid));
+	drbd_uuid_set(mdev,Current,be64_to_cpu(p->uuid));
 	_drbd_uuid_set(mdev,Bitmap,0UL);
 
 	drbd_start_resync(mdev,SyncTarget);
@@ -2509,7 +2508,6 @@
 		D_ASSERT(h->command == ReportBitMap);
 	}
 
-	clear_bit(CRASHED_PRIMARY, &mdev->flags); // md_write() is in drbd_start_resync.
 	if (mdev->state.conn == WFBitMapS) {
 		drbd_start_resync(mdev,SyncSource);
 	} else if (mdev->state.conn == WFBitMapT) {



More information about the drbd-cvs mailing list