[DRBD-cvs] svn commit by phil - r2794 - trunk/drbd - Rearranged the code once more drbd_sync_handshake()...

drbd-cvs at lists.linbit.com drbd-cvs at lists.linbit.com
Tue Mar 13 11:18:51 CET 2007


Author: phil
Date: 2007-03-13 11:18:49 +0100 (Tue, 13 Mar 2007)
New Revision: 2794

Modified:
   trunk/drbd/drbd_receiver.c
Log:
Rearranged the code once more drbd_sync_handshake()...

* to not resync unrelated data.
* to do a full sync in case it is neccesary, also if the
  resync decission is found by looking at the disk states.



Modified: trunk/drbd/drbd_receiver.c
===================================================================
--- trunk/drbd/drbd_receiver.c	2007-03-12 17:47:41 UTC (rev 2793)
+++ trunk/drbd/drbd_receiver.c	2007-03-13 10:18:49 UTC (rev 2794)
@@ -1932,26 +1932,37 @@
 STATIC drbd_conns_t drbd_sync_handshake(drbd_dev *mdev, drbd_role_t peer_role,
 					drbd_disks_t peer_disk)
 {
-	int hg,rule_nr=0;
+	int hg,rule_nr;
 	drbd_conns_t rv = conn_mask;
 	drbd_disks_t mydisk;
 
 	mydisk = mdev->state.disk;
 	if( mydisk == Negotiating ) mydisk = mdev->new_state_tmp.disk;
 
-	// Look if a disk is inconsistent. Only if this does not find 
-	// a decission look at the UUIDs.
-	if(mydisk==Inconsistent && peer_disk>Inconsistent) hg=-1;
-	else if(mydisk>Inconsistent && peer_disk==Inconsistent) hg= 1;
-	else hg = drbd_uuid_compare(mdev,&rule_nr);
+	hg = drbd_uuid_compare(mdev,&rule_nr);
 
 	MTRACE(TraceTypeUuid,TraceLvlSummary,
 	       INFO("drbd_sync_handshake:\n");
 	       drbd_uuid_dump(mdev,"self",mdev->bc->md.uuid);
 	       drbd_uuid_dump(mdev,"peer",mdev->p_uuid);
-	       INFO("have_good=%d by rule %d\n",hg,rule_nr);
+	       INFO("uuid_compare()=%d by rule %d\n",hg,rule_nr);
 	    );
 
+	if (hg == -1000) {
+		ALERT("Unrelated data, dropping connection!\n");
+		drbd_force_state(mdev,NS(conn,Disconnecting));
+		return conn_mask;
+	}
+
+	if( (mydisk==Inconsistent && peer_disk>Inconsistent) ||
+	    (peer_disk==Inconsistent && mydisk>Inconsistent) )  {
+		int f = (hg == -100) || abs(hg) == 2;
+		hg = mydisk > Inconsistent ? 1 : -1;
+		if(f) hg=hg*2;
+		INFO("Becoming sync %s due to disk states.\n",
+		     hg > 0 ? "source" : "target");
+	}
+
 	if (hg == 100 || (hg == -100 && mdev->net_conf->always_asbp) ) {
 		int pcount = (mdev->state.role==Primary) + (peer_role==Primary);
 		int forced = (hg == -100);
@@ -1994,12 +2005,6 @@
 		}
 	}
 
-	if (hg == -1000) {
-		ALERT("Unrelated data, dropping connection!\n");
-		drbd_force_state(mdev,NS(conn,Disconnecting));
-		return conn_mask;
-	}
-
 	if (hg == -100) {
 		ALERT("Split-Brain detected, dropping connection!\n");
 		drbd_uuid_dump(mdev,"self",mdev->bc->md.uuid);



More information about the drbd-cvs mailing list