[DRBD-cvs] r1448 - trunk/drbd

drbd-user@lists.linbit.com drbd-user@lists.linbit.com
Thu, 22 Jul 2004 19:42:00 +0200 (CEST)


Author: lars
Date: 2004-07-22 19:42:00 +0200 (Thu, 22 Jul 2004)
New Revision: 1448

Modified:
   trunk/drbd/drbd_bitmap.c
   trunk/drbd/drbd_fs.c
   trunk/drbd/drbd_receiver.c
Log:
- removed some FIXME comments about implementing the HandShake packet:
  it is implemented now...
- log something to syslog when someone forced ("--do-what-I-say") us to become primary.
- fix placement in drbd_bm_(un)lock in receive_param and drbd_sync_handshake;
  commented the dump_stack() there, it's just too noisy for "normal users".
  but leave it there, until we properly restructured the code somewhen...


Modified: trunk/drbd/drbd_bitmap.c
===================================================================
--- trunk/drbd/drbd_bitmap.c	2004-07-21 12:16:53 UTC (rev 1447)
+++ trunk/drbd/drbd_bitmap.c	2004-07-22 17:42:00 UTC (rev 1448)
@@ -130,7 +130,12 @@
 	} else if (DRBD_ratelimit(5*HZ,5)) {
 		ERR("%s:%d: bitmap already locked by %s:%lu\n",
 		    file, line, b->bm_file,b->bm_line);
+		/*
 		dump_stack();
+		ERR("This is no oops, but debug stack trace only.\n");
+		ERR("If you get this often, or in reproducable situations, "
+		    "notify <drbd-devel@linbit.com>\n");
+		*/
 	}
 	spin_unlock_irq(&b->bm_lock);
 }
@@ -141,6 +146,8 @@
 	if (!__test_and_clear_bit(BM_LOCKED,&mdev->bitmap->bm_flags)) {
 		D_ASSERT(0);
 	} else {
+		/* FIXME if we got a "is already locked" previously,
+		 * we unlock here even though we actually MUST NOT do so... */
 		b->bm_file = NULL;
 		b->bm_line = -1;
 	}

Modified: trunk/drbd/drbd_fs.c
===================================================================
--- trunk/drbd/drbd_fs.c	2004-07-21 12:16:53 UTC (rev 1447)
+++ trunk/drbd/drbd_fs.c	2004-07-22 17:42:00 UTC (rev 1448)
@@ -745,8 +745,16 @@
 	 * but that means someone is misusing DRBD...
 	 * */
 
