[DRBD-cvs] svn commit by phil - r3031 - in branches/drbd-8.2: drbd drbd/linux scripts user - Unfinished work on the data-checksum feature.

drbd-cvs at lists.linbit.com drbd-cvs at lists.linbit.com
Tue Aug 28 21:44:20 CEST 2007


Author: phil
Date: 2007-08-28 21:44:18 +0200 (Tue, 28 Aug 2007)
New Revision: 3031

Modified:
   branches/drbd-8.2/drbd/drbd_int.h
   branches/drbd-8.2/drbd/drbd_main.c
   branches/drbd-8.2/drbd/drbd_proc.c
   branches/drbd-8.2/drbd/drbd_receiver.c
   branches/drbd-8.2/drbd/linux/drbd_config.h
   branches/drbd-8.2/drbd/linux/drbd_nl.h
   branches/drbd-8.2/scripts/drbd.conf
   branches/drbd-8.2/user/drbdadm_scanner.fl
   branches/drbd-8.2/user/drbdsetup.c
Log:
Unfinished work on the data-checksum feature.


Modified: branches/drbd-8.2/drbd/drbd_int.h
===================================================================
--- branches/drbd-8.2/drbd/drbd_int.h	2007-08-28 19:42:59 UTC (rev 3030)
+++ branches/drbd-8.2/drbd/drbd_int.h	2007-08-28 19:44:18 UTC (rev 3031)
@@ -346,7 +346,8 @@
 		[NegRSDReply]	   = "NegRSDReply",
 		[BarrierAck]	   = "BarrierAck",
 		[StateChgRequest]  = "StateChgRequest",
