[DRBD-cvs] r1882 - branches/drbd-0.7/drbd

www-data www-data at linbit.com
Mon Jul 18 11:53:29 CEST 2005


Author: lars
Date: 2005-07-18 11:53:28 +0200 (Mon, 18 Jul 2005)
New Revision: 1882

Modified:
   branches/drbd-0.7/drbd/drbd_receiver.c
Log:

 you could get a flip-flop connection established/connection loss,
 in case both peers have different, non-zero, usize uppon first connect!

 sort-of solved it:
  "expected" (first) param exchange: use the minimum.
  "unexpected" (resize) param exchange:
    just do what the peer tells us to do.
 



Modified: branches/drbd-0.7/drbd/drbd_receiver.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_receiver.c	2005-07-18 09:48:44 UTC (rev 1881)
+++ branches/drbd-0.7/drbd/drbd_receiver.c	2005-07-18 09:53:28 UTC (rev 1882)
@@ -1348,7 +1348,7 @@
 	Drbd_Parameter_Packet *p = (Drbd_Parameter_Packet*)h;
 	int consider_sync;
 	int oo_state;
-	sector_t p_size;
+	sector_t p_size, p_usize;
 
 	if (h->length != (sizeof(*p)-sizeof(*h))) {
 		ERR("Incompatible packet size of Parameter packet!\n");
@@ -1425,12 +1425,29 @@
 
 	set_bit(MD_DIRTY,&mdev->flags); // we are changing state!
 
-	if( mdev->lo_usize != be64_to_cpu(p->u_size) ) {
-		mdev->lo_usize = be64_to_cpu(p->u_size);
+	p_usize=be64_to_cpu(p->u_size);
+	/*
+	 * you may get a flip-flop connection established/connection loss, in
+	 * case both really have different usize uppon first connect!
+	 * try to solve it thus:
+	 ***/
+#define min_not_zero(l, r) (l == 0) ? r : ((r == 0) ? l : min(l, r))
+	if (mdev->cstate == WFReportParams) {
+		/* this is first connect, or an otherwise expected param
+		 * exchange.  choose the minimum */
+		p_usize = min_not_zero(mdev->lo_usize, p_usize);
+	} else {
+		/* this was an "unexpected" param packet,
+		 * just do what the peer suggests */
+	}
+#undef min_not_zero
+	if( mdev->lo_usize != p_usize ) {
+		mdev->lo_usize = p_usize;
 		INFO("Peer sets u_size to %lu KB\n",
 		     (unsigned long)mdev->lo_usize);
 	}
 
+
 /*lge:
  * FIXME
  * please get the order of tests (re)settings for consider_sync



More information about the drbd-cvs mailing list