-	if (forced) {
-		/* this was --do-what-I-say ... */
+	if (forced) { /* this was --do-what-I-say ... */
+		int i;
+		// drbd_dump_md(mdev,0,0);
+		for (i=HumanCnt; i < GEN_CNT_SIZE ; i++) {
+			if (mdev->gen_cnt[i] != 1) {
+				WARN("Forcefully set consistent! "
+				     "If this screws your data, don't blame DRBD!\n");
+				break;
+			}
+		}
 		drbd_md_set_flag(mdev,MDF_Consistent);
 	}
 	set_bit(MD_DIRTY,&mdev->flags); // we are changing state!

Modified: trunk/drbd/drbd_receiver.c
===================================================================
--- trunk/drbd/drbd_receiver.c	2004-07-21 12:16:53 UTC (rev 1447)
+++ trunk/drbd/drbd_receiver.c	2004-07-22 17:42:00 UTC (rev 1448)
@@ -1273,7 +1273,9 @@
 			set_cstate(mdev,WFBitMapS);
 			wait_event(mdev->cstate_wait,
 			     atomic_read(&mdev->ap_bio_cnt)==0);
+			drbd_bm_lock(mdev);   // {
 			drbd_send_bitmap(mdev);
+			drbd_bm_unlock(mdev); // }
 		} else { // have_good == -1
 			if ( (mdev->state == Primary) &&
 			     drbd_md_test_flag(mdev,MDF_Consistent) ) {
@@ -1294,6 +1296,7 @@
 		}
 	} else {
 		set_cstate(mdev,Connected);
+		drbd_bm_lock(mdev);   // {
 		if(drbd_bm_total_weight(mdev)) {
 			if (drbd_md_test_flag(mdev,MDF_Consistent)) {
 				/* We are not going to do a resync but there
@@ -1309,6 +1312,7 @@
 				WARN("I am inconsistent, but there is no sync? BOTH nodes inconsistent!\n");
 			}
 		}
+		drbd_bm_unlock(mdev); // }
 	}
 
 	if (have_good == -1) {
@@ -1328,15 +1332,6 @@
 	int oo_state;
 	unsigned long p_size;
 
-	/* FIXME never change the size of the first handshake packet again.
-	 * I think we should introduce a protocol version handshake
-	 * independently of the other parameters. */
-
-	/* we expect 72 byte.
-	 * unfortunately h->length of drbd-0.6 Parameter_Packet is 72, too,
-	 * but it includes the header size itself, so there are only 64 byte
-	 * remaining...
-	 */
 	if (h->length != (sizeof(*p)-sizeof(*h))) {
 		ERR("Incompatible packet size of Parameter packet!\n");
 		set_cstate(mdev,StandAlone);
@@ -1344,10 +1339,6 @@
 		return FALSE;
 	}
 
-	/* FIXME. If this connects to some drbd 0.6.X, it will timeout,
-	 * and reconnect, in a loop, forever. annoying!
-	 * maybe we want to change the on-the-wire-magic?
-	 */
 	if (drbd_recv(mdev, h->payload, h->length) != h->length)
 		return FALSE;
 
@@ -1411,7 +1402,7 @@
 		return FALSE;
 	}
 
-	drbd_bm_lock(mdev);
+	drbd_bm_lock(mdev); // {
 	mdev->p_size=p_size;
 
 	set_bit(MD_DIRTY,&mdev->flags); // we are changing state!
@@ -1425,6 +1416,8 @@
 	consider_sync = (mdev->cstate == WFReportParams);
 	if(drbd_determin_dev_size(mdev)) consider_sync=0;
 
+	drbd_bm_unlock(mdev); // }
+
 	if(be32_to_cpu(p->flags)&1) {
 		consider_sync=1;
 		drbd_send_param(mdev,2);
@@ -1513,9 +1506,7 @@
 		      nodestate_to_name(mdev->state),
 		      nodestate_to_name(mdev->o_state) );
 	}
-
 	drbd_md_write(mdev); // update connected indicator, la_size, ...
-	drbd_bm_unlock(mdev);
 
 	return TRUE;
 }
@@ -1534,7 +1525,7 @@
 	unsigned long *buffer;
 	int ok=FALSE;
 
-	drbd_bm_lock(mdev);
+	drbd_bm_lock(mdev);  // {
 
 	bm_words = drbd_bm_words(mdev);
 	bm_i     = 0;
@@ -1582,7 +1573,7 @@
 
 	ok=TRUE;
  out:
-	drbd_bm_unlock(mdev);
+	drbd_bm_unlock(mdev); // }
 	vfree(buffer);
 	return ok;
 }
@@ -1644,7 +1635,7 @@
 	 * otherwise this does not make much sense, no?
 	 * and some other assertion maybe about cstate...
 	 */
-	ERR_IF(mdev->cstate == Secondary) return FALSE;
+	ERR_IF(mdev->cstate != Secondary) return FALSE;
 
 	drbd_bm_lock(mdev);
 	drbd_bm_set_all(mdev);
@@ -1935,7 +1926,7 @@
 			      "Peer wants protocol version: %u\n",
 			      p->protocol_version );
 		}
-		INFO( "Handshake successful: DRBD Protocol version %u\n",
+		INFO( "Handshake successful: DRBD Network Protocol version %u\n",
 		      PRO_VERSION );
 	} /* else if ( p->protocol_version == (PRO_VERSION-1) ) {
 		// not yet; but next time :)