-		[StateChgReply]    = "StateChgReply"
+		[StateChgReply]    = "StateChgReply",
+		[IntegrityAlg]     = "IntegrityAlg"
 	};
 
 	if (Data > cmd || cmd >= MAX_CMD) {
@@ -450,14 +451,16 @@
 
 struct Drbd_HandShake_Packet {
 	struct Drbd_Header head;	/* 8 bytes */
-	u32 protocol_version;
+	u32 protocol_min;
 	u32 feature_flags;
+	u32 protocol_max;
 
 	/* should be more than enough for future enhancements
 	 * for now, feature_flags and the reserverd array shall be zero.
 	 */
 
-	u64 reserverd[8];
+	u32 _pad;
+	u64 reserverd[7];
 } __attribute((packed));
 /* 80 bytes, FIXED for the next century */
 
@@ -783,6 +786,7 @@
 
 	struct drbd_socket data; /* data/barrier/cstate/parameter packets */
 	struct drbd_socket meta; /* ping/ack (metadata) packets */
+	int agreed_pro_version;  /* actually used protocol version */
 	unsigned long last_received; /* in jiffies, either socket */
 	unsigned int ko_count;
 	struct drbd_work  resync_work,

Modified: branches/drbd-8.2/drbd/drbd_main.c
===================================================================
--- branches/drbd-8.2/drbd/drbd_main.c	2007-08-28 19:42:59 UTC (rev 3030)
+++ branches/drbd-8.2/drbd/drbd_main.c	2007-08-28 19:44:18 UTC (rev 3031)
@@ -1312,6 +1312,7 @@
 
 int drbd_send_protocol(struct drbd_conf *mdev)
 {
+	int rv;
 	struct Drbd_Protocol_Packet p;
 
 	p.protocol      = cpu_to_be32(mdev->net_conf->wire_protocol);
@@ -1321,8 +1322,16 @@
 	p.want_lose     = cpu_to_be32(mdev->net_conf->want_lose);
 	p.two_primaries = cpu_to_be32(mdev->net_conf->two_primaries);
 
-	return drbd_send_cmd(mdev, USE_DATA_SOCKET, ReportProtocol,
-			     (struct Drbd_Header *)&p, sizeof(p));
+	if (mdev->agreed_pro_version >= 87) {
+		rv = drbd_send_cmd2(mdev, USE_DATA_SOCKET, ReportProtocol,
+				    (struct Drbd_Header *)&p, sizeof(p),
+				    mdev->net_conf->integrity_alg,
+				    strlen(mdev->net_conf->integrity_alg));
+	} else { 
+		rv = drbd_send_cmd(mdev, USE_DATA_SOCKET, ReportProtocol,
+				   (struct Drbd_Header *)&p, sizeof(p));
+	}
+	return rv;
 }
 
 int drbd_send_uuids(struct drbd_conf *mdev)
@@ -3143,7 +3152,7 @@
 	switch (cmd) {
 	case HandShake:
 		INFOP("%s (protocol %u)\n", cmdname(cmd),
-			be32_to_cpu(p->HandShake.protocol_version));
+			be32_to_cpu(p->HandShake.protocol_min));
 		break;
 
 	case ReportBitMap: /* don't report this */

Modified: branches/drbd-8.2/drbd/drbd_proc.c
===================================================================
--- branches/drbd-8.2/drbd/drbd_proc.c	2007-08-28 19:42:59 UTC (rev 3030)
+++ branches/drbd-8.2/drbd/drbd_proc.c	2007-08-28 19:44:18 UTC (rev 3031)
@@ -177,8 +177,8 @@
 	const char *sn;
 	struct drbd_conf *mdev;
 
-	seq_printf(seq, "version: " REL_VERSION " (api:%d/proto:%d)\n%s\n",
-		    API_VERSION, PRO_VERSION, drbd_buildtag());
+	seq_printf(seq, "version: " REL_VERSION " (api:%d/proto:%d-%d)\n%s\n",
+		   API_VERSION, PRO_VERSION_MIN, PRO_VERSION_MAX, drbd_buildtag());
 
 	/*
 	  cs .. connection state

Modified: branches/drbd-8.2/drbd/drbd_receiver.c
===================================================================
--- branches/drbd-8.2/drbd/drbd_receiver.c	2007-08-28 19:42:59 UTC (rev 3030)
+++ branches/drbd-8.2/drbd/drbd_receiver.c	2007-08-28 19:44:18 UTC (rev 3031)
@@ -2051,12 +2051,16 @@
 int receive_protocol(struct drbd_conf *mdev, struct Drbd_Header *h)
 {
 	struct Drbd_Protocol_Packet *p = (struct Drbd_Protocol_Packet *)h;
+	int header_size, data_size;
 
 	int p_proto, p_after_sb_0p, p_after_sb_1p, p_after_sb_2p;
 	int p_want_lose, p_two_primaries;
+	char p_integrity_alg[SHARED_SECRET_MAX] = "";
 
-	ERR_IF(h->length != (sizeof(*p)-sizeof(*h))) return FALSE;
-	if (drbd_recv(mdev, h->payload, h->length) != h->length)
+	header_size = sizeof(*p) - sizeof(*h);
+	data_size   = h->length  - header_size;
+
+	if (drbd_recv(mdev, h->payload, header_size) != header_size)
 		return FALSE;
 
 	p_proto		= be32_to_cpu(p->protocol);
@@ -2096,6 +2100,17 @@
 		goto disconnect;
 	}
 
+	if (mdev->agreed_pro_version >= 87) {
+		if (drbd_recv(mdev, integrity_alg, data_size) != data_size)
+			return FALSE;
+
+		integrity_alg[SHARED_SECRET_MAX-1]=0;
+		if(strcmp(integrity_alg, mdev->net_conf->integrity_alg)) {
+			ERR("incompatible setting of the data-integrity-alg\n");
+			goto disconnect;
+		}
+	}
+
 	return TRUE;
 
  disconnect:
@@ -2740,8 +2755,8 @@
 }
 
 /*
- * we hereby assure that we always support the drbd dialects
- * PRO_VERSION and (PRO_VERSION -1), allowing for rolling upgrades
+ * We support PRO_VERSION_MIN to PRO_VERSION_MAX. The protocol version
+ * we can agree on is stored in agreed_pro_version.
  *
  * feature flags and the reserved array should be enough room for future
  * enhancements of the handshake protocol, and possible plugins...
@@ -2765,7 +2780,8 @@
 	}
 
 	memset(p, 0, sizeof(*p));
-	p->protocol_version = cpu_to_be32(PRO_VERSION);
+	p->protocol_min = cpu_to_be32(PRO_VERSION_MIN);
+	p->protocol_max = cpu_to_be32(PRO_VERSION_MAX);
 	ok = _drbd_send_cmd( mdev, mdev->data.socket, HandShake,
 			     (struct Drbd_Header *)p, sizeof(*p), 0 );
 	up(&mdev->data.mutex);
@@ -2817,31 +2833,27 @@
 	dump_packet(mdev, mdev->data.socket, 2, &mdev->data.rbuf,
 			__FILE__, __LINE__);
 
-	p->protocol_version = be32_to_cpu(p->protocol_version);
+	p->protocol_min = be32_to_cpu(p->protocol_min);
+	p->protocol_max = be32_to_cpu(p->protocol_max);
+	if(p->protocol_max == 0) p->protocol_max = p->protocol_min;
 
-	if ( p->protocol_version == PRO_VERSION ||
-	     p->protocol_version == (PRO_VERSION+1) ) {
-		if (p->protocol_version == (PRO_VERSION+1)) {
-			WARN( "You should upgrade me! "
-			      "Peer wants protocol version: %u\n",
-			      p->protocol_version );
-		}
-		INFO("Handshake successful: "
-		     "DRBD Network Protocol version %u\n", PRO_VERSION);
-	} /* else if ( p->protocol_version == (PRO_VERSION-1) ) {
-		// not yet; but next time :)
-		INFO( "Handshake successful: DRBD Protocol version %u\n",
-		      (PRO_VERSION-1) );
-		... do some remapping of defaults and jump tables here ...
-	} */ else {
-		ERR( "incompatible DRBD dialects: "
-		     "I support %u, peer wants %u\n",
-		     PRO_VERSION, p->protocol_version );
-		return -1;
-	}
+	if (PRO_VERSION_MAX < p->protocol_min ) goto incompat;
+	if (PRO_VERSION_MIN > p->protocol_max ) goto incompat;
 
+	mdev->agreed_pro_version = min(PRO_VERSION_MAX,p->protocol_max);
+
+	INFO("Handshake successful: "
+	     "Agreed network protocol version %d\n", mdev->agreed_pro_version);
+
 	return 1;
 
+ incompat:
+	ERR("incompatible DRBD dialects: "
+	    "I support %d-%d, peer supports %d-%d\n",
+	    PRO_VERSION_MIN,PRO_VERSION_MAX, 
+	    p->protocol_min, p->protocol_max);
+	return -1;
+
  break_c_loop:
 	WARN( "My msock connect got accepted onto peer's sock!\n");
 	/* In case a tcp connection set-up takes longer than

Modified: branches/drbd-8.2/drbd/linux/drbd_config.h
===================================================================
--- branches/drbd-8.2/drbd/linux/drbd_config.h	2007-08-28 19:42:59 UTC (rev 3030)
+++ branches/drbd-8.2/drbd/linux/drbd_config.h	2007-08-28 19:44:18 UTC (rev 3031)
@@ -24,7 +24,8 @@
 
 #define REL_VERSION "8.1.0-nqty" /* not quite there yet */
 #define API_VERSION 86
-#define PRO_VERSION 86
+#define PRO_VERSION_MIN 86
+#define PRO_VERSION_MAX 87
 
 /* no static functs, improves quality of OOPS traces
  */

Modified: branches/drbd-8.2/drbd/linux/drbd_nl.h
===================================================================
--- branches/drbd-8.2/drbd/linux/drbd_nl.h	2007-08-28 19:42:59 UTC (rev 3030)
+++ branches/drbd-8.2/drbd/linux/drbd_nl.h	2007-08-28 19:44:18 UTC (rev 3031)
@@ -34,6 +34,7 @@
 	STRING(		9,	T_MANDATORY,	peer_addr,	128)
 	STRING(		10,	T_MAY_IGNORE,	shared_secret,	SHARED_SECRET_MAX)
 	STRING(		11,	T_MAY_IGNORE,	cram_hmac_alg,	SHARED_SECRET_MAX)
+	STRING(		44,	T_MAY_IGNORE,	integrity_alg,	SHARED_SECRET_MAX)
 	INTEGER(	14,	T_MAY_IGNORE,	timeout)
 	INTEGER(	15,	T_MANDATORY,	wire_protocol)
 	INTEGER(	16,	T_MAY_IGNORE,	try_connect_int)

Modified: branches/drbd-8.2/scripts/drbd.conf
===================================================================
--- branches/drbd-8.2/scripts/drbd.conf	2007-08-28 19:42:59 UTC (rev 3030)
+++ branches/drbd-8.2/scripts/drbd.conf	2007-08-28 19:44:18 UTC (rev 3031)
@@ -333,6 +333,15 @@
     #   after-sb-0pri discard-younger-primary;
     #   after-sb-1pri consensus;
     #   after-sb-2pri disconnect;
+
+    # DRBD can ensure the data integrity of the user's data on the network
+    # by comparing hash values. 
+    # Note: Normally this is ensured by the 16 bit checksums in the headers 
+    # of TCP/IP packets. Unforunately it turned out that GBit NICs with 
+    # various offloading engines might produce valid checksums for corrupted 
+    # data. Use this option during your pre-production tests, usually you
+    # want to turn it off for production to reduce CPU overhead.
+    # data-integrity-alg "md5";
   }
 
   syncer {

Modified: branches/drbd-8.2/user/drbdadm_scanner.fl
===================================================================
--- branches/drbd-8.2/user/drbdadm_scanner.fl	2007-08-28 19:42:59 UTC (rev 3030)
+++ branches/drbd-8.2/user/drbdadm_scanner.fl	2007-08-28 19:44:18 UTC (rev 3031)
@@ -81,6 +81,7 @@
 rr-conflict 		{ DP; CP; return TK_NET_OPTION;		}
 ping-timeout 		{ DP; CP; return TK_NET_OPTION;		}
 unplug-watermark	{ DP; CP; return TK_NET_OPTION;         }
+data-integrity-alg	{ DP; CP; return TK_NET_OPTION;         }
 allow-two-primaries	{ DP; CP; return TK_NET_SWITCH;		}
 always-asbp		{ DP; CP; return TK_NET_SWITCH;		}
 rate			{ DP; CP; RC(RATE); return TK_SYNCER_OPTION;	}

Modified: branches/drbd-8.2/user/drbdsetup.c
===================================================================
--- branches/drbd-8.2/user/drbdsetup.c	2007-08-28 19:42:59 UTC (rev 3030)
+++ branches/drbd-8.2/user/drbdsetup.c	2007-08-28 19:44:18 UTC (rev 3031)
@@ -309,6 +309,7 @@
 		 { "rr-conflict",'R',	T_rr_conflict,EH(rrcf_n,RR_CONFLICT) },
 		 { "ping-timeout",'p',  T_ping_timeo,	   EN(PING_TIMEO,1,"1/10 seconds") },
 		 { "discard-my-data",'D', T_want_lose,     EB },
+		 { "data-integrity-alg",'d', T_want_lose,     EB },
 		 CLOSE_OPTIONS }} }, },
 
 	{"disconnect", P_disconnect, F_CONFIG_CMD, {{NULL, NULL}} },



More information about the drbd-cvs mailing list