From drbd-cvs at lists.linbit.com  Wed Aug  1 16:26:13 2007
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Wed Aug  1 16:26:16 2007
Subject: [DRBD-cvs] svn commit by phil - r3004 - branches/drbd-8.0/drbd -
	Fixed a bug that was introduced with 8.0.1 (r2737). In 
Message-ID: <20070801142613.E9C3440095@garcon1.linbit.com>

Author: phil
Date: 2007-08-01 16:26:12 +0200 (Wed, 01 Aug 2007)
New Revision: 3004

Modified:
   branches/drbd-8.0/drbd/drbd_worker.c
Log:
Fixed a bug that was introduced with 8.0.1 (r2737). In case you slowed
down the resync speed during a running resync process considerabely, you
could trigger a bug in w_make_resync_request(), that causes the local_cnt 
to go below zero.

When the number of requests that should be on the fly for the new
(lower) resync speed is higher than the number of requests that are 
currently on the fly, we had that "goto requeue:". In the exit path of 
the function we decreased the local_cnt by one...



Modified: branches/drbd-8.0/drbd/drbd_worker.c
===================================================================
--- branches/drbd-8.0/drbd/drbd_worker.c	2007-07-27 13:07:19 UTC (rev 3003)
+++ branches/drbd-8.0/drbd/drbd_worker.c	2007-08-01 14:26:12 UTC (rev 3004)
@@ -325,13 +325,6 @@
 		ERR("%s in w_make_resync_request\n", conns_to_name(mdev->state.conn));
 	}
 
-        number = SLEEP_TIME*mdev->sync_conf.rate / ((BM_BLOCK_SIZE/1024)*HZ);
-
-	if (atomic_read(&mdev->rs_pending_cnt)>number) {
-		goto requeue;
-	}
-	number -= atomic_read(&mdev->rs_pending_cnt);
-
 	if(!inc_local(mdev)) {
 		/* Since we only need to access mdev->rsync a
 		   inc_local_if_state(mdev,Failed) would be sufficient, but
@@ -341,7 +334,15 @@
 		mdev->resync_work.cb = w_resync_inactive;
 		return 1;
 	}
+	/* All goto requeses have to happend after this block: inc_local() */
 
+	number = SLEEP_TIME*mdev->sync_conf.rate / ((BM_BLOCK_SIZE/1024)*HZ);
+
+	if (atomic_read(&mdev->rs_pending_cnt)>number) {
+		goto requeue;
+	}
+	number -= atomic_read(&mdev->rs_pending_cnt);
+
 	for(i=0;i<number;i++) {
 
 	next_sector:

From drbd-cvs at lists.linbit.com  Wed Aug  1 17:05:53 2007
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Wed Aug  1 17:05:55 2007
Subject: [DRBD-cvs] svn commit by phil - r3005 - branches/drbd-8.0/drbd -
	Ernest pointed out that we erroneously created a new cu
Message-ID: <20070801150553.69B6640095@garcon1.linbit.com>

Author: phil
Date: 2007-08-01 17:05:52 +0200 (Wed, 01 Aug 2007)
New Revision: 3005

Modified:
   branches/drbd-8.0/drbd/drbd_main.c
Log:
Ernest pointed out that we erroneously created a new current_id
each time a diskless peer become secondary. We should do that
only the first time...

By the way, I enlosed this in a inc_local() - dec_local() pair, 
since mdev->bc gets dereferenced in this code block. 



Modified: branches/drbd-8.0/drbd/drbd_main.c
===================================================================
--- branches/drbd-8.0/drbd/drbd_main.c	2007-08-01 14:26:12 UTC (rev 3004)
+++ branches/drbd-8.0/drbd/drbd_main.c	2007-08-01 15:05:52 UTC (rev 3005)
@@ -931,15 +931,17 @@
 		}
 	}
 
-	if( ns.pdsk < Inconsistent ) {
+	if (ns.pdsk < Inconsistent && inc_local(mdev)) {
 		/* Diskless Peer becomes primary */
-		if (os.peer == Secondary && ns.peer == Primary ) {
+		if (os.peer == Secondary && ns.peer == Primary &&
+		    mdev->bc->md.uuid[Bitmap] == 0) {
 			drbd_uuid_new_current(mdev);
 		}
 		/* Diskless Peer becomes secondary */
 		if (os.peer == Primary && ns.peer == Secondary ) {
 			drbd_al_to_on_disk_bm(mdev);
 		}
+		dec_local(mdev);
 	}
 
 	/* Last part of the attaching process ... */

From drbd-cvs at lists.linbit.com  Thu Aug  2 11:35:18 2007
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Thu Aug  2 11:35:21 2007
Subject: [DRBD-cvs] svn commit by phil - r3006 - branches/drbd-8.0/drbd -
	Ernest pointed this out. When we attach a disk to a con
Message-ID: <20070802093518.093BA40095@garcon1.linbit.com>

Author: phil
Date: 2007-08-02 11:35:17 +0200 (Thu, 02 Aug 2007)
New Revision: 3006

Modified:
   branches/drbd-8.0/drbd/drbd_main.c
Log:
Ernest pointed this out.

When we attach a disk to a connected device pair, we are in
disk state Nogotiating on the node that gets the disk attached.

When in the mean time some event on the peer node triggers
the transmittion of a state packet, we might end up using an
old p_uuid set and find a wrong resync decission.

Fixed that.


Modified: branches/drbd-8.0/drbd/drbd_main.c
===================================================================
--- branches/drbd-8.0/drbd/drbd_main.c	2007-08-01 15:05:52 UTC (rev 3005)
+++ branches/drbd-8.0/drbd/drbd_main.c	2007-08-02 09:35:17 UTC (rev 3006)
@@ -947,6 +947,8 @@
 	/* Last part of the attaching process ... */
 	if ( ns.conn >= Connected && 
 	     os.disk == Attaching && ns.disk == Negotiating ) {
+		kfree(mdev->p_uuid); /* We expect to receive up-to-date UUIDs soon. */
+		mdev->p_uuid = NULL; /* ...to not use the old ones in the mean time */
 		drbd_send_sizes(mdev);  // to start sync...
 		drbd_send_uuids(mdev);
 		drbd_send_state(mdev);

From drbd-cvs at lists.linbit.com  Thu Aug  2 14:58:34 2007
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Thu Aug  2 14:58:35 2007
Subject: [DRBD-cvs] svn commit by phil - r3007 - in branches/drbd-8.0:
	documentation scripts user - Implemented the wait-after-sb
	option for the startup se
Message-ID: <20070802125834.41FE340095@garcon1.linbit.com>

Author: phil
Date: 2007-08-02 14:58:32 +0200 (Thu, 02 Aug 2007)
New Revision: 3007

Modified:
   branches/drbd-8.0/documentation/drbd.conf.sgml
   branches/drbd-8.0/documentation/drbdsetup.sgml
   branches/drbd-8.0/scripts/drbd.conf
   branches/drbd-8.0/user/drbdadm_scanner.fl
   branches/drbd-8.0/user/drbdsetup.c
Log:
Implemented the wait-after-sb option for the startup section.
AND CHANGED THE DEFAULT BEHAVIOUR OF THE INIT SCRIPT.


Modified: branches/drbd-8.0/documentation/drbd.conf.sgml
===================================================================
--- branches/drbd-8.0/documentation/drbd.conf.sgml	2007-08-02 09:35:17 UTC (rev 3006)
+++ branches/drbd-8.0/documentation/drbd.conf.sgml	2007-08-02 12:58:32 UTC (rev 3007)
@@ -217,7 +217,8 @@
     <manvolnum>8</manvolnum></citerefentry> for a detailed description
     of this section's parameters.
     Optional parameters:
-    <option>wfc-timeout</option>, <option>degr-wfc-timeout</option>.
+    <option>wfc-timeout</option>, <option>degr-wfc-timeout</option> and
+    <option>wait-after-sb</option>.
   </para>
   </listitem>
 </varlistentry>
@@ -835,6 +836,16 @@
 </varlistentry>
 
 <varlistentry>
+  <term><option>wait-after-sb</option></term>
+  <listitem><para>
+  By setting this option you can make the init script to continue 
+  to wait even if the device pair had a split brain situation
+  and therefore refuses to connect.
+  </para>
+  </listitem>
+</varlistentry>
+
+<varlistentry>
   <term><option>rate <replaceable>rate</replaceable></option></term>
   <listitem><para>
   <indexterm><primary>drbd.conf</primary><secondary>rate </secondary></indexterm>

Modified: branches/drbd-8.0/documentation/drbdsetup.sgml
===================================================================
--- branches/drbd-8.0/documentation/drbdsetup.sgml	2007-08-02 09:35:17 UTC (rev 3006)
+++ branches/drbd-8.0/documentation/drbdsetup.sgml	2007-08-02 12:58:32 UTC (rev 3007)
@@ -103,16 +103,18 @@
     <cmdsynopsis>
       <command>drbdsetup</command>
       <arg choice="req"><replaceable>device</replaceable></arg>
-      <arg choice="req">wait_connect</arg>
+      <arg choice="req">wait-connect</arg>
       <arg>-t<arg choice="req"><replaceable>wfc_timeout</replaceable></arg></arg>
       <arg>-d<arg choice="req"><replaceable>degr_wfc_timeout</replaceable></arg></arg>
+      <arg>-w</arg>
     </cmdsynopsis>
     <cmdsynopsis>
       <command>drbdsetup</command>
       <arg choice="req"><replaceable>device</replaceable></arg>
-      <arg choice="req">wait_sync</arg>
+      <arg choice="req">wait-sync</arg>
       <arg>-t<arg choice="req"><replaceable>wfc_timeout</replaceable></arg></arg>
       <arg>-d<arg choice="req"><replaceable>degr_wfc_timeout</replaceable></arg></arg>
+      <arg>-w</arg>
     </cmdsynopsis>
     <cmdsynopsis>
       <command>drbdsetup</command>
@@ -817,8 +819,8 @@
       </para>
     </refsect2>
     <refsect2>
-      <title>wait_connect</title>
-      <indexterm><primary>drbdsetup</primary><secondary>wait_connect</secondary></indexterm>
+      <title>wait-connect</title>
+      <indexterm><primary>drbdsetup</primary><secondary>wait-connect</secondary></indexterm>
       <para>
 	Returns as soon as the <replaceable>device</replaceable> can
 	communicate with its partner device.
@@ -829,6 +831,7 @@
 	  <option>--wfc-timeout <replaceable>wfc_timeout</replaceable></option></term>
 	  <term><option>-d</option>,
 	  <option>--degr-wfc-timeout <replaceable>degr_wfc_timeout</replaceable></option></term>
+	  <term><option>-w</option>, <option>--wait-after-sb</option></term>
 	  <listitem>
 	    <para>
 	      This command will fail if the
@@ -841,18 +844,22 @@
 	      The default value for <replaceable>wfc_timeout</replaceable>
 	      is 0 which means to wait forever. The default for
 	      <replaceable>degr_wfc_timeout</replaceable> is 120 seconds.
+	      In case the connection status goes down to StandAlone because
+              the peer appeared but the devices had a split brain situation,
+              the default for the command is to terminate. You can change this
+              behaviour with the <option>--wait-after-sb</option> option.
 	    </para>
 	  </listitem>
 	</varlistentry>
       </variablelist>
     </refsect2>
     <refsect2>
-      <title>wait_sync</title>
-      <indexterm><primary>drbdsetup</primary><secondary>wait_sync</secondary></indexterm>
+      <title>wait-sync</title>
+      <indexterm><primary>drbdsetup</primary><secondary>wait-sync</secondary></indexterm>
       <para>
 	Returns as soon as the <replaceable>device</replaceable> leaves any
 	synchronisation into connected state. The options
-	are the same as with the <replaceable>wait_connect</replaceable>
+	are the same as with the <replaceable>wait-connect</replaceable>
 	command.
       </para>
     </refsect2>

Modified: branches/drbd-8.0/scripts/drbd.conf
===================================================================
--- branches/drbd-8.0/scripts/drbd.conf	2007-08-02 09:35:17 UTC (rev 3006)
+++ branches/drbd-8.0/scripts/drbd.conf	2007-08-02 12:58:32 UTC (rev 3007)
@@ -161,6 +161,15 @@
     # is rebooted, this timeout value is used.
     #
     degr-wfc-timeout 120;    # 2 minutes.
+
+    # In case there was a split brain situation the devices will
+    # drop their network configuration instead of connecting. Since
+    # this means that the network is working, the cluster manager
+    # should be able to communicate as well. Therefore the default
+    # of DRBD's init script is to terminate in this case. To make
+    # it to continue waiting in this case set this option.
+    # 
+    # wait-after-sb;
   }
 
   disk {

Modified: branches/drbd-8.0/user/drbdadm_scanner.fl
===================================================================
--- branches/drbd-8.0/user/drbdadm_scanner.fl	2007-08-02 09:35:17 UTC (rev 3006)
+++ branches/drbd-8.0/user/drbdadm_scanner.fl	2007-08-02 12:58:32 UTC (rev 3007)
@@ -88,6 +88,7 @@
 al-extents		{ DP; CP; RC(AL_EXTENTS); return TK_SYNCER_OPTION;}
 wfc-timeout		{ DP; CP; RC(WFC_TIMEOUT); return TK_STARTUP_OPTION;}
 degr-wfc-timeout	{ DP; CP; RC(DEGR_WFC_TIMEOUT); return TK_STARTUP_OPTION;}
+wait-after-sb		{ DP; CP; return TK_STARTUP_SWITCH;     }
 pri-on-incon-degr	{ DP; CP; return TK_HANDLER_OPTION;	}
 pri-lost-after-sb	{ DP; CP; return TK_HANDLER_OPTION;	}
 pri-lost	        { DP; CP; return TK_HANDLER_OPTION;     }

Modified: branches/drbd-8.0/user/drbdsetup.c
===================================================================
--- branches/drbd-8.0/user/drbdsetup.c	2007-08-02 09:35:17 UTC (rev 3006)
+++ branches/drbd-8.0/user/drbdsetup.c	2007-08-02 12:58:32 UTC (rev 3007)
@@ -124,7 +124,8 @@
 		} gp; // for generic_get_cmd, get_usage
 		struct {
 			struct option *options;
-			int (*proc_event)();
+			int (*proc_event)(unsigned int, int, 
+					  struct drbd_nl_cfg_reply *);
 		} ep; // for events_cmd, events_usage
 	};
 };
@@ -191,9 +192,9 @@
 void show_string(struct drbd_option *od, unsigned short* tp);
 
 // sub functions for events_cmd
-int print_state(unsigned int seq, struct drbd_nl_cfg_reply *reply);
-int w_connected_state(unsigned int seq, struct drbd_nl_cfg_reply *reply);
-int w_synced_state(unsigned int seq, struct drbd_nl_cfg_reply *reply);
+int print_state(unsigned int seq, int, struct drbd_nl_cfg_reply *reply);
+int w_connected_state(unsigned int seq, int, struct drbd_nl_cfg_reply *reply);
+int w_synced_state(unsigned int seq, int, struct drbd_nl_cfg_reply *reply);
 
 const char *on_error[] = {
 	[PassOn]         = "pass_on",
@@ -240,6 +241,7 @@
 struct option wait_cmds_options[] = {
 	{ "wfc-timeout",required_argument, 0, 't' },
 	{ "degr-wfc-timeout",required_argument,0,'d'},
+	{ "wait-after-sb",no_argument,0,'w'},
 	{ 0,            0,           0,  0  }
 };
 
@@ -1187,7 +1189,8 @@
 	return rv;
 }
 
-int print_state(unsigned int seq, struct drbd_nl_cfg_reply *reply)
+int print_state(unsigned int seq, int u __attribute((unused)),
+		struct drbd_nl_cfg_reply *reply)
 {
 	drbd_state_t state;
 	char* str;
@@ -1239,6 +1242,7 @@
 }
 
 int w_connected_state(unsigned int seq __attribute((unused)),
+		      int wait_after_sb,
 		      struct drbd_nl_cfg_reply *reply)
 {
 	drbd_state_t state;
@@ -1246,6 +1250,7 @@
 	if(reply->packet_type == P_get_state) {
 		if(consume_tag_int(T_state_i,reply->tag_list,(int*)&state.i)) {
 			if(state.conn >= Connected) return 0;
+			if(!wait_after_sb && state.conn < Unconnected) return 0;
 		} else fprintf(stderr,"Missing tag !?\n");
 	}
 
@@ -1253,14 +1258,15 @@
 }
 
 int w_synced_state(unsigned int seq __attribute((unused)),
+		   int wait_after_sb,
 		   struct drbd_nl_cfg_reply *reply)
 {
 	drbd_state_t state;
 
 	if(reply->packet_type == P_get_state) {
 		if(consume_tag_int(T_state_i,reply->tag_list,(int*)&state.i)) {
-			if(state.conn == Connected || state.conn < Unconnected )
-				return 0;
+			if(state.conn == Connected) return 0;
+			if(!wait_after_sb && state.conn < Unconnected) return 0;
 		} else fprintf(stderr,"Missing tag !?\n");
 	}
 	return 1;
@@ -1278,6 +1284,7 @@
 	int unfiltered=0, all_devices=0;
 	int wfc_timeout=0, degr_wfc_timeout=0,timeout_ms;
 	struct timeval before,after;
+	int wasb=0;
 
 	lo = cm->ep.options;
 
@@ -1307,6 +1314,9 @@
 				return 20;
 			}
 			break;
+		case 'w':
+			wasb=1;
+			break;
 		}
 	}
 
@@ -1381,7 +1391,7 @@
 		}
 
 		if( all_devices || minor == reply->minor ) {
-			cont=cm->ep.proc_event(cn_reply->seq, reply);
+			cont=cm->ep.proc_event(cn_reply->seq, wasb, reply);
 		}
 	} while(cont);
 

From drbd-cvs at lists.linbit.com  Thu Aug  2 16:15:49 2007
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Thu Aug  2 16:15:51 2007
Subject: [DRBD-cvs] svn commit by phil - r3008 - in branches/drbd-8.0: .
	debian drbd/linux - Preparing the 8.0.5 release. 
Message-ID: <20070802141549.A671D40095@garcon1.linbit.com>

Author: phil
Date: 2007-08-02 16:15:46 +0200 (Thu, 02 Aug 2007)
New Revision: 3008

Modified:
   branches/drbd-8.0/ChangeLog
   branches/drbd-8.0/debian/changelog
   branches/drbd-8.0/drbd.spec.in
   branches/drbd-8.0/drbd/linux/drbd_config.h
Log:
Preparing the 8.0.5 release.


Modified: branches/drbd-8.0/ChangeLog
===================================================================
--- branches/drbd-8.0/ChangeLog	2007-08-02 12:58:32 UTC (rev 3007)
+++ branches/drbd-8.0/ChangeLog	2007-08-02 14:15:46 UTC (rev 3008)
@@ -4,6 +4,38 @@
  Cumulative changes since last tarball.
  For even more detail, use "svn log" and "svn diff".
 
+8.0.5 (api:86/proto:86)
+--------
+ * Changed the default behaviour of the init script. Now the init
+   script terminates in case the devices refuse to because they 
+   had a split brain. Introduced an option to preserve the old
+   behaviour.
+ * Fixed a bug where the local_cnt could get imbalanced upon a 
+   state change.
+ * Fixed an bug in the UUID algorithm, that could lead to both
+   sides in cs:WFBitMapT state. It was triggered when the disk
+   on the SyncTarget gets detached and attached.
+ * Implemented proper size checking on strings that get communicated
+   with DRBD's netlink protocol.
+ * Changed the maximal length of device names from 32 characters to
+   128 characters. (udev based disk names might be very long nowadays)
+ * Fixed the after-sb-0pri policies discard-younger/discard-older
+ * When the resync speed was changed to a considerably lower 
+   value while resync was running, it could happen that we erronously
+   decremented the local_cnt too often.
+ * Fixed a bug in the UUID code, that caused drbd to erronously report 
+   a split brain after changing the role of a diskless node multiple 
+   times.
+ * Both nodes ended up in SyncSource when a state change occured on 
+   one node while the disk state on the other node is in the temporal 
+   'Negotiating' state. Fixed got fixed.
+ * drbdmeta's parse/scan code for meta-data dumps got fixed for 
+   huge devices, and an improved error reporting.
+ * Fixed a code path that should it make possible to unload the
+   module even in case some of our receive buffers leaked.
+ * The usermode helper program is now user definable. It is no
+   longer hardcoded set to 'drbdadm'.
+
 8.0.4 (api:86/proto:86)
 --------
  * Fixed an OOPS in case you do an invalidate on an diskless device. And

Modified: branches/drbd-8.0/debian/changelog
===================================================================
--- branches/drbd-8.0/debian/changelog	2007-08-02 12:58:32 UTC (rev 3007)
+++ branches/drbd-8.0/debian/changelog	2007-08-02 14:15:46 UTC (rev 3008)
@@ -1,3 +1,9 @@
+drbd8 (8.0.5-0) unstable; urgency=low
+
+  * New upstream release.
+
+ -- Philipp Reisner <phil@linbit.com>  Thu,  2 Aug 2007 16:12:26 +0200
+
 drbd8 (8.0.4-0) unstable; urgency=low
 
   * New upstream release.
@@ -2,3 +8,3 @@
 
- -- Philipp Reisner <phil@linbit.com>  Wed, 27 Jun 2007 10:0:00 +0200
+ -- Philipp Reisner <phil@linbit.com>  Wed, 27 Jun 2007 10:00:00 +0200
 

Modified: branches/drbd-8.0/drbd/linux/drbd_config.h
===================================================================
--- branches/drbd-8.0/drbd/linux/drbd_config.h	2007-08-02 12:58:32 UTC (rev 3007)
+++ branches/drbd-8.0/drbd/linux/drbd_config.h	2007-08-02 14:15:46 UTC (rev 3008)
@@ -22,7 +22,7 @@
 
 extern const char * drbd_buildtag(void);
 
-#define REL_VERSION "8.0.4"
+#define REL_VERSION "8.0.5"
 #define API_VERSION 86
 #define PRO_VERSION 86
 

Modified: branches/drbd-8.0/drbd.spec.in
===================================================================
--- branches/drbd-8.0/drbd.spec.in	2007-08-02 12:58:32 UTC (rev 3007)
+++ branches/drbd-8.0/drbd.spec.in	2007-08-02 14:15:46 UTC (rev 3008)
@@ -191,6 +191,38 @@
 /sbin/depmod -a -F /boot/System.map-%{kernelversion} %{kernelversion} >/dev/null 2>&1 || true
 
 %changelog
+* Thu Aug  2 2007 16:12:26 +0200 Philipp Reisner <phil@linbit.com>
+- drbd (8.0.4-1)
+ * Changed the default behaviour of the init script. Now the init
+   script terminates in case the devices refuse to because they 
+   had a split brain. Introduced an option to preserve the old
+   behaviour.
+ * Fixed a bug where the local_cnt could get imbalanced upon a 
+   state change.
+ * Fixed an bug in the UUID algorithm, that could lead to both
+   sides in cs:WFBitMapT state. It was triggered when the disk
+   on the SyncTarget gets detached and attached.
+ * Implemented proper size checking on strings that get communicated
+   with DRBD's netlink protocol.
+ * Changed the maximal length of device names from 32 characters to
+   128 characters. (udev based disk names might be very long nowadays)
+ * Fixed the after-sb-0pri policies discard-younger/discard-older
+ * When the resync speed was changed to a considerably lower 
+   value while resync was running, it could happen that we erronously
+   decremented the local_cnt too often.
+ * Fixed a bug in the UUID code, that caused drbd to erronously report 
+   a split brain after changing the role of a diskless node multiple 
+   times.
+ * Both nodes ended up in SyncSource when a state change occured on 
+   one node while the disk state on the other node is in the temporal 
+   'Negotiating' state. Fixed got fixed.
+ * drbdmeta's parse/scan code for meta-data dumps got fixed for 
+   huge devices, and an improved error reporting.
+ * Fixed a code path that should it make possible to unload the
+   module even in case some of our receive buffers leaked.
+ * The usermode helper program is now user definable. It is no
+   longer hardcoded set to 'drbdadm'.
+
 * Wed Jun 27 2007 10:00:00 +0200 Philipp Reisner <phil@linbit.com>
 - drbd (8.0.4-1)
  * Fixed an OOPS in case you do an invalidate on an diskless device. And

From drbd-cvs at lists.linbit.com  Thu Aug  2 16:17:20 2007
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Thu Aug  2 16:17:22 2007
Subject: [DRBD-cvs] svn commit by phil - r3009 - branches/drbd-8.0 - Typo
	fix. 
Message-ID: <20070802141720.F07CE40095@garcon1.linbit.com>

Author: phil
Date: 2007-08-02 16:17:20 +0200 (Thu, 02 Aug 2007)
New Revision: 3009

Modified:
   branches/drbd-8.0/drbd.spec.in
Log:
Typo fix.


Modified: branches/drbd-8.0/drbd.spec.in
===================================================================
--- branches/drbd-8.0/drbd.spec.in	2007-08-02 14:15:46 UTC (rev 3008)
+++ branches/drbd-8.0/drbd.spec.in	2007-08-02 14:17:20 UTC (rev 3009)
@@ -192,7 +192,7 @@
 
 %changelog
 * Thu Aug  2 2007 16:12:26 +0200 Philipp Reisner <phil@linbit.com>
-- drbd (8.0.4-1)
+- drbd (8.0.5-1)
  * Changed the default behaviour of the init script. Now the init
    script terminates in case the devices refuse to because they 
    had a split brain. Introduced an option to preserve the old

From drbd-cvs at lists.linbit.com  Thu Aug  2 21:18:00 2007
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Thu Aug  2 21:18:02 2007
Subject: [DRBD-cvs] svn commit by phil - r3010 - branches/drbd-8.0/user -
	Using the test isdigit(val1[0]) to find out if a string
Message-ID: <20070802191800.7B85D40095@garcon1.linbit.com>

Author: phil
Date: 2007-08-02 21:17:57 +0200 (Thu, 02 Aug 2007)
New Revision: 3010

Modified:
   branches/drbd-8.0/user/drbdadm_adjust.c
   branches/drbd-8.0/user/drbdtool_common.c
   branches/drbd-8.0/user/drbdtool_common.h
Log:
Using the test isdigit(val1[0]) to find out if a string
represents a number is of course right out stupid and wrong.

When you used a shared secret that started with a digit,
this broke the "drbdadm adjust" function.

Fixed now.


Modified: branches/drbd-8.0/user/drbdadm_adjust.c
===================================================================
--- branches/drbd-8.0/user/drbdadm_adjust.c	2007-08-02 14:17:20 UTC (rev 3009)
+++ branches/drbd-8.0/user/drbdadm_adjust.c	2007-08-02 19:17:57 UTC (rev 3010)
@@ -29,7 +29,6 @@
 #include <sys/wait.h>
 #include <unistd.h>
 
-#include <ctype.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
@@ -77,13 +76,9 @@
 	if(val1 == NULL && val2 == NULL) return 1;
 	if(val1 == NULL || val2 == NULL) return 0;
 
-	if(isdigit(val1[0])) {
-		v1 = m_strtoll(val1,0);
-		v2 = m_strtoll(val2,0);
+	if(new_strtoll(val1,0,&v1) == MSE_OK &&
+	   new_strtoll(val2,0,&v2) == MSE_OK) return v1 == v2;
 
-		return v1 == v2;
-	}
-
 	return !strcmp(val1,val2);
 }
 

Modified: branches/drbd-8.0/user/drbdtool_common.c
===================================================================
--- branches/drbd-8.0/user/drbdtool_common.c	2007-08-02 14:17:20 UTC (rev 3009)
+++ branches/drbd-8.0/user/drbdtool_common.c	2007-08-02 19:17:57 UTC (rev 3010)
@@ -53,88 +53,96 @@
   return buffer;
 }
 
-unsigned long long
-m_strtoll(const char *s, const char def_unit)
+int
+new_strtoll(const char *s, const char def_unit, unsigned long long *rv)
 {
-  unsigned long long r;
-  char unit = 0;
-  char dummy = 0;
-  int shift, c;
+	char unit = 0;
+	char dummy = 0;
+	int shift, c;
 
-  /*
-   * paranoia
-   */
-  switch (def_unit)
-    {
-    default:
-      fprintf(stderr, "%s:%d: unexpected default unit\n", __FILE__, __LINE__);
-      exit(100);
-    case 0:
-    case 1:
-    case '1':
-      shift = 0;
-      break;
+	switch (def_unit) {
+	default:
+		return MSE_DEFAULT_UNIT;
+	case 0:
+	case 1:
+	case '1':
+		shift = 0;
+		break;
+	case 'K':
+	case 'k':
+		shift = -10;
+		break;
+	case 's':
+		shift = -9;   // sectors
+		break;
+		/*
+		  case 'M':
+		  case 'm':
+		  case 'G':
+		  case 'g':
+		*/
+	}
+	
+	if (!s || !*s) return MSE_MISSING_NUMBER;
 
-    case 'K':
-    case 'k':
-      shift = -10;
-      break;
+	c = sscanf(s, "%llu%c%c", rv, &unit, &dummy);
 
-    case 's':
-      shift = -9;   // sectors
-      break;
+	if (c != 1 && c != 2) return MSE_INVALID_NUMBER;
 
-      /*
-         case 'M':
-         case 'm':
-         case 'G':
-         case 'g':
-       */
-    }
+	switch (unit) {
+	case 0:
+		return MSE_OK;
+	case 'K':
+	case 'k':
+		shift += 10;
+		break;
+	case 'M':
+	case 'm':
+		shift += 20;
+		break;
+	case 'G':
+	case 'g':
+		shift += 30;
+		break;
+	case 's':
+		shift += 9;
+		break;		
+	default:
+		return MSE_INVALID_UNIT;
+	}
+	if (*rv > (~0ULL >> shift)) return MSE_OUT_OF_RANGE;
 
-  if (!s || !*s)
-    {
-      fprintf(stderr, "missing number argument\n");
-      exit(100);
-    }
+	*rv = *rv << shift;
+	return MSE_OK;
+}
 
-  c = sscanf(s, "%llu%c%c", &r, &unit, &dummy);
+unsigned long long
+m_strtoll(const char *s, const char def_unit)
+{
+	unsigned long long r;
 
-  if (c != 1 && c != 2)
-    {
-      fprintf(stderr, "%s is not a valid number\n", s);
-      exit(20);
-    }
-
-  switch (unit)
-    {
-    case 0:
-      return r;
-    case 'K':
-    case 'k':
-      shift += 10;
-      break;
-    case 'M':
-    case 'm':
-      shift += 20;
-      break;
-    case 'G':
-    case 'g':
-      shift += 30;
-      break;
-    case 's':
-      shift += 9;
-      break;
-    default:
-      fprintf(stderr, "%s is not a valid number\n", s);
-      exit(20);
-    }
-  if (r > (~0ULL >> shift))
-    {
-      fprintf(stderr, "%s: out of range\n", s);
-      exit(20);
-    }
-  return r << shift;
+	switch(new_strtoll(s, def_unit, &r)) {
+	case MSE_OK:
+		return r;
+	case MSE_DEFAULT_UNIT:
+		fprintf(stderr, "unexpected default unit: %d\n",def_unit);
+		exit(100);
+	case MSE_MISSING_NUMBER:
+		fprintf(stderr, "missing number argument\n");
+		exit(100);
+	case MSE_INVALID_NUMBER:
+		fprintf(stderr, "%s is not a valid number\n", s);
+		exit(20);
+	case MSE_INVALID_UNIT:
+		fprintf(stderr, "%s is not a valid number\n", s);
+		exit(20);
+	case MSE_OUT_OF_RANGE:
+		fprintf(stderr, "%s: out of range\n", s);
+		exit(20);
+	default:
+		fprintf(stderr, "m_stroll() is confused\n");
+		exit(20);
+	}
 }
 
 void alarm_handler(int __attribute((unused)) signo)

Modified: branches/drbd-8.0/user/drbdtool_common.h
===================================================================
--- branches/drbd-8.0/user/drbdtool_common.h	2007-08-02 14:17:20 UTC (rev 3009)
+++ branches/drbd-8.0/user/drbdtool_common.h	2007-08-02 19:17:57 UTC (rev 3010)
@@ -23,12 +23,22 @@
 */
 #define PERROR(fmt, args...) fprintf(stderr, fmt ": %m\n" , ##args);
 
+enum new_strtoll_errs {
+	MSE_OK,
+	MSE_DEFAULT_UNIT,
+	MSE_MISSING_NUMBER,
+	MSE_INVALID_NUMBER,
+	MSE_INVALID_UNIT,
+	MSE_OUT_OF_RANGE,
+};
+
 struct option;
 
 extern int dt_lock_drbd(const char* device);
 extern void dt_unlock_drbd(int lock_fd);
 extern void dt_release_lockfile(int drbd_fd);
 extern int dt_minor_of_dev(const char *device);
+extern int new_strtoll(const char *s, const char def_unit, unsigned long long *rv);
 extern unsigned long long m_strtoll(const char* s,const char def_unit);
 extern const char* make_optstring(struct option *options, char startc);
 extern char* ppsize(char* buf, size_t size);

From drbd-cvs at lists.linbit.com  Fri Aug  3 09:37:45 2007
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Fri Aug  3 09:37:47 2007
Subject: [DRBD-cvs] svn commit by phil - r3011 - in branches/drbd-8.0: .
	debian - The release will happen today... 
Message-ID: <20070803073745.EDFE140095@garcon1.linbit.com>

Author: phil
Date: 2007-08-03 09:37:44 +0200 (Fri, 03 Aug 2007)
New Revision: 3011

Modified:
   branches/drbd-8.0/ChangeLog
   branches/drbd-8.0/debian/changelog
   branches/drbd-8.0/drbd.spec.in
Log:
The release will happen today...


Modified: branches/drbd-8.0/ChangeLog
===================================================================
--- branches/drbd-8.0/ChangeLog	2007-08-02 19:17:57 UTC (rev 3010)
+++ branches/drbd-8.0/ChangeLog	2007-08-03 07:37:44 UTC (rev 3011)
@@ -31,6 +31,8 @@
    'Negotiating' state. Fixed got fixed.
  * drbdmeta's parse/scan code for meta-data dumps got fixed for 
    huge devices, and an improved error reporting.
+ * drbdadm had difficulties with option values of type string that
+   start with an digit. Fixed.
  * Fixed a code path that should it make possible to unload the
    module even in case some of our receive buffers leaked.
  * The usermode helper program is now user definable. It is no

Modified: branches/drbd-8.0/debian/changelog
===================================================================
--- branches/drbd-8.0/debian/changelog	2007-08-02 19:17:57 UTC (rev 3010)
+++ branches/drbd-8.0/debian/changelog	2007-08-03 07:37:44 UTC (rev 3011)
@@ -2,7 +2,7 @@
 
   * New upstream release.
 
- -- Philipp Reisner <phil@linbit.com>  Thu,  2 Aug 2007 16:12:26 +0200
+ -- Philipp Reisner <phil@linbit.com>  Fri, 3 Aug 2007 09:34:49 +0200
 
 drbd8 (8.0.4-0) unstable; urgency=low
 

Modified: branches/drbd-8.0/drbd.spec.in
===================================================================
--- branches/drbd-8.0/drbd.spec.in	2007-08-02 19:17:57 UTC (rev 3010)
+++ branches/drbd-8.0/drbd.spec.in	2007-08-03 07:37:44 UTC (rev 3011)
@@ -191,7 +191,7 @@
 /sbin/depmod -a -F /boot/System.map-%{kernelversion} %{kernelversion} >/dev/null 2>&1 || true
 
 %changelog
-* Thu Aug  2 2007 16:12:26 +0200 Philipp Reisner <phil@linbit.com>
+* Fri Aug  3 2007 09:34:49 +0200 Philipp Reisner <phil@linbit.com>
 - drbd (8.0.5-1)
  * Changed the default behaviour of the init script. Now the init
    script terminates in case the devices refuse to because they 
@@ -218,6 +218,8 @@
    'Negotiating' state. Fixed got fixed.
  * drbdmeta's parse/scan code for meta-data dumps got fixed for 
    huge devices, and an improved error reporting.
+ * drbdadm had difficulties with option values of type string that
+   start with an digit. Fixed.
  * Fixed a code path that should it make possible to unload the
    module even in case some of our receive buffers leaked.
  * The usermode helper program is now user definable. It is no

From drbd-cvs at lists.linbit.com  Fri Aug  3 09:39:26 2007
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Fri Aug  3 09:39:28 2007
Subject: [DRBD-cvs] svn commit by phil - r3012 - tags - Tagging 8.0.5 
Message-ID: <20070803073926.857A740095@garcon1.linbit.com>

Author: phil
Date: 2007-08-03 09:39:25 +0200 (Fri, 03 Aug 2007)
New Revision: 3012

Added:
   tags/drbd-8.0.5/
Log:
Tagging 8.0.5 


Copied: tags/drbd-8.0.5 (from rev 3011, branches/drbd-8.0)

From drbd-cvs at lists.linbit.com  Mon Aug 13 15:10:08 2007
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Mon Aug 13 15:10:09 2007
Subject: [DRBD-cvs] svn commit by phil - r3018 - branches/drbd-8.0 -
	preparing merging of 8.0.5 fixes to 8.1 
Message-ID: <20070813131008.359714009A@garcon1.linbit.com>

Author: phil
Date: 2007-08-13 15:10:07 +0200 (Mon, 13 Aug 2007)
New Revision: 3018

Modified:
   branches/drbd-8.0/
Log:
preparing merging of 8.0.5 fixes to 8.1



Property changes on: branches/drbd-8.0
___________________________________________________________________
Name: propagate:to:2
   + /drbd/branches/drbd-8.1
Name: propagate:at:2
   + 2977

From drbd-cvs at lists.linbit.com  Mon Aug 13 15:14:45 2007
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Mon Aug 13 15:14:48 2007
Subject: [DRBD-cvs] svn commit by phil - r3019 - branches/drbd-8.0 - More
	preparation 
Message-ID: <20070813131445.04ABF4009A@garcon1.linbit.com>

Author: phil
Date: 2007-08-13 15:14:44 +0200 (Mon, 13 Aug 2007)
New Revision: 3019

Modified:
   branches/drbd-8.0/
Log:
More preparation



Property changes on: branches/drbd-8.0
___________________________________________________________________
Name: propagate:lo:2
   + ../drbd81

From drbd-cvs at lists.linbit.com  Mon Aug 13 15:20:18 2007
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Mon Aug 13 15:20:20 2007
Subject: [DRBD-cvs] svn commit by phil - r3020 - branches/drbd-8.1 -
	preparing... 
Message-ID: <20070813132018.AB00E4009A@garcon1.linbit.com>

Author: phil
Date: 2007-08-13 15:20:18 +0200 (Mon, 13 Aug 2007)
New Revision: 3020

Modified:
   branches/drbd-8.1/
Log:
preparing...



Property changes on: branches/drbd-8.1
___________________________________________________________________
Name: propagate:to
   - /drbd/plus-branches/08-10-csums
Name: propagate:at
   - 2291
Name: propagate:lo:1
   - ../drbd81
Name: propagate:lo
   - ../drbd08-p-10
Name: propagate:to:1
   - /drbd/trunk
Name: propagate:at:2
   + 2977

From drbd-cvs at lists.linbit.com  Mon Aug 13 15:50:05 2007
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Mon Aug 13 15:50:07 2007
Subject: [DRBD-cvs] svn commit by phil - r3021 - in branches/drbd-8.1: .
	debian documentation drbd scripts user - svnp run.
	Propagating the 8.0.5 fixes to the 8.1 branch
Message-ID: <20070813135005.51FCD4009A@garcon1.linbit.com>

Author: phil
Date: 2007-08-13 15:50:02 +0200 (Mon, 13 Aug 2007)
New Revision: 3021

Modified:
   branches/drbd-8.1/
   branches/drbd-8.1/ChangeLog
   branches/drbd-8.1/debian/changelog
   branches/drbd-8.1/documentation/drbd.conf.sgml
   branches/drbd-8.1/documentation/drbdsetup.sgml
   branches/drbd-8.1/drbd.spec.in
   branches/drbd-8.1/drbd/drbd_main.c
   branches/drbd-8.1/drbd/drbd_worker.c
   branches/drbd-8.1/scripts/drbd.conf
   branches/drbd-8.1/user/drbdadm_adjust.c
   branches/drbd-8.1/user/drbdadm_scanner.fl
   branches/drbd-8.1/user/drbdsetup.c
   branches/drbd-8.1/user/drbdtool_common.c
   branches/drbd-8.1/user/drbdtool_common.h
Log:
svnp run. Propagating the 8.0.5 fixes to the 8.1 branch.

Fixed a bug that was introduced with 8.0.1 (r2737). In case you slowed
down the resync speed during a running resync process considerabely, you
could trigger a bug in w_make_resync_request(), that causes the
local_cnt
to go below zero.

When the number of requests that should be on the fly for the new
(lower) resync speed is higher than the number of requests that are
currently on the fly, we had that "goto requeue:". In the exit path of
the function we decreased the local_cnt by one...
--
Ernest pointed out that we erroneously created a new current_id
each time a diskless peer become secondary. We should do that
only the first time...

By the way, I enlosed this in a inc_local() - dec_local() pair,
since mdev->bc gets dereferenced in this code block.
--
When we attach a disk to a connected device pair, we are in
disk state Nogotiating on the node that gets the disk attache

When in the mean time some event on the peer node triggers
the transmittion of a state packet, we might end up using an
old p_uuid set and find a wrong resync decission.

Fixed that.
--
Implemented the wait-after-sb option for the startup section.
AND CHANGED THE DEFAULT BEHAVIOUR OF THE INIT SCRIPT.
--
Preparing the 8.0.5 release.
--
Using the test isdigit(val1[0]) to find out if a string
represents a number is of course right out stupid and wrong.

When you used a shared secret that started with a digit,
this broke the "drbdadm adjust" function.

Fixed now.
--




Property changes on: branches/drbd-8.1
___________________________________________________________________
Name: propagate:at:2
   - 2977
   + 3019

Modified: branches/drbd-8.1/ChangeLog
===================================================================
--- branches/drbd-8.1/ChangeLog	2007-08-13 13:20:18 UTC (rev 3020)
+++ branches/drbd-8.1/ChangeLog	2007-08-13 13:50:02 UTC (rev 3021)
@@ -4,6 +4,40 @@
  Cumulative changes since last tarball.
  For even more detail, use "svn log" and "svn diff".
 
+8.0.5 (api:86/proto:86)
+--------
+ * Changed the default behaviour of the init script. Now the init
+   script terminates in case the devices refuse to because they 
+   had a split brain. Introduced an option to preserve the old
+   behaviour.
+ * Fixed a bug where the local_cnt could get imbalanced upon a 
+   state change.
+ * Fixed an bug in the UUID algorithm, that could lead to both
+   sides in cs:WFBitMapT state. It was triggered when the disk
+   on the SyncTarget gets detached and attached.
+ * Implemented proper size checking on strings that get communicated
+   with DRBD's netlink protocol.
+ * Changed the maximal length of device names from 32 characters to
+   128 characters. (udev based disk names might be very long nowadays)
+ * Fixed the after-sb-0pri policies discard-younger/discard-older
+ * When the resync speed was changed to a considerably lower 
+   value while resync was running, it could happen that we erronously
+   decremented the local_cnt too often.
+ * Fixed a bug in the UUID code, that caused drbd to erronously report 
+   a split brain after changing the role of a diskless node multiple 
+   times.
+ * Both nodes ended up in SyncSource when a state change occured on 
+   one node while the disk state on the other node is in the temporal 
+   'Negotiating' state. Fixed got fixed.
+ * drbdmeta's parse/scan code for meta-data dumps got fixed for 
+   huge devices, and an improved error reporting.
+ * drbdadm had difficulties with option values of type string that
+   start with an digit. Fixed.
+ * Fixed a code path that should it make possible to unload the
+   module even in case some of our receive buffers leaked.
+ * The usermode helper program is now user definable. It is no
+   longer hardcoded set to 'drbdadm'.
+
 8.0.4 (api:86/proto:86)
 --------
  * Fixed an OOPS in case you do an invalidate on an diskless device. And

Modified: branches/drbd-8.1/debian/changelog
===================================================================
--- branches/drbd-8.1/debian/changelog	2007-08-13 13:20:18 UTC (rev 3020)
+++ branches/drbd-8.1/debian/changelog	2007-08-13 13:50:02 UTC (rev 3021)
@@ -1,3 +1,9 @@
+drbd8 (8.0.5-0) unstable; urgency=low
+
+  * New upstream release.
+
+ -- Philipp Reisner <phil@linbit.com>  Fri, 3 Aug 2007 09:34:49 +0200
+
 drbd8 (8.0.4-0) unstable; urgency=low
 
   * New upstream release.
@@ -2,3 +8,3 @@
 
- -- Philipp Reisner <phil@linbit.com>  Wed, 27 Jun 2007 10:0:00 +0200
+ -- Philipp Reisner <phil@linbit.com>  Wed, 27 Jun 2007 10:00:00 +0200
 

Modified: branches/drbd-8.1/documentation/drbd.conf.sgml
===================================================================
--- branches/drbd-8.1/documentation/drbd.conf.sgml	2007-08-13 13:20:18 UTC (rev 3020)
+++ branches/drbd-8.1/documentation/drbd.conf.sgml	2007-08-13 13:50:02 UTC (rev 3021)
@@ -217,7 +217,8 @@
     <manvolnum>8</manvolnum></citerefentry> for a detailed description
     of this section's parameters.
     Optional parameters:
-    <option>wfc-timeout</option>, <option>degr-wfc-timeout</option>.
+    <option>wfc-timeout</option>, <option>degr-wfc-timeout</option> and
+    <option>wait-after-sb</option>.
   </para>
   </listitem>
 </varlistentry>
@@ -835,6 +836,16 @@
 </varlistentry>
 
 <varlistentry>
+  <term><option>wait-after-sb</option></term>
+  <listitem><para>
+  By setting this option you can make the init script to continue 
+  to wait even if the device pair had a split brain situation
+  and therefore refuses to connect.
+  </para>
+  </listitem>
+</varlistentry>
+
+<varlistentry>
   <term><option>rate <replaceable>rate</replaceable></option></term>
   <listitem><para>
   <indexterm><primary>drbd.conf</primary><secondary>rate </secondary></indexterm>

Modified: branches/drbd-8.1/documentation/drbdsetup.sgml
===================================================================
--- branches/drbd-8.1/documentation/drbdsetup.sgml	2007-08-13 13:20:18 UTC (rev 3020)
+++ branches/drbd-8.1/documentation/drbdsetup.sgml	2007-08-13 13:50:02 UTC (rev 3021)
@@ -103,16 +103,18 @@
     <cmdsynopsis>
       <command>drbdsetup</command>
       <arg choice="req"><replaceable>device</replaceable></arg>
-      <arg choice="req">wait_connect</arg>
+      <arg choice="req">wait-connect</arg>
       <arg>-t<arg choice="req"><replaceable>wfc_timeout</replaceable></arg></arg>
       <arg>-d<arg choice="req"><replaceable>degr_wfc_timeout</replaceable></arg></arg>
+      <arg>-w</arg>
     </cmdsynopsis>
     <cmdsynopsis>
       <command>drbdsetup</command>
       <arg choice="req"><replaceable>device</replaceable></arg>
-      <arg choice="req">wait_sync</arg>
+      <arg choice="req">wait-sync</arg>
       <arg>-t<arg choice="req"><replaceable>wfc_timeout</replaceable></arg></arg>
       <arg>-d<arg choice="req"><replaceable>degr_wfc_timeout</replaceable></arg></arg>
+      <arg>-w</arg>
     </cmdsynopsis>
     <cmdsynopsis>
       <command>drbdsetup</command>
@@ -817,8 +819,8 @@
       </para>
     </refsect2>
     <refsect2>
-      <title>wait_connect</title>
-      <indexterm><primary>drbdsetup</primary><secondary>wait_connect</secondary></indexterm>
+      <title>wait-connect</title>
+      <indexterm><primary>drbdsetup</primary><secondary>wait-connect</secondary></indexterm>
       <para>
 	Returns as soon as the <replaceable>device</replaceable> can
 	communicate with its partner device.
@@ -829,6 +831,7 @@
 	  <option>--wfc-timeout <replaceable>wfc_timeout</replaceable></option></term>
 	  <term><option>-d</option>,
 	  <option>--degr-wfc-timeout <replaceable>degr_wfc_timeout</replaceable></option></term>
+	  <term><option>-w</option>, <option>--wait-after-sb</option></term>
 	  <listitem>
 	    <para>
 	      This command will fail if the
@@ -841,18 +844,22 @@
 	      The default value for <replaceable>wfc_timeout</replaceable>
 	      is 0 which means to wait forever. The default for
 	      <replaceable>degr_wfc_timeout</replaceable> is 120 seconds.
+	      In case the connection status goes down to StandAlone because
+              the peer appeared but the devices had a split brain situation,
+              the default for the command is to terminate. You can change this
+              behaviour with the <option>--wait-after-sb</option> option.
 	    </para>
 	  </listitem>
 	</varlistentry>
       </variablelist>
     </refsect2>
     <refsect2>
-      <title>wait_sync</title>
-      <indexterm><primary>drbdsetup</primary><secondary>wait_sync</secondary></indexterm>
+      <title>wait-sync</title>
+      <indexterm><primary>drbdsetup</primary><secondary>wait-sync</secondary></indexterm>
       <para>
 	Returns as soon as the <replaceable>device</replaceable> leaves any
 	synchronisation into connected state. The options
-	are the same as with the <replaceable>wait_connect</replaceable>
+	are the same as with the <replaceable>wait-connect</replaceable>
 	command.
       </para>
     </refsect2>

Modified: branches/drbd-8.1/drbd/drbd_main.c
===================================================================
--- branches/drbd-8.1/drbd/drbd_main.c	2007-08-13 13:20:18 UTC (rev 3020)
+++ branches/drbd-8.1/drbd/drbd_main.c	2007-08-13 13:50:02 UTC (rev 3021)
@@ -954,18 +954,21 @@
 		}
 	}
 
-	if (ns.pdsk < Inconsistent) {
+	if (ns.pdsk < Inconsistent && inc_local(mdev)) {
 		/* Diskless Peer becomes primary */
-		if (os.peer == Secondary && ns.peer == Primary)
+		if (os.peer == Secondary && ns.peer == Primary && mdev->bc->md.uuid[Bitmap] == 0)
 			drbd_uuid_new_current(mdev);
 		/* Diskless Peer becomes secondary */
 		if (os.peer == Primary && ns.peer == Secondary)
 			drbd_al_to_on_disk_bm(mdev);
+		dec_local(mdev);
 	}
 
 	/* Last part of the attaching process ... */
 	if ( ns.conn >= Connected &&
 	     os.disk == Attaching && ns.disk == Negotiating ) {
+		kfree(mdev->p_uuid); /* We expect to receive up-to-date UUIDs soon. */
+		mdev->p_uuid = NULL; /* ...to not use the old ones in the mean time */
 		drbd_send_sizes(mdev);  /* to start sync... */
 		drbd_send_uuids(mdev);
 		drbd_send_state(mdev);

Modified: branches/drbd-8.1/drbd/drbd_worker.c
===================================================================
--- branches/drbd-8.1/drbd/drbd_worker.c	2007-08-13 13:20:18 UTC (rev 3020)
+++ branches/drbd-8.1/drbd/drbd_worker.c	2007-08-13 13:50:02 UTC (rev 3021)
@@ -335,12 +335,6 @@
 		ERR("%s in w_make_resync_request\n",
 			conns_to_name(mdev->state.conn));
 
-	number = SLEEP_TIME*mdev->sync_conf.rate / ((BM_BLOCK_SIZE/1024)*HZ);
-
-	if (atomic_read(&mdev->rs_pending_cnt) > number)
-		goto requeue;
-	number -= atomic_read(&mdev->rs_pending_cnt);
-
 	if (!inc_local(mdev)) {
 		/* Since we only need to access mdev->rsync a
 		   inc_local_if_state(mdev,Failed) would be sufficient, but
@@ -350,7 +344,14 @@
 		mdev->resync_work.cb = w_resync_inactive;
 		return 1;
 	}
+	/* All goto requeses have to happend after this block: inc_local() */
 
+	number = SLEEP_TIME*mdev->sync_conf.rate / ((BM_BLOCK_SIZE/1024)*HZ);
+
+	if (atomic_read(&mdev->rs_pending_cnt) > number)
+		goto requeue;
+	number -= atomic_read(&mdev->rs_pending_cnt);
+
 	for (i = 0; i < number; i++) {
 next_sector:
 		size = BM_BLOCK_SIZE;

Modified: branches/drbd-8.1/drbd.spec.in
===================================================================
--- branches/drbd-8.1/drbd.spec.in	2007-08-13 13:20:18 UTC (rev 3020)
+++ branches/drbd-8.1/drbd.spec.in	2007-08-13 13:50:02 UTC (rev 3021)
@@ -191,6 +191,40 @@
 /sbin/depmod -a -F /boot/System.map-%{kernelversion} %{kernelversion} >/dev/null 2>&1 || true
 
 %changelog
+* Fri Aug  3 2007 09:34:49 +0200 Philipp Reisner <phil@linbit.com>
+- drbd (8.0.5-1)
+ * Changed the default behaviour of the init script. Now the init
+   script terminates in case the devices refuse to because they 
+   had a split brain. Introduced an option to preserve the old
+   behaviour.
+ * Fixed a bug where the local_cnt could get imbalanced upon a 
+   state change.
+ * Fixed an bug in the UUID algorithm, that could lead to both
+   sides in cs:WFBitMapT state. It was triggered when the disk
+   on the SyncTarget gets detached and attached.
+ * Implemented proper size checking on strings that get communicated
+   with DRBD's netlink protocol.
+ * Changed the maximal length of device names from 32 characters to
+   128 characters. (udev based disk names might be very long nowadays)
+ * Fixed the after-sb-0pri policies discard-younger/discard-older
+ * When the resync speed was changed to a considerably lower 
+   value while resync was running, it could happen that we erronously
+   decremented the local_cnt too often.
+ * Fixed a bug in the UUID code, that caused drbd to erronously report 
+   a split brain after changing the role of a diskless node multiple 
+   times.
+ * Both nodes ended up in SyncSource when a state change occured on 
+   one node while the disk state on the other node is in the temporal 
+   'Negotiating' state. Fixed got fixed.
+ * drbdmeta's parse/scan code for meta-data dumps got fixed for 
+   huge devices, and an improved error reporting.
+ * drbdadm had difficulties with option values of type string that
+   start with an digit. Fixed.
+ * Fixed a code path that should it make possible to unload the
+   module even in case some of our receive buffers leaked.
+ * The usermode helper program is now user definable. It is no
+   longer hardcoded set to 'drbdadm'.
+
 * Wed Jun 27 2007 10:00:00 +0200 Philipp Reisner <phil@linbit.com>
 - drbd (8.0.4-1)
  * Fixed an OOPS in case you do an invalidate on an diskless device. And

Modified: branches/drbd-8.1/scripts/drbd.conf
===================================================================
--- branches/drbd-8.1/scripts/drbd.conf	2007-08-13 13:20:18 UTC (rev 3020)
+++ branches/drbd-8.1/scripts/drbd.conf	2007-08-13 13:50:02 UTC (rev 3021)
@@ -161,6 +161,15 @@
     # is rebooted, this timeout value is used.
     #
     degr-wfc-timeout 120;    # 2 minutes.
+
+    # In case there was a split brain situation the devices will
+    # drop their network configuration instead of connecting. Since
+    # this means that the network is working, the cluster manager
+    # should be able to communicate as well. Therefore the default
+    # of DRBD's init script is to terminate in this case. To make
+    # it to continue waiting in this case set this option.
+    # 
+    # wait-after-sb;
   }
 
   disk {

Modified: branches/drbd-8.1/user/drbdadm_adjust.c
===================================================================
--- branches/drbd-8.1/user/drbdadm_adjust.c	2007-08-13 13:20:18 UTC (rev 3020)
+++ branches/drbd-8.1/user/drbdadm_adjust.c	2007-08-13 13:50:02 UTC (rev 3021)
@@ -29,7 +29,6 @@
 #include <sys/wait.h>
 #include <unistd.h>
 
-#include <ctype.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
@@ -77,13 +76,9 @@
 	if(val1 == NULL && val2 == NULL) return 1;
 	if(val1 == NULL || val2 == NULL) return 0;
 
-	if(isdigit(val1[0])) {
-		v1 = m_strtoll(val1,0);
-		v2 = m_strtoll(val2,0);
+	if(new_strtoll(val1,0,&v1) == MSE_OK &&
+	   new_strtoll(val2,0,&v2) == MSE_OK) return v1 == v2;
 
-		return v1 == v2;
-	}
-
 	return !strcmp(val1,val2);
 }
 

Modified: branches/drbd-8.1/user/drbdadm_scanner.fl
===================================================================
--- branches/drbd-8.1/user/drbdadm_scanner.fl	2007-08-13 13:20:18 UTC (rev 3020)
+++ branches/drbd-8.1/user/drbdadm_scanner.fl	2007-08-13 13:50:02 UTC (rev 3021)
@@ -88,6 +88,7 @@
 al-extents		{ DP; CP; RC(AL_EXTENTS); return TK_SYNCER_OPTION;}
 wfc-timeout		{ DP; CP; RC(WFC_TIMEOUT); return TK_STARTUP_OPTION;}
 degr-wfc-timeout	{ DP; CP; RC(DEGR_WFC_TIMEOUT); return TK_STARTUP_OPTION;}
+wait-after-sb		{ DP; CP; return TK_STARTUP_SWITCH;     }
 pri-on-incon-degr	{ DP; CP; return TK_HANDLER_OPTION;	}
 pri-lost-after-sb	{ DP; CP; return TK_HANDLER_OPTION;	}
 pri-lost	        { DP; CP; return TK_HANDLER_OPTION;     }

Modified: branches/drbd-8.1/user/drbdsetup.c
===================================================================
--- branches/drbd-8.1/user/drbdsetup.c	2007-08-13 13:20:18 UTC (rev 3020)
+++ branches/drbd-8.1/user/drbdsetup.c	2007-08-13 13:50:02 UTC (rev 3021)
@@ -124,7 +124,8 @@
 		} gp; // for generic_get_cmd, get_usage
 		struct {
 			struct option *options;
-			int (*proc_event)();
+			int (*proc_event)(unsigned int, int, 
+					  struct drbd_nl_cfg_reply *);
 		} ep; // for events_cmd, events_usage
 	};
 };
@@ -191,9 +192,9 @@
 void show_string(struct drbd_option *od, unsigned short* tp);
 
 // sub functions for events_cmd
-int print_state(unsigned int seq, struct drbd_nl_cfg_reply *reply);
-int w_connected_state(unsigned int seq, struct drbd_nl_cfg_reply *reply);
-int w_synced_state(unsigned int seq, struct drbd_nl_cfg_reply *reply);
+int print_state(unsigned int seq, int, struct drbd_nl_cfg_reply *reply);
+int w_connected_state(unsigned int seq, int, struct drbd_nl_cfg_reply *reply);
+int w_synced_state(unsigned int seq, int, struct drbd_nl_cfg_reply *reply);
 
 const char *on_error[] = {
 	[PassOn]         = "pass_on",
@@ -240,6 +241,7 @@
 struct option wait_cmds_options[] = {
 	{ "wfc-timeout",required_argument, 0, 't' },
 	{ "degr-wfc-timeout",required_argument,0,'d'},
+	{ "wait-after-sb",no_argument,0,'w'},
 	{ 0,            0,           0,  0  }
 };
 
@@ -1187,7 +1189,8 @@
 	return rv;
 }
 
-int print_state(unsigned int seq, struct drbd_nl_cfg_reply *reply)
+int print_state(unsigned int seq, int u __attribute((unused)),
+		struct drbd_nl_cfg_reply *reply)
 {
 	drbd_state_t state;
 	char* str;
@@ -1239,6 +1242,7 @@
 }
 
 int w_connected_state(unsigned int seq __attribute((unused)),
+		      int wait_after_sb,
 		      struct drbd_nl_cfg_reply *reply)
 {
 	drbd_state_t state;
@@ -1246,6 +1250,7 @@
 	if(reply->packet_type == P_get_state) {
 		if(consume_tag_int(T_state_i,reply->tag_list,(int*)&state.i)) {
 			if(state.conn >= Connected) return 0;
+			if(!wait_after_sb && state.conn < Unconnected) return 0;
 		} else fprintf(stderr,"Missing tag !?\n");
 	}
 
@@ -1253,14 +1258,15 @@
 }
 
 int w_synced_state(unsigned int seq __attribute((unused)),
+		   int wait_after_sb,
 		   struct drbd_nl_cfg_reply *reply)
 {
 	drbd_state_t state;
 
 	if(reply->packet_type == P_get_state) {
 		if(consume_tag_int(T_state_i,reply->tag_list,(int*)&state.i)) {
-			if(state.conn == Connected || state.conn < Unconnected )
-				return 0;
+			if(state.conn == Connected) return 0;
+			if(!wait_after_sb && state.conn < Unconnected) return 0;
 		} else fprintf(stderr,"Missing tag !?\n");
 	}
 	return 1;
@@ -1278,6 +1284,7 @@
 	int unfiltered=0, all_devices=0;
 	int wfc_timeout=0, degr_wfc_timeout=0,timeout_ms;
 	struct timeval before,after;
+	int wasb=0;
 
 	lo = cm->ep.options;
 
@@ -1307,6 +1314,9 @@
 				return 20;
 			}
 			break;
+		case 'w':
+			wasb=1;
+			break;
 		}
 	}
 
@@ -1372,7 +1382,7 @@
 		seq = cn_reply->seq;
 
 		if( all_devices || minor == reply->minor ) {
-			cont=cm->ep.proc_event(cn_reply->seq, reply);
+			cont=cm->ep.proc_event(cn_reply->seq, wasb, reply);
 		}
 	} while(cont);
 

Modified: branches/drbd-8.1/user/drbdtool_common.c
===================================================================
--- branches/drbd-8.1/user/drbdtool_common.c	2007-08-13 13:20:18 UTC (rev 3020)
+++ branches/drbd-8.1/user/drbdtool_common.c	2007-08-13 13:50:02 UTC (rev 3021)
@@ -53,88 +53,96 @@
   return buffer;
 }
 
-unsigned long long
-m_strtoll(const char *s, const char def_unit)
+int
+new_strtoll(const char *s, const char def_unit, unsigned long long *rv)
 {
-  unsigned long long r;
-  char unit = 0;
-  char dummy = 0;
-  int shift, c;
+	char unit = 0;
+	char dummy = 0;
+	int shift, c;
 
-  /*
-   * paranoia
-   */
-  switch (def_unit)
-    {
-    default:
-      fprintf(stderr, "%s:%d: unexpected default unit\n", __FILE__, __LINE__);
-      exit(100);
-    case 0:
-    case 1:
-    case '1':
-      shift = 0;
-      break;
+	switch (def_unit) {
+	default:
+		return MSE_DEFAULT_UNIT;
+	case 0:
+	case 1:
+	case '1':
+		shift = 0;
+		break;
+	case 'K':
+	case 'k':
+		shift = -10;
+		break;
+	case 's':
+		shift = -9;   // sectors
+		break;
+		/*
+		  case 'M':
+		  case 'm':
+		  case 'G':
+		  case 'g':
+		*/
+	}
+	
+	if (!s || !*s) return MSE_MISSING_NUMBER;
 
-    case 'K':
-    case 'k':
-      shift = -10;
-      break;
+	c = sscanf(s, "%llu%c%c", rv, &unit, &dummy);
 
-    case 's':
-      shift = -9;   // sectors
-      break;
+	if (c != 1 && c != 2) return MSE_INVALID_NUMBER;
 
-      /*
-         case 'M':
-         case 'm':
-         case 'G':
-         case 'g':
-       */
-    }
+	switch (unit) {
+	case 0:
+		return MSE_OK;
+	case 'K':
+	case 'k':
+		shift += 10;
+		break;
+	case 'M':
+	case 'm':
+		shift += 20;
+		break;
+	case 'G':
+	case 'g':
+		shift += 30;
+		break;
+	case 's':
+		shift += 9;
+		break;		
+	default:
+		return MSE_INVALID_UNIT;
+	}
+	if (*rv > (~0ULL >> shift)) return MSE_OUT_OF_RANGE;
 
-  if (!s || !*s)
-    {
-      fprintf(stderr, "missing number argument\n");
-      exit(100);
-    }
+	*rv = *rv << shift;
+	return MSE_OK;
+}
 
-  c = sscanf(s, "%llu%c%c", &r, &unit, &dummy);
+unsigned long long
+m_strtoll(const char *s, const char def_unit)
+{
+	unsigned long long r;
 
-  if (c != 1 && c != 2)
-    {
-      fprintf(stderr, "%s is not a valid number\n", s);
-      exit(20);
-    }
-
-  switch (unit)
-    {
-    case 0:
-      return r;
-    case 'K':
-    case 'k':
-      shift += 10;
-      break;
-    case 'M':
-    case 'm':
-      shift += 20;
-      break;
-    case 'G':
-    case 'g':
-      shift += 30;
-      break;
-    case 's':
-      shift += 9;
-      break;
-    default:
-      fprintf(stderr, "%s is not a valid number\n", s);
-      exit(20);
-    }
-  if (r > (~0ULL >> shift))
-    {
-      fprintf(stderr, "%s: out of range\n", s);
-      exit(20);
-    }
-  return r << shift;
+	switch(new_strtoll(s, def_unit, &r)) {
+	case MSE_OK:
+		return r;
+	case MSE_DEFAULT_UNIT:
+		fprintf(stderr, "unexpected default unit: %d\n",def_unit);
+		exit(100);
+	case MSE_MISSING_NUMBER:
+		fprintf(stderr, "missing number argument\n");
+		exit(100);
+	case MSE_INVALID_NUMBER:
+		fprintf(stderr, "%s is not a valid number\n", s);
+		exit(20);
+	case MSE_INVALID_UNIT:
+		fprintf(stderr, "%s is not a valid number\n", s);
+		exit(20);
+	case MSE_OUT_OF_RANGE:
+		fprintf(stderr, "%s: out of range\n", s);
+		exit(20);
+	default:
+		fprintf(stderr, "m_stroll() is confused\n");
+		exit(20);
+	}
 }
 
 void alarm_handler(int __attribute((unused)) signo)

Modified: branches/drbd-8.1/user/drbdtool_common.h
===================================================================
--- branches/drbd-8.1/user/drbdtool_common.h	2007-08-13 13:20:18 UTC (rev 3020)
+++ branches/drbd-8.1/user/drbdtool_common.h	2007-08-13 13:50:02 UTC (rev 3021)
@@ -23,12 +23,22 @@
 */
 #define PERROR(fmt, args...) fprintf(stderr, fmt ": %m\n" , ##args);
 
+enum new_strtoll_errs {
+	MSE_OK,
+	MSE_DEFAULT_UNIT,
+	MSE_MISSING_NUMBER,
+	MSE_INVALID_NUMBER,
+	MSE_INVALID_UNIT,
+	MSE_OUT_OF_RANGE,
+};
+
 struct option;
 
 extern int dt_lock_drbd(const char* device);
 extern void dt_unlock_drbd(int lock_fd);
 extern void dt_release_lockfile(int drbd_fd);
 extern int dt_minor_of_dev(const char *device);
+extern int new_strtoll(const char *s, const char def_unit, unsigned long long *rv);
 extern unsigned long long m_strtoll(const char* s,const char def_unit);
 extern const char* make_optstring(struct option *options, char startc);
 extern char* ppsize(char* buf, size_t size);

From drbd-cvs at lists.linbit.com  Sat Aug 25 10:56:58 2007
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Sat Aug 25 10:57:00 2007
Subject: [DRBD-cvs] svn commit by lars - r3022 - branches/drbd-8.1/drbd -
	get on-disk bitmap update out of the generic_make_reque
Message-ID: <20070825085658.1FB4D4009A@garcon1.linbit.com>

Author: lars
Date: 2007-08-25 10:56:57 +0200 (Sat, 25 Aug 2007)
New Revision: 3022

Modified:
   branches/drbd-8.1/drbd/drbd_actlog.c
Log:
get on-disk bitmap update out of the generic_make_request path
would deadlock due to recursion prevention patch in kernel now

Modified: branches/drbd-8.1/drbd/drbd_actlog.c
===================================================================
--- branches/drbd-8.1/drbd/drbd_actlog.c	2007-08-13 13:50:02 UTC (rev 3021)
+++ branches/drbd-8.1/drbd/drbd_actlog.c	2007-08-25 08:56:57 UTC (rev 3022)
@@ -185,6 +185,8 @@
 	struct lc_element *al_ext;
 	struct completion event;
 	unsigned int enr;
+	/* if old_enr != LC_FREE, write corresponding bitmap sector, too */
+	unsigned int old_enr;
 };
 
 int w_al_write_transaction(struct drbd_conf *, struct drbd_work *, int);
@@ -241,14 +243,6 @@
 	wait_event(mdev->al_wait, (al_ext = _al_get(mdev, enr)) );
 
 	if (al_ext->lc_number != enr) {
-		/* We have to do write an transaction to AL. */
-		unsigned int evicted;
-
-		evicted = al_ext->lc_number;
-
-		if (mdev->state.conn < Connected && evicted != LC_FREE)
-			drbd_bm_write_sect(mdev, evicted/AL_EXT_PER_BM_SECT);
-
 		/* drbd_al_write_transaction(mdev,al_ext,enr);
 		   generic_make_request() are serialized on the
 		   current->bio_tail list now. Therefore we have
@@ -257,6 +251,7 @@
 		init_completion(&al_work.event);
 		al_work.al_ext = al_ext;
 		al_work.enr = enr;
+		al_work.old_enr = al_ext->lc_number;
 		al_work.w.cb = w_al_write_transaction;
 		drbd_queue_work_front(&mdev->data.work, &al_work.w);
 		wait_for_completion(&al_work.event);
@@ -305,14 +300,23 @@
 int
 w_al_write_transaction(struct drbd_conf *mdev, struct drbd_work *w, int unused)
 {
-	int i, n, mx;
-	unsigned int extent_nr;
-	struct al_transaction *buffer;
+	struct update_al_work *aw = (struct update_al_work*)w;
+	struct lc_element *updated = aw->al_ext;
+	const unsigned int new_enr = aw->enr;
+	const unsigned int evicted = aw->old_enr;
+
+	struct al_transaction* buffer;
 	sector_t sector;
-	u32 xor_sum = 0;
+ 	int i,n,mx;
+ 	unsigned int extent_nr;
+ 	u32 xor_sum=0;
 
-	struct lc_element *updated = ((struct update_al_work *)w)->al_ext;
-	unsigned int new_enr = ((struct update_al_work *)w)->enr;
+	/* do we have to do a bitmap write, first?
+	 * TODO reduce maximum latency:
+	 * submit both bios, then wait for both,
+	 * instead of doing two synchronous sector writes. */
+	if (mdev->state.conn < Connected && evicted != LC_FREE)
+		drbd_bm_write_sect(mdev, evicted/AL_EXT_PER_BM_SECT);
 
 	down(&mdev->md_io_mutex); /* protects md_io_buffer, al_tr_cycle, ... */
 	buffer = (struct al_transaction *)page_address(mdev->md_io_page);

From drbd-cvs at lists.linbit.com  Sat Aug 25 11:02:22 2007
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Sat Aug 25 11:02:25 2007
Subject: [DRBD-cvs] svn commit by lars - r3023 - branches/drbd-8.1/user -
	make it compile (no more typedefs) 
Message-ID: <20070825090222.E30084009A@garcon1.linbit.com>

Author: lars
Date: 2007-08-25 11:01:32 +0200 (Sat, 25 Aug 2007)
New Revision: 3023

Modified:
   branches/drbd-8.1/user/drbdsetup.c
Log:
make it compile (no more typedefs)

Modified: branches/drbd-8.1/user/drbdsetup.c
===================================================================
--- branches/drbd-8.1/user/drbdsetup.c	2007-08-25 08:56:57 UTC (rev 3022)
+++ branches/drbd-8.1/user/drbdsetup.c	2007-08-25 09:01:32 UTC (rev 3023)
@@ -1088,7 +1088,7 @@
 	       int minor __attribute((unused)),
 	       unsigned short *rtl)
 {
-	drbd_state_t state;
+	union drbd_state_t state;
 	consume_tag_int(T_state_i,rtl,(int*)&state.i);
 	if ( state.conn == StandAlone &&
 	     state.disk == Diskless) {
@@ -1103,7 +1103,7 @@
 		int minor __attribute((unused)),
 		unsigned short *rtl)
 {
-	drbd_state_t state;
+	union drbd_state_t state;
 	consume_tag_int(T_state_i,rtl,(int*)&state.i);
 	if ( state.conn == StandAlone &&
 	     state.disk == Diskless) {
@@ -1118,7 +1118,7 @@
 		int minor __attribute((unused)),
 		unsigned short *rtl)
 {
-	drbd_state_t state;
+	union drbd_state_t state;
 	consume_tag_int(T_state_i,rtl,(int*)&state.i);
 	if ( state.conn == StandAlone &&
 	     state.disk == Diskless) {
@@ -1192,7 +1192,7 @@
 int print_state(unsigned int seq, int u __attribute((unused)),
 		struct drbd_nl_cfg_reply *reply)
 {
-	drbd_state_t state;
+	union drbd_state_t state;
 	char* str;
 	int synced = 0;
 
@@ -1245,7 +1245,7 @@
 		      int wait_after_sb,
 		      struct drbd_nl_cfg_reply *reply)
 {
-	drbd_state_t state;
+	union drbd_state_t state;
 
 	if(reply->packet_type == P_get_state) {
 		if(consume_tag_int(T_state_i,reply->tag_list,(int*)&state.i)) {
@@ -1261,7 +1261,7 @@
 		   int wait_after_sb,
 		   struct drbd_nl_cfg_reply *reply)
 {
-	drbd_state_t state;
+	union drbd_state_t state;
 
 	if(reply->packet_type == P_get_state) {
 		if(consume_tag_int(T_state_i,reply->tag_list,(int*)&state.i)) {

From drbd-cvs at lists.linbit.com  Mon Aug 27 11:02:18 2007
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Mon Aug 27 11:02:21 2007
Subject: [DRBD-cvs] svn commit by lars - r3024 - branches/drbd-8.0/drbd -
	get on-disk bitmap update out of the generic_make_reque
Message-ID: <20070827090218.B929B4009A@garcon1.linbit.com>

Author: lars
Date: 2007-08-27 11:01:12 +0200 (Mon, 27 Aug 2007)
New Revision: 3024

Modified:
   branches/drbd-8.0/drbd/drbd_actlog.c
Log:
get on-disk bitmap update out of the generic_make_request path
would deadlock due to recursion prevention patch in kernel now


Modified: branches/drbd-8.0/drbd/drbd_actlog.c
===================================================================
--- branches/drbd-8.0/drbd/drbd_actlog.c	2007-08-25 09:01:32 UTC (rev 3023)
+++ branches/drbd-8.0/drbd/drbd_actlog.c	2007-08-27 09:01:12 UTC (rev 3024)
@@ -180,6 +180,8 @@
 	struct lc_element * al_ext;
 	struct completion event;
 	unsigned int enr;
+	/* if old_enr != LC_FREE, write corresponding bitmap sector, too */
+	unsigned int old_enr;
 };
 
 STATIC int w_al_write_transaction(struct Drbd_Conf *, struct drbd_work *, int);
@@ -236,15 +238,6 @@
 	wait_event(mdev->al_wait, (al_ext = _al_get(mdev,enr)) );
 
 	if (al_ext->lc_number != enr) {
-		// We have to do write an transaction to AL.
-		unsigned int evicted;
-
-		evicted = al_ext->lc_number;
-
-		if(mdev->state.conn < Connected && evicted != LC_FREE ) {
-			drbd_bm_write_sect(mdev, evicted/AL_EXT_PER_BM_SECT );
-		}
-
 		/* drbd_al_write_transaction(mdev,al_ext,enr);
 		   generic_make_request() are serialized on the
 		   current->bio_tail list now. Therefore we have
@@ -253,6 +246,7 @@
 		init_completion(&al_work.event);
 		al_work.al_ext = al_ext;
 		al_work.enr = enr;
+		al_work.old_enr = al_ext->lc_number;
 		al_work.w.cb = w_al_write_transaction;
 		drbd_queue_work_front(&mdev->data.work,&al_work.w);
 		wait_for_completion(&al_work.event);
@@ -302,14 +296,23 @@
 STATIC int
 w_al_write_transaction(struct Drbd_Conf *mdev, struct drbd_work *w, int unused)
 {
+	struct update_al_work *aw = (struct update_al_work*)w;
+	struct lc_element *updated = aw->al_ext;
+	const unsigned int new_enr = aw->enr;
+	const unsigned int evicted = aw->old_enr;
+
+	struct al_transaction* buffer;
+	sector_t sector;
 	int i,n,mx;
 	unsigned int extent_nr;
-	struct al_transaction* buffer;
-	sector_t sector;
 	u32 xor_sum=0;
 
-	struct lc_element *updated = ((struct update_al_work*)w)->al_ext;
-	unsigned int new_enr = ((struct update_al_work*)w)->enr;
+	/* do we have to do a bitmap write, first?
+	 * TODO reduce maximum latency:
+	 * submit both bios, then wait for both,
+	 * instead of doing two synchronous sector writes. */
+	if (mdev->state.conn < Connected && evicted != LC_FREE)
+		drbd_bm_write_sect(mdev, evicted/AL_EXT_PER_BM_SECT);
 
 	down(&mdev->md_io_mutex); // protects md_io_buffer, al_tr_cycle, ...
 	buffer = (struct al_transaction*)page_address(mdev->md_io_page);

From drbd-cvs at lists.linbit.com  Mon Aug 27 12:12:04 2007
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Mon Aug 27 12:12:07 2007
Subject: [DRBD-cvs] svn commit by lars - r3025 - branches/drbd-8.1/drbd -
	d330d33fc649b127a811e37378aec9430897bd77 DRBD: get rid 
Message-ID: <20070827101204.EAC714009A@garcon1.linbit.com>

Author: lars
Date: 2007-08-27 12:12:02 +0200 (Mon, 27 Aug 2007)
New Revision: 3025

Modified:
   branches/drbd-8.1/drbd/drbd_int.h
   branches/drbd-8.1/drbd/drbd_main.c
   branches/drbd-8.1/drbd/drbd_nl.c
   branches/drbd-8.1/drbd/drbd_wrappers.h
Log:
d330d33fc649b127a811e37378aec9430897bd77 DRBD: get rid of DEVICE_NAME macro, open-code "drbd"

Modified: branches/drbd-8.1/drbd/drbd_int.h
===================================================================
--- branches/drbd-8.1/drbd/drbd_int.h	2007-08-27 09:01:12 UTC (rev 3024)
+++ branches/drbd-8.1/drbd/drbd_int.h	2007-08-27 10:12:02 UTC (rev 3025)
@@ -59,9 +59,6 @@
 #include <linux/blkdev.h>
 #include <linux/bio.h>
 
-#undef DEVICE_NAME
-#define DEVICE_NAME "drbd"
-
 // XXX do we need this?
 #ifndef TRUE
 #define TRUE 1
@@ -134,7 +131,7 @@
 /* Info: do not remove the spaces around the "," before ##
  *	 Otherwise this is not portable from gcc-2.95 to gcc-3.3 */
 #define PRINTK(level, fmt, args...) \
-	printk(level DEVICE_NAME "%d: " fmt, \
+	printk(level "drbd%d: " fmt, \
 		mdev->minor , ##args)
 
 #define ALERT(fmt, args...) PRINTK(KERN_ALERT, fmt , ##args)

Modified: branches/drbd-8.1/drbd/drbd_main.c
===================================================================
--- branches/drbd-8.1/drbd/drbd_main.c	2007-08-27 09:01:12 UTC (rev 3024)
+++ branches/drbd-8.1/drbd/drbd_main.c	2007-08-27 10:12:02 UTC (rev 3025)
@@ -1641,8 +1641,8 @@
 	++total;
 	if (fallback && time_before(last_rep+3600*HZ, now)) {
 		last_rep = now;
-		printk(KERN_INFO DEVICE_NAME
-		       ": sendpage() omitted: %lu/%lu\n", fallback, total);
+		printk(KERN_INFO "drbd: sendpage() omitted: %lu/%lu\n",
+			fallback, total);
 	}
 #endif
 
@@ -1941,7 +1941,7 @@
 		return -ENODEV;
 
 	/*
-	printk(KERN_ERR DEVICE_NAME ": close(inode=%p,file=%p)"
+	printk(KERN_ERR "drbd: close(inode=%p,file=%p)"
 	       "current=%p,minor=%d,wc=%d\n", inode, file, current, minor,
 	       inode->i_writecount);
 	*/
@@ -2342,9 +2342,9 @@
 
 	kfree(minor_table);
 
-	drbd_unregister_blkdev(DRBD_MAJOR, DEVICE_NAME);
+	drbd_unregister_blkdev(DRBD_MAJOR, "drbd");
 
-	printk(KERN_INFO DEVICE_NAME": module cleanup done.\n");
+	printk(KERN_INFO "drbd: module cleanup done.\n");
 }
 
 struct drbd_conf *drbd_new_device(int minor)
@@ -2379,7 +2379,7 @@
 	disk->major = DRBD_MAJOR;
 	disk->first_minor = minor;
 	disk->fops = &drbd_ops;
-	sprintf(disk->disk_name, DEVICE_NAME "%d", minor);
+	sprintf(disk->disk_name, "drbd%d", minor);
 	disk->private_data = mdev;
 	add_disk(disk);
 
@@ -2428,15 +2428,15 @@
 
 	/* FIXME should be a compile time assert */
 	if (sizeof(struct Drbd_HandShake_Packet) != 80) {
-		printk(KERN_ERR DEVICE_NAME
-		       ": never change the size or layout "
+		printk(KERN_ERR
+		       "drbd: never change the size or layout "
 		       "of the HandShake packet.\n");
 		return -EINVAL;
 	}
 
 	if (1 > minor_count || minor_count > 255) {
-		printk(KERN_ERR DEVICE_NAME
-			": invalid minor_count (%d)\n", minor_count);
+		printk(KERN_ERR
+			"drbd: invalid minor_count (%d)\n", minor_count);
 #ifdef MODULE
 		return -EINVAL;
 #else
@@ -2448,10 +2448,10 @@
 	if (err)
 		return err;
 
-	err = register_blkdev(DRBD_MAJOR, DEVICE_NAME);
+	err = register_blkdev(DRBD_MAJOR, "drbd");
 	if (err) {
-		printk(KERN_ERR DEVICE_NAME
-		       ": unable to register block device major %d\n",
+		printk(KERN_ERR
+		       "drbd: unable to register block device major %d\n",
 		       DRBD_MAJOR);
 		return err;
 	}
@@ -2482,7 +2482,7 @@
 	drbd_proc = create_proc_entry("drbd",  S_IFREG | S_IRUGO , &proc_root);
 
 	if (!drbd_proc)	{
-		printk(KERN_ERR DEVICE_NAME": unable to register proc file\n");
+		printk(KERN_ERR "drbd: unable to register proc file\n");
 		goto Enomem;
 	}
 
@@ -2492,13 +2492,13 @@
 # error "Currently drbd depends on the proc file system (CONFIG_PROC_FS)"
 #endif
 
-	printk(KERN_INFO DEVICE_NAME ": initialised. "
+	printk(KERN_INFO "drbd: initialised. "
 	       "Version: " REL_VERSION " (api:%d/proto:%d)\n",
 	       API_VERSION, PRO_VERSION);
-	printk(KERN_INFO DEVICE_NAME ": %s\n", drbd_buildtag());
-	printk(KERN_INFO DEVICE_NAME": registered as block device major %d\n",
+	printk(KERN_INFO "drbd: %s\n", drbd_buildtag());
+	printk(KERN_INFO "drbd: registered as block device major %d\n",
 		DRBD_MAJOR);
-	printk(KERN_INFO DEVICE_NAME": minor_table @ 0x%p\n", minor_table);
+	printk(KERN_INFO "drbd: minor_table @ 0x%p\n", minor_table);
 
 	return 0; /* Success! */
 
@@ -2506,9 +2506,9 @@
 	drbd_cleanup();
 	if (err == -ENOMEM)
 		/* currently always the case */
-		printk(KERN_ERR DEVICE_NAME ": ran out of memory\n");
+		printk(KERN_ERR "drbd: ran out of memory\n");
 	else
-		printk(KERN_ERR DEVICE_NAME ": initialization failure\n");
+		printk(KERN_ERR "drbd: initialization failure\n");
 	return err;
 }
 

Modified: branches/drbd-8.1/drbd/drbd_nl.c
===================================================================
--- branches/drbd-8.1/drbd/drbd_nl.c	2007-08-27 09:01:12 UTC (rev 3024)
+++ branches/drbd-8.1/drbd/drbd_nl.c	2007-08-27 10:12:02 UTC (rev 3025)
@@ -144,7 +144,7 @@
 	struct cn_msg *req = data;
 	struct drbd_nl_cfg_req *nlp = (struct drbd_nl_cfg_req *)req->data;
 
-	printk(KERN_INFO DEVICE_NAME "%d: "
+	printk(KERN_INFO "drbd%d: "
 	       "Netlink: << %s (%d) - seq: %x, ack: %x, len: %x\n",
 	       nlp->drbd_minor,
 	       nl_packet_name(nlp->packet_type),
@@ -157,7 +157,7 @@
 	struct cn_msg *req = data;
 	struct drbd_nl_cfg_reply *nlp = (struct drbd_nl_cfg_reply *)req->data;
 
-	printk(KERN_INFO DEVICE_NAME "%d: "
+	printk(KERN_INFO "drbd%d: "
 	       "Netlink: >> %s (%d) - seq: %x, ack: %x, len: %x\n",
 	       nlp->minor,
 	       nlp->packet_type == P_nl_after_last_packet?
@@ -1625,7 +1625,7 @@
 		+ sizeof(short int);
 
 	if (!try_module_get(THIS_MODULE)) {
-		printk(KERN_ERR DEVICE_NAME "try_module_get() failed!\n");
+		printk(KERN_ERR "drbd: try_module_get() failed!\n");
 		return;
 	}
 
@@ -1670,7 +1670,7 @@
 
 	rr = cn_netlink_send(cn_reply, CN_IDX_DRBD, GFP_KERNEL);
 	if (rr && rr != -ESRCH)
-		printk(KERN_INFO DEVICE_NAME " cn_netlink_send()=%d\n", rr);
+		printk(KERN_INFO "drbd: cn_netlink_send()=%d\n", rr);
 
 	kfree(cn_reply);
 	module_put(THIS_MODULE);
@@ -1824,7 +1824,7 @@
 #endif
 	err = cn_add_callback(&cn_id_drbd, "cn_drbd", &drbd_connector_callback);
 	if (err) {
-		printk(KERN_ERR DEVICE_NAME "cn_drbd failed to register\n");
+		printk(KERN_ERR "drbd: cn_drbd failed to register\n");
 		return err;
 	}
 
@@ -1866,6 +1866,6 @@
 
 	rr = cn_netlink_send(cn_reply, CN_IDX_DRBD, GFP_KERNEL);
 	if (rr && rr != -ESRCH)
-		printk(KERN_INFO DEVICE_NAME " cn_netlink_send()=%d\n", rr);
+		printk(KERN_INFO "drbd: cn_netlink_send()=%d\n", rr);
 }
 

Modified: branches/drbd-8.1/drbd/drbd_wrappers.h
===================================================================
--- branches/drbd-8.1/drbd/drbd_wrappers.h	2007-08-27 09:01:12 UTC (rev 3024)
+++ branches/drbd-8.1/drbd/drbd_wrappers.h	2007-08-27 10:12:02 UTC (rev 3025)
@@ -118,8 +118,8 @@
 	bio->bi_rw = rw;
 
 	if (!bio->bi_bdev) {
-		printk(KERN_ERR DEVICE_NAME
-		       "%d: drbd_generic_make_request: bio->bi_bdev == NULL\n",
+		printk(KERN_ERR "drbd%d: drbd_generic_make_request: "
+				"bio->bi_bdev == NULL\n",
 		       mdev_to_minor(mdev));
 		dump_stack();
 		bio_endio(bio, bio->bi_size, -ENODEV);
@@ -190,7 +190,7 @@
 {
 	int ret = unregister_blkdev(major,name);
 	if (ret)
-		printk(KERN_ERR DEVICE_NAME": unregister of device failed\n");
+		printk(KERN_ERR "drbd: unregister of device failed\n");
 }
 #else
 #define drbd_unregister_blkdev unregister_blkdev

From drbd-cvs at lists.linbit.com  Mon Aug 27 12:16:38 2007
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Mon Aug 27 12:16:40 2007
Subject: [DRBD-cvs] svn commit by lars - r3026 - branches/drbd-8.1/drbd -
	b26d16ecd9ebc748def78094dd2d3c25c69f759e DRBD: get rid 
Message-ID: <20070827101638.49C064009A@garcon1.linbit.com>

Author: lars
Date: 2007-08-27 12:16:34 +0200 (Mon, 27 Aug 2007)
New Revision: 3026

Modified:
   branches/drbd-8.1/drbd/drbd_int.h
   branches/drbd-8.1/drbd/drbd_main.c
   branches/drbd-8.1/drbd/drbd_nl.c
   branches/drbd-8.1/drbd/drbd_receiver.c
   branches/drbd-8.1/drbd/drbd_req.c
   branches/drbd-8.1/drbd/drbd_wrappers.h
Log:
b26d16ecd9ebc748def78094dd2d3c25c69f759e DRBD: get rid of deprecated request_queue_t

Modified: branches/drbd-8.1/drbd/drbd_int.h
===================================================================
--- branches/drbd-8.1/drbd/drbd_int.h	2007-08-27 10:12:02 UTC (rev 3025)
+++ branches/drbd-8.1/drbd/drbd_int.h	2007-08-27 10:16:34 UTC (rev 3026)
@@ -777,7 +777,7 @@
 	struct drbd_backing_dev *bc; /* protected by inc_local() dec_local() */
 
 	sector_t p_size;     /* partner's disk size */
-	request_queue_t     *rq_queue;
+	struct request_queue *rq_queue;
 	struct block_device *this_bdev;
 	struct gendisk	    *vdisk;
 
@@ -1300,9 +1300,9 @@
 #endif
 
 /* drbd_req */
-extern int drbd_make_request_26(request_queue_t *q, struct bio *bio);
+extern int drbd_make_request_26(struct request_queue *q, struct bio *bio);
 extern int drbd_read_remote(struct drbd_conf *mdev, struct drbd_request *req);
-extern int drbd_merge_bvec(request_queue_t *, struct bio *, struct bio_vec *);
+extern int drbd_merge_bvec(struct request_queue *, struct bio *, struct bio_vec *);
 extern int is_valid_ar_handle(struct drbd_request *, sector_t);
 
 
@@ -1923,7 +1923,7 @@
  * d) q->unplug_fn(q), which is what all the drivers/md/ stuff uses...
  *
  */
-static inline void drbd_blk_run_queue(request_queue_t *q)
+static inline void drbd_blk_run_queue(struct request_queue *q)
 {
 	if (q && q->unplug_fn)
 		q->unplug_fn(q);

Modified: branches/drbd-8.1/drbd/drbd_main.c
===================================================================
--- branches/drbd-8.1/drbd/drbd_main.c	2007-08-27 10:12:02 UTC (rev 3025)
+++ branches/drbd-8.1/drbd/drbd_main.c	2007-08-27 10:16:34 UTC (rev 3026)
@@ -1951,7 +1951,7 @@
 	return 0;
 }
 
-void drbd_unplug_fn(request_queue_t *q)
+void drbd_unplug_fn(struct request_queue *q)
 {
 	struct drbd_conf *mdev = q->queuedata;
 
@@ -2262,7 +2262,7 @@
 		while (i--) {
 			struct drbd_conf        *mdev  = minor_to_mdev(i);
 			struct gendisk  **disk = &mdev->vdisk;
-			request_queue_t **q    = &mdev->rq_queue;
+			struct request_queue **q    = &mdev->rq_queue;
 
 			if (!mdev)
 				continue;
@@ -2351,7 +2351,7 @@
 {
 	struct drbd_conf *mdev = NULL;
 	struct gendisk *disk;
-	request_queue_t *q;
+	struct request_queue *q;
 
 	mdev = kzalloc(sizeof(struct drbd_conf), GFP_KERNEL);
 	if (!mdev)

Modified: branches/drbd-8.1/drbd/drbd_nl.c
===================================================================
--- branches/drbd-8.1/drbd/drbd_nl.c	2007-08-27 10:12:02 UTC (rev 3025)
+++ branches/drbd-8.1/drbd/drbd_nl.c	2007-08-27 10:16:34 UTC (rev 3026)
@@ -632,8 +632,8 @@
 
 void drbd_setup_queue_param(struct drbd_conf *mdev, unsigned int max_seg_s)
 {
-	request_queue_t * const q = mdev->rq_queue;
-	request_queue_t * const b = mdev->bc->backing_bdev->bd_disk->queue;
+	struct request_queue * const q = mdev->rq_queue;
+	struct request_queue * const b = mdev->bc->backing_bdev->bd_disk->queue;
 	/* unsigned int old_max_seg_s = q->max_segment_size; */
 
 	if (b->merge_bvec_fn && !mdev->bc->dc.use_bmbv)

Modified: branches/drbd-8.1/drbd/drbd_receiver.c
===================================================================
--- branches/drbd-8.1/drbd/drbd_receiver.c	2007-08-27 10:12:02 UTC (rev 3025)
+++ branches/drbd-8.1/drbd/drbd_receiver.c	2007-08-27 10:16:34 UTC (rev 3026)
@@ -193,7 +193,7 @@
 				     unsigned int data_size,
 				     unsigned int gfp_mask)
 {
-	request_queue_t *q;
+	struct request_queue *q;
 	struct Tl_epoch_entry *e;
 	struct bio_vec *bvec;
 	struct page *page;

Modified: branches/drbd-8.1/drbd/drbd_req.c
===================================================================
--- branches/drbd-8.1/drbd/drbd_req.c	2007-08-27 10:12:02 UTC (rev 3025)
+++ branches/drbd-8.1/drbd/drbd_req.c	2007-08-27 10:16:34 UTC (rev 3026)
@@ -1086,7 +1086,7 @@
 	return 0;
 }
 
-int drbd_make_request_26(request_queue_t *q, struct bio *bio)
+int drbd_make_request_26(struct request_queue *q, struct bio *bio)
 {
 	unsigned int s_enr, e_enr;
 	struct drbd_conf *mdev = (struct drbd_conf *) q->queuedata;
@@ -1164,7 +1164,7 @@
  */
 /* FIXME for two_primaries,
  * we should use DRBD_MAX_SEGMENT_SIZE instead of AL_EXTENT_SIZE */
-int drbd_merge_bvec(request_queue_t *q, struct bio *bio, struct bio_vec *bvec)
+int drbd_merge_bvec(struct request_queue *q, struct bio *bio, struct bio_vec *bvec)
 {
 	struct drbd_conf *mdev = (struct drbd_conf *) q->queuedata;
 	unsigned int bio_offset =
@@ -1180,7 +1180,7 @@
 		if (limit <= bvec->bv_len)
 			limit = bvec->bv_len;
 	} else if (limit && inc_local(mdev)) {
-		request_queue_t * const b =
+		struct request_queue * const b =
 			mdev->bc->backing_bdev->bd_disk->queue;
 		if (b->merge_bvec_fn && mdev->bc->dc.use_bmbv) {
 			backing_limit = b->merge_bvec_fn(b, bio, bvec);

Modified: branches/drbd-8.1/drbd/drbd_wrappers.h
===================================================================
--- branches/drbd-8.1/drbd/drbd_wrappers.h	2007-08-27 10:12:02 UTC (rev 3025)
+++ branches/drbd-8.1/drbd/drbd_wrappers.h	2007-08-27 10:16:34 UTC (rev 3026)
@@ -134,7 +134,7 @@
 
 static inline void drbd_plug_device(struct drbd_conf *mdev)
 {
-	request_queue_t *q;
+	struct request_queue *q;
 	q = bdev_get_queue(mdev->this_bdev);
 
 	spin_lock_irq(q->queue_lock);

From drbd-cvs at lists.linbit.com  Mon Aug 27 21:29:57 2007
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Mon Aug 27 21:29:59 2007
Subject: [DRBD-cvs] svn commit by lars - r3027 - branches/drbd-8.0/drbd -
	fixes for linux 2.6.23 * r2983 | lars | 2007-07-24 10:4
Message-ID: <20070827192957.756534009A@garcon1.linbit.com>

Author: lars
Date: 2007-08-27 21:29:55 +0200 (Mon, 27 Aug 2007)
New Revision: 3027

Modified:
   branches/drbd-8.0/drbd/drbd_compat_wrappers.h
   branches/drbd-8.0/drbd/drbd_int.h
   branches/drbd-8.0/drbd/drbd_main.c
Log:
fixes for linux 2.6.23
 * r2983 | lars | 2007-07-24 10:47:36 +0200
   8e628f935b8c66bf595449b41be12a966e9f20a0 DRBD: remove NULL contructor from kmem_cache_create invocations
   actually, introduce a new compatibility wrapper...


Modified: branches/drbd-8.0/drbd/drbd_compat_wrappers.h
===================================================================
--- branches/drbd-8.0/drbd/drbd_compat_wrappers.h	2007-08-27 10:16:34 UTC (rev 3026)
+++ branches/drbd-8.0/drbd/drbd_compat_wrappers.h	2007-08-27 19:29:55 UTC (rev 3027)
@@ -174,11 +174,23 @@
 #endif
 
 #ifdef USE_KMEM_CACHE_S
-typedef struct kmem_cache_s drbd_kmem_cache_t;
-#else
-typedef struct kmem_cache drbd_kmem_cache_t;
+#define kmem_cache kmem_cache_s
 #endif
 
+/* dtor was removed in 20c2df83d25c6a95affe6157a4c9cac4cf5ffaac
+ * on the way to 2.6.23 */
+static inline struct kmem_cache *
+drbd_kmem_cache_create (const char *name, size_t size, size_t align,
+        unsigned long flags,
+        void (*ctor)(void*, struct kmem_cache *, unsigned long))
+{
+	return kmem_cache_create(name, size, align, flags, ctor
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+		, NULL
+#endif
+		);
+}
+
 #ifdef NEED_BACKPORT_OF_ATOMIC_ADD
 
 #if defined(__x86_64__)

Modified: branches/drbd-8.0/drbd/drbd_int.h
===================================================================
--- branches/drbd-8.0/drbd/drbd_int.h	2007-08-27 10:16:34 UTC (rev 3026)
+++ branches/drbd-8.0/drbd/drbd_int.h	2007-08-27 19:29:55 UTC (rev 3027)
@@ -1168,8 +1168,8 @@
 #include "drbd_compat_wrappers.h"
 
 extern int minor_count;
-extern drbd_kmem_cache_t *drbd_request_cache;
-extern drbd_kmem_cache_t *drbd_ee_cache;
+extern struct kmem_cache *drbd_request_cache;
+extern struct kmem_cache *drbd_ee_cache;
 extern mempool_t *drbd_request_mempool;
 extern mempool_t *drbd_ee_mempool;
 

Modified: branches/drbd-8.0/drbd/drbd_main.c
===================================================================
--- branches/drbd-8.0/drbd/drbd_main.c	2007-08-27 10:16:34 UTC (rev 3026)
+++ branches/drbd-8.0/drbd/drbd_main.c	2007-08-27 19:29:55 UTC (rev 3027)
@@ -135,8 +135,8 @@
  */
 struct Drbd_Conf **minor_table = NULL;
 
-drbd_kmem_cache_t *drbd_request_cache;
-drbd_kmem_cache_t *drbd_ee_cache;
+struct kmem_cache *drbd_request_cache;
+struct kmem_cache *drbd_ee_cache;
 mempool_t *drbd_request_mempool;
 mempool_t *drbd_ee_mempool;
 
@@ -2161,15 +2161,15 @@
 	drbd_pp_pool         = NULL;
 
 	// caches
-	drbd_request_cache = kmem_cache_create(
+	drbd_request_cache = drbd_kmem_cache_create(
 		"drbd_req_cache", sizeof(drbd_request_t),
-		0, 0, NULL, NULL);
+		0, 0, NULL);
 	if (drbd_request_cache == NULL)
 		goto Enomem;
 
-	drbd_ee_cache = kmem_cache_create(
+	drbd_ee_cache = drbd_kmem_cache_create(
 		"drbd_ee_cache", sizeof(struct Tl_epoch_entry),
-		0, 0, NULL, NULL);
+		0, 0, NULL);
 	if (drbd_ee_cache == NULL)
 		goto Enomem;
 

From drbd-cvs at lists.linbit.com  Mon Aug 27 21:38:52 2007
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Mon Aug 27 21:38:54 2007
Subject: [DRBD-cvs] svn commit by lars - r3028 - branches/drbd-8.0/drbd -
	fixes for linux 2.6.23 * r3003 | lars | 2007-07-27 15:0
Message-ID: <20070827193852.7FA8B4009A@garcon1.linbit.com>

Author: lars
Date: 2007-08-27 21:38:47 +0200 (Mon, 27 Aug 2007)
New Revision: 3028

Modified:
   branches/drbd-8.0/drbd/drbd_compat_wrappers.h
   branches/drbd-8.0/drbd/drbd_main.c
Log:
fixes for linux 2.6.23
 * r3003 | lars | 2007-07-27 15:07:19 +0200
   unregister_blkdev is void now; add wrapper for older kernels.


Modified: branches/drbd-8.0/drbd/drbd_compat_wrappers.h
===================================================================
--- branches/drbd-8.0/drbd/drbd_compat_wrappers.h	2007-08-27 19:29:55 UTC (rev 3027)
+++ branches/drbd-8.0/drbd/drbd_compat_wrappers.h	2007-08-27 19:38:47 UTC (rev 3028)
@@ -191,6 +191,17 @@
 		);
 }
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,23)
+static inline void drbd_unregister_blkdev(unsigned int major, const char *name)
+{
+	int ret = unregister_blkdev(major,name);
+	if (ret)
+		printk(KERN_ERR DEVICE_NAME": unregister of device failed\n");
+}
+#else
+#define drbd_unregister_blkdev unregister_blkdev
+#endif
+
 #ifdef NEED_BACKPORT_OF_ATOMIC_ADD
 
 #if defined(__x86_64__)

Modified: branches/drbd-8.0/drbd/drbd_main.c
===================================================================
--- branches/drbd-8.0/drbd/drbd_main.c	2007-08-27 19:29:55 UTC (rev 3027)
+++ branches/drbd-8.0/drbd/drbd_main.c	2007-08-27 19:38:47 UTC (rev 3028)
@@ -2306,8 +2306,7 @@
 
 	kfree(minor_table);
 
-	if (unregister_blkdev(MAJOR_NR, DEVICE_NAME) != 0)
-		printk(KERN_ERR DEVICE_NAME": unregister of device failed\n");
+	drbd_unregister_blkdev(LANANA_DRBD_MAJOR, DEVICE_NAME);
 
 	printk(KERN_INFO DEVICE_NAME": module cleanup done.\n");
 }

From drbd-cvs at lists.linbit.com  Mon Aug 27 21:59:45 2007
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Mon Aug 27 21:59:49 2007
Subject: [DRBD-cvs] svn commit by lars - r3029 - branches/drbd-8.0/drbd -
	fixes for linux 2.6.23 * r3026 | lars | 2007-08-27 12:1
Message-ID: <20070827195945.925754009A@garcon1.linbit.com>

Author: lars
Date: 2007-08-27 21:59:44 +0200 (Mon, 27 Aug 2007)
New Revision: 3029

Modified:
   branches/drbd-8.0/drbd/drbd_compat_wrappers.h
   branches/drbd-8.0/drbd/drbd_int.h
   branches/drbd-8.0/drbd/drbd_main.c
   branches/drbd-8.0/drbd/drbd_nl.c
   branches/drbd-8.0/drbd/drbd_receiver.c
   branches/drbd-8.0/drbd/drbd_req.c
Log:
fixes for linux 2.6.23
 * r3026 | lars | 2007-08-27 12:16:34 +0200
   b26d16ecd9ebc748def78094dd2d3c25c69f759e DRBD: get rid of deprecated request_queue_t
   in fact, that git commit was done weeks ago, but got lost in the initial back-merge
   of git->svn


Modified: branches/drbd-8.0/drbd/drbd_compat_wrappers.h
===================================================================
--- branches/drbd-8.0/drbd/drbd_compat_wrappers.h	2007-08-27 19:38:47 UTC (rev 3028)
+++ branches/drbd-8.0/drbd/drbd_compat_wrappers.h	2007-08-27 19:59:44 UTC (rev 3029)
@@ -140,7 +140,7 @@
 
 static inline void drbd_plug_device(drbd_dev *mdev)
 {
-	request_queue_t *q;
+	struct request_queue *q;
 	q = bdev_get_queue(mdev->this_bdev);
 
 	spin_lock_irq(q->queue_lock);

Modified: branches/drbd-8.0/drbd/drbd_int.h
===================================================================
--- branches/drbd-8.0/drbd/drbd_int.h	2007-08-27 19:38:47 UTC (rev 3028)
+++ branches/drbd-8.0/drbd/drbd_int.h	2007-08-27 19:59:44 UTC (rev 3029)
@@ -780,7 +780,7 @@
 	struct drbd_backing_dev *bc; // protected by inc_local() dec_local()
 
 	sector_t p_size;     /* partner's disk size */
-	request_queue_t     *rq_queue;
+	struct request_queue *rq_queue;
 	struct block_device *this_bdev;
 	struct gendisk      *vdisk;
 
@@ -1278,9 +1278,9 @@
 #endif
 
 // drbd_req
-extern int drbd_make_request_26(request_queue_t *q, struct bio *bio);
+extern int drbd_make_request_26(struct request_queue *q, struct bio *bio);
 extern int drbd_read_remote(drbd_dev *mdev, drbd_request_t *req);
-extern int drbd_merge_bvec(request_queue_t *, struct bio *, struct bio_vec *);
+extern int drbd_merge_bvec(struct request_queue *, struct bio *, struct bio_vec *);
 extern int is_valid_ar_handle(drbd_request_t *, sector_t);
 
 
@@ -1908,7 +1908,7 @@
  * d) q->unplug_fn(q), which is what all the drivers/md/ stuff uses...
  *
  */
-static inline void drbd_blk_run_queue(request_queue_t *q)
+static inline void drbd_blk_run_queue(struct request_queue *q)
 {
 	if (q && q->unplug_fn)
 		q->unplug_fn(q);

Modified: branches/drbd-8.0/drbd/drbd_main.c
===================================================================
--- branches/drbd-8.0/drbd/drbd_main.c	2007-08-27 19:38:47 UTC (rev 3028)
+++ branches/drbd-8.0/drbd/drbd_main.c	2007-08-27 19:59:44 UTC (rev 3029)
@@ -1924,7 +1924,7 @@
 	return 0;
 }
 
-STATIC void drbd_unplug_fn(request_queue_t *q)
+STATIC void drbd_unplug_fn(struct request_queue *q)
 {
 	drbd_dev *mdev = q->queuedata;
 
@@ -2232,7 +2232,7 @@
 		while (i--) {
 			drbd_dev        *mdev  = minor_to_mdev(i);
 			struct gendisk  **disk = &mdev->vdisk;
-			request_queue_t **q    = &mdev->rq_queue;
+			struct request_queue **q = &mdev->rq_queue;
 
 			if(!mdev) continue;
 			drbd_free_resources(mdev);
@@ -2315,7 +2315,7 @@
 {
 	drbd_dev *mdev = NULL;
 	struct gendisk *disk;
-	request_queue_t *q;
+	struct request_queue *q;
 
 	mdev = kzalloc(sizeof(drbd_dev),GFP_KERNEL);
 	if(!mdev) goto Enomem;

Modified: branches/drbd-8.0/drbd/drbd_nl.c
===================================================================
--- branches/drbd-8.0/drbd/drbd_nl.c	2007-08-27 19:38:47 UTC (rev 3028)
+++ branches/drbd-8.0/drbd/drbd_nl.c	2007-08-27 19:59:44 UTC (rev 3029)
@@ -619,8 +619,8 @@
 
 void drbd_setup_queue_param(drbd_dev *mdev, unsigned int max_seg_s)
 {
-	request_queue_t * const q = mdev->rq_queue;
-	request_queue_t * const b = mdev->bc->backing_bdev->bd_disk->queue;
+	struct request_queue * const q = mdev->rq_queue;
+	struct request_queue * const b = mdev->bc->backing_bdev->bd_disk->queue;
 	//unsigned int old_max_seg_s = q->max_segment_size;
 
 	if (b->merge_bvec_fn && !mdev->bc->dc.use_bmbv)

Modified: branches/drbd-8.0/drbd/drbd_receiver.c
===================================================================
--- branches/drbd-8.0/drbd/drbd_receiver.c	2007-08-27 19:38:47 UTC (rev 3028)
+++ branches/drbd-8.0/drbd/drbd_receiver.c	2007-08-27 19:59:44 UTC (rev 3029)
@@ -237,7 +237,7 @@
 				     unsigned int data_size,
 				     unsigned int gfp_mask)
 {
-	request_queue_t *q;
+	struct request_queue *q;
 	struct Tl_epoch_entry* e;
 	struct bio_vec *bvec;
 	struct page *page;

Modified: branches/drbd-8.0/drbd/drbd_req.c
===================================================================
--- branches/drbd-8.0/drbd/drbd_req.c	2007-08-27 19:38:47 UTC (rev 3028)
+++ branches/drbd-8.0/drbd/drbd_req.c	2007-08-27 19:59:44 UTC (rev 3029)
@@ -1065,7 +1065,7 @@
 	return 0;
 }
 
-int drbd_make_request_26(request_queue_t *q, struct bio *bio)
+int drbd_make_request_26(struct request_queue *q, struct bio *bio)
 {
 	unsigned int s_enr,e_enr;
 	struct Drbd_Conf* mdev = (drbd_dev*) q->queuedata;
@@ -1142,7 +1142,7 @@
  */
 /* FIXME for two_primaries,
  * we should use DRBD_MAX_SEGMENT_SIZE instead of AL_EXTENT_SIZE */
-int drbd_merge_bvec(request_queue_t *q, struct bio *bio, struct bio_vec *bvec)
+int drbd_merge_bvec(struct request_queue *q, struct bio *bio, struct bio_vec *bvec)
 {
 	struct Drbd_Conf* mdev = (drbd_dev*) q->queuedata;
 	unsigned int bio_offset = (unsigned int)bio->bi_sector << 9; // 32 bit
@@ -1158,7 +1158,7 @@
 	if (bio_size == 0) {
 		if (limit <= bvec->bv_len) limit = bvec->bv_len;
 	} else if (limit && inc_local(mdev)) {
-		request_queue_t * const b = mdev->bc->backing_bdev->bd_disk->queue;
+		struct request_queue * const b = mdev->bc->backing_bdev->bd_disk->queue;
 		if(b->merge_bvec_fn && mdev->bc->dc.use_bmbv) {
 			backing_limit = b->merge_bvec_fn(b,bio,bvec);
 			limit = min(limit,backing_limit);

From drbd-cvs at lists.linbit.com  Tue Aug 28 21:43:00 2007
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Tue Aug 28 21:43:02 2007
Subject: [DRBD-cvs] svn commit by phil - r3030 - branches - Branch for new
	features 
Message-ID: <20070828194300.49B074009A@garcon1.linbit.com>

Author: phil
Date: 2007-08-28 21:42:59 +0200 (Tue, 28 Aug 2007)
New Revision: 3030

Added:
   branches/drbd-8.2/
Log:
Branch for new features


Copied: branches/drbd-8.2 (from rev 3029, branches/drbd-8.1)

From drbd-cvs at lists.linbit.com  Tue Aug 28 21:44:20 2007
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Tue Aug 28 21:44:22 2007
Subject: [DRBD-cvs] svn commit by phil - r3031 - in branches/drbd-8.2: drbd
	drbd/linux scripts user - Unfinished work on the
	data-checksum feature. 
Message-ID: <20070828194420.B554C4009A@garcon1.linbit.com>

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}} },

From drbd-cvs at lists.linbit.com  Tue Aug 28 22:01:26 2007
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Tue Aug 28 22:01:29 2007
Subject: [DRBD-cvs] svn commit by lars - r3032 - branches/drbd-8.0/user -
	Explicit NULL argp for ioctls without arguments. Even i
Message-ID: <20070828200126.86E884009A@garcon1.linbit.com>

Author: lars
Date: 2007-08-28 22:01:18 +0200 (Tue, 28 Aug 2007)
New Revision: 3032

Modified:
   branches/drbd-8.0/user/drbdmeta.c
Log:
Explicit NULL argp for ioctls without arguments.
Even if an ioctl does not take an argument,
we still have to provide an explicit NULL.
Otherwise we may fail with EFAULT "Bad address".
This worked so far only by accident.


Modified: branches/drbd-8.0/user/drbdmeta.c
===================================================================
--- branches/drbd-8.0/user/drbdmeta.c	2007-08-28 19:44:18 UTC (rev 3031)
+++ branches/drbd-8.0/user/drbdmeta.c	2007-08-28 20:01:18 UTC (rev 3032)
@@ -905,7 +905,7 @@
 		exit(20);
 	}
 
-	if (ioctl(cfg->md_fd, BLKFLSBUF) == -1) {
+	if (ioctl(cfg->md_fd, BLKFLSBUF, NULL) == -1) {
 		PERROR("WARN: ioctl(,BLKFLSBUF,) failed");
 	}
 
@@ -1509,7 +1509,7 @@
 		PERROR("fsync() failed");
 		err = -1;
 	}
-	if (ioctl(cfg->md_fd, BLKFLSBUF) == -1) {
+	if (ioctl(cfg->md_fd, BLKFLSBUF, NULL) == -1) {
 		PERROR("ioctl(,BLKFLSBUF,) failed");
 		err = -1;
 	}

From drbd-cvs at lists.linbit.com  Tue Aug 28 22:18:47 2007
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Tue Aug 28 22:18:48 2007
Subject: [DRBD-cvs] svn commit by lars - r3033 - in branches/drbd-8.1: .
	user - svnp run. Investigated 3019 to 3032 r3032 by lars on 20
Message-ID: <20070828201847.331294009A@garcon1.linbit.com>

Author: lars
Date: 2007-08-28 22:18:46 +0200 (Tue, 28 Aug 2007)
New Revision: 3033

Modified:
   branches/drbd-8.1/
   branches/drbd-8.1/user/drbdmeta.c
Log:
svnp run. Investigated 3019 to 3032

r3032 by lars on 2007-08-28 22:01:18 +0200 (Die, 28 Aug 2007) 
  Ge?\195?\164nderte Pfade:
     M /branches/drbd-8.0/user/drbdmeta.c
  
  Explicit NULL argp for ioctls without arguments.
  Even if an ioctl does not take an argument,
  we still have to provide an explicit NULL.
  Otherwise we may fail with EFAULT "Bad address".
  This worked so far only by accident.
  




Property changes on: branches/drbd-8.1
___________________________________________________________________
Name: propagate:at:2
   - 3019
   + 3032

Modified: branches/drbd-8.1/user/drbdmeta.c
===================================================================
--- branches/drbd-8.1/user/drbdmeta.c	2007-08-28 20:01:18 UTC (rev 3032)
+++ branches/drbd-8.1/user/drbdmeta.c	2007-08-28 20:18:46 UTC (rev 3033)
@@ -905,7 +905,7 @@
 		exit(20);
 	}
 
-	if (ioctl(cfg->md_fd, BLKFLSBUF) == -1) {
+	if (ioctl(cfg->md_fd, BLKFLSBUF, NULL) == -1) {
 		PERROR("WARN: ioctl(,BLKFLSBUF,) failed");
 	}
 
@@ -1509,7 +1509,7 @@
 		PERROR("fsync() failed");
 		err = -1;
 	}
-	if (ioctl(cfg->md_fd, BLKFLSBUF) == -1) {
+	if (ioctl(cfg->md_fd, BLKFLSBUF, NULL) == -1) {
 		PERROR("ioctl(,BLKFLSBUF,) failed");
 		err = -1;
 	}

From drbd-cvs at lists.linbit.com  Wed Aug 29 11:05:11 2007
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Wed Aug 29 11:05:12 2007
Subject: [DRBD-cvs] svn commit by lars - r3034 - branches/drbd-8.0/user -
	don't try to read from before the start of the device..
Message-ID: <20070829090511.4E7AC4009A@garcon1.linbit.com>

Author: lars
Date: 2007-08-29 11:05:10 +0200 (Wed, 29 Aug 2007)
New Revision: 3034

Modified:
   branches/drbd-8.0/user/drbdmeta_unfinished_rewrite.c
Log:
don't try to read from before the start of the device...


Modified: branches/drbd-8.0/user/drbdmeta_unfinished_rewrite.c
===================================================================
--- branches/drbd-8.0/user/drbdmeta_unfinished_rewrite.c	2007-08-28 20:18:46 UTC (rev 3033)
+++ branches/drbd-8.0/user/drbdmeta_unfinished_rewrite.c	2007-08-29 09:05:10 UTC (rev 3034)
@@ -2028,7 +2028,7 @@
 		DRBD_MD_INDEX_FLEX_INT, cfg->bd_size);
 
 	printf("%lld\n%lld\n%lld\n", cfg->bd_size, fixed_offset, flex_offset);
-	if (fixed_offset < (off_t)cfg->bd_size - 4096) {
+	if (0 <= fixed_offset && fixed_offset < (off_t)cfg->bd_size - 4096) {
 		/* ... v07 fixed-size internal meta data? */
 		PREAD(cfg->md_fd, on_disk_buffer, 4096, fixed_offset);
 	

From drbd-cvs at lists.linbit.com  Wed Aug 29 11:09:09 2007
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Wed Aug 29 11:09:10 2007
Subject: [DRBD-cvs] svn commit by lars - r3035 - branches/drbd-8.0/user -
	prevent drbdmeta from trying to wipe out "just in case"
Message-ID: <20070829090909.169CB4009A@garcon1.linbit.com>

Author: lars
Date: 2007-08-29 11:09:08 +0200 (Wed, 29 Aug 2007)
New Revision: 3035

Modified:
   branches/drbd-8.0/user/drbdmeta.c
Log:
prevent drbdmeta from trying to wipe out "just in case"
something that just is no there (device < 128MB).
the old drbdmeta is sooo ugly.
well, but the rewrite is still unfinished :(


Modified: branches/drbd-8.0/user/drbdmeta.c
===================================================================
--- branches/drbd-8.0/user/drbdmeta.c	2007-08-29 09:05:10 UTC (rev 3034)
+++ branches/drbd-8.0/user/drbdmeta.c	2007-08-29 09:09:08 UTC (rev 3035)
@@ -273,9 +273,9 @@
 	struct md_cpu md;
 
 	/* _byte_ offsets of our "super block" and other data, within fd */
-	u64 md_offset;
-	u64 al_offset;
-	u64 bm_offset;
+	s64 md_offset;
+	s64 al_offset;
+	s64 bm_offset;
 	size_t md_mmaped_length;
 	size_t al_mmaped_length;
 	size_t bm_mmaped_length;
@@ -684,14 +684,14 @@
 int v07_parse(struct format *cfg, char **argv, int argc, int *ai);
 int v07_md_initialize(struct format *cfg);
 void v07_md_erase_others(struct format *cfg);
-u64 v07_md_get_byte_offset(struct format * cfg);
+s64 v07_md_get_byte_offset(struct format * cfg);
 
 int v08_md_open(struct format *cfg);
 int v08_md_cpu_to_disk(struct format *cfg);
 int v08_md_disk_to_cpu(struct format *cfg);
 int v08_md_initialize(struct format *cfg);
 void v08_md_erase_others(struct format *cfg);
-u64 v08_md_get_byte_offset(struct format * cfg);
+s64 v08_md_get_byte_offset(struct format * cfg);
 
 struct format_ops f_ops[] = {
 	[Drbd_06] = {
@@ -881,7 +881,7 @@
 }
 
 int v07_style_md_open(struct format *cfg,
-		      u64 (*md_get_byte_offset) (struct format *),
+		      s64 (*md_get_byte_offset) (struct format *),
 		      size_t size)
 {
 	struct stat sb;
@@ -938,7 +938,7 @@
 	// For the case that someone modified la_sect by hand..
 	if( (cfg->md_index == DRBD_MD_INDEX_INTERNAL ||
 	     cfg->md_index == DRBD_MD_INDEX_FLEX_INT ) &&
-	    (cfg->md.la_sect*512 > cfg->md_offset) ) {
+	    (cfg->md.la_sect*512 > (u64)cfg->md_offset) ) {
 		printf("la-size-sect was too big, fixed.\n");
 		cfg->md.la_sect = cfg->md_offset/512;
 	}
@@ -972,7 +972,7 @@
 }
 
 void md_erase_sb(struct format *cfg,
-		 u64 (*md_get_byte_offset) (struct format *))
+		 s64 (*md_get_byte_offset) (struct format *))
 {
 	/* in case these are internal meta data, we need to
 	   make sure that there is no v08 superblock at the end
@@ -980,7 +980,7 @@
 
 	unsigned char zero_sector[512];
 	struct format cfg_f;
-	u64 offset;
+	s64 offset;
 	int bw;
 
 	if(cfg->md_index == DRBD_MD_INDEX_INTERNAL ||
@@ -992,6 +992,8 @@
 		   in the front of the meta data area. */
 
 		offset = md_get_byte_offset(&cfg_f);
+		if (offset < 0)
+			return;
 		if(lseek64(cfg->md_fd, offset, SEEK_SET) == -1) {
 			PERROR("lseek64() failed");
 			exit(20);
@@ -1404,9 +1406,9 @@
  begin of v07 {{{
  ******************************************/
 
-u64 v07_md_get_byte_offset(struct format *cfg)
+s64 v07_md_get_byte_offset(struct format *cfg)
 {
-	u64 offset;
+	s64 offset;
 
 	switch(cfg->md_index) {
 	default: /* external, some index */
@@ -1545,9 +1547,9 @@
  begin of v08 {{{
  ******************************************/
 
-u64 v08_md_get_byte_offset(struct format *cfg)
+s64 v08_md_get_byte_offset(struct format *cfg)
 {
-	u64 offset;
+	s64 offset;
 
 	switch(cfg->md_index) {
 	default: /* external, some index */

From drbd-cvs at lists.linbit.com  Wed Aug 29 12:11:49 2007
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Wed Aug 29 12:11:51 2007
Subject: [DRBD-cvs] svn commit by lars - r3036 - in branches/drbd-8.1: .
	user - svnp run. Investigated 3032 to 3035 r3034 by lars on 20
Message-ID: <20070829101149.46EB94009A@garcon1.linbit.com>

Author: lars
Date: 2007-08-29 12:11:47 +0200 (Wed, 29 Aug 2007)
New Revision: 3036

Modified:
   branches/drbd-8.1/
   branches/drbd-8.1/user/drbdmeta.c
   branches/drbd-8.1/user/drbdmeta_unfinished_rewrite.c
Log:
svnp run. Investigated 3032 to 3035

r3034 by lars on 2007-08-29 11:05:10 +0200 (Wed, 29 Aug 2007) 
  Changed paths:
     M /branches/drbd-8.0/user/drbdmeta_unfinished_rewrite.c
  
  don't try to read from before the start of the device...
  

r3035 by lars on 2007-08-29 11:09:08 +0200 (Wed, 29 Aug 2007) 
  Changed paths:
     M /branches/drbd-8.0/user/drbdmeta.c
  
  prevent drbdmeta from trying to wipe out "just in case"
  something that just is no there (device < 128MB).
  the old drbdmeta is sooo ugly.
  well, but the rewrite is still unfinished :(
  




Property changes on: branches/drbd-8.1
___________________________________________________________________
Name: propagate:at:2
   - 3032
   + 3035

Modified: branches/drbd-8.1/user/drbdmeta.c
===================================================================
--- branches/drbd-8.1/user/drbdmeta.c	2007-08-29 09:09:08 UTC (rev 3035)
+++ branches/drbd-8.1/user/drbdmeta.c	2007-08-29 10:11:47 UTC (rev 3036)
@@ -273,9 +273,9 @@
 	struct md_cpu md;
 
 	/* _byte_ offsets of our "super block" and other data, within fd */
-	u64 md_offset;
-	u64 al_offset;
-	u64 bm_offset;
+	s64 md_offset;
+	s64 al_offset;
+	s64 bm_offset;
 	size_t md_mmaped_length;
 	size_t al_mmaped_length;
 	size_t bm_mmaped_length;
@@ -684,14 +684,14 @@
 int v07_parse(struct format *cfg, char **argv, int argc, int *ai);
 int v07_md_initialize(struct format *cfg);
 void v07_md_erase_others(struct format *cfg);
-u64 v07_md_get_byte_offset(struct format * cfg);
+s64 v07_md_get_byte_offset(struct format * cfg);
 
 int v08_md_open(struct format *cfg);
 int v08_md_cpu_to_disk(struct format *cfg);
 int v08_md_disk_to_cpu(struct format *cfg);
 int v08_md_initialize(struct format *cfg);
 void v08_md_erase_others(struct format *cfg);
-u64 v08_md_get_byte_offset(struct format * cfg);
+s64 v08_md_get_byte_offset(struct format * cfg);
 
 struct format_ops f_ops[] = {
 	[Drbd_06] = {
@@ -881,7 +881,7 @@
 }
 
 int v07_style_md_open(struct format *cfg,
-		      u64 (*md_get_byte_offset) (struct format *),
+		      s64 (*md_get_byte_offset) (struct format *),
 		      size_t size)
 {
 	struct stat sb;
@@ -938,7 +938,7 @@
 	// For the case that someone modified la_sect by hand..
 	if( (cfg->md_index == DRBD_MD_INDEX_INTERNAL ||
 	     cfg->md_index == DRBD_MD_INDEX_FLEX_INT ) &&
-	    (cfg->md.la_sect*512 > cfg->md_offset) ) {
+	    (cfg->md.la_sect*512 > (u64)cfg->md_offset) ) {
 		printf("la-size-sect was too big, fixed.\n");
 		cfg->md.la_sect = cfg->md_offset/512;
 	}
@@ -972,7 +972,7 @@
 }
 
 void md_erase_sb(struct format *cfg,
-		 u64 (*md_get_byte_offset) (struct format *))
+		 s64 (*md_get_byte_offset) (struct format *))
 {
 	/* in case these are internal meta data, we need to
 	   make sure that there is no v08 superblock at the end
@@ -980,7 +980,7 @@
 
 	unsigned char zero_sector[512];
 	struct format cfg_f;
-	u64 offset;
+	s64 offset;
 	int bw;
 
 	if(cfg->md_index == DRBD_MD_INDEX_INTERNAL ||
@@ -992,6 +992,8 @@
 		   in the front of the meta data area. */
 
 		offset = md_get_byte_offset(&cfg_f);
+		if (offset < 0)
+			return;
 		if(lseek64(cfg->md_fd, offset, SEEK_SET) == -1) {
 			PERROR("lseek64() failed");
 			exit(20);
@@ -1404,9 +1406,9 @@
  begin of v07 {{{
  ******************************************/
 
-u64 v07_md_get_byte_offset(struct format *cfg)
+s64 v07_md_get_byte_offset(struct format *cfg)
 {
-	u64 offset;
+	s64 offset;
 
 	switch(cfg->md_index) {
 	default: /* external, some index */
@@ -1545,9 +1547,9 @@
  begin of v08 {{{
  ******************************************/
 
-u64 v08_md_get_byte_offset(struct format *cfg)
+s64 v08_md_get_byte_offset(struct format *cfg)
 {
-	u64 offset;
+	s64 offset;
 
 	switch(cfg->md_index) {
 	default: /* external, some index */

Modified: branches/drbd-8.1/user/drbdmeta_unfinished_rewrite.c
===================================================================
--- branches/drbd-8.1/user/drbdmeta_unfinished_rewrite.c	2007-08-29 09:09:08 UTC (rev 3035)
+++ branches/drbd-8.1/user/drbdmeta_unfinished_rewrite.c	2007-08-29 10:11:47 UTC (rev 3036)
@@ -2028,7 +2028,7 @@
 		DRBD_MD_INDEX_FLEX_INT, cfg->bd_size);
 
 	printf("%lld\n%lld\n%lld\n", cfg->bd_size, fixed_offset, flex_offset);
-	if (fixed_offset < (off_t)cfg->bd_size - 4096) {
+	if (0 <= fixed_offset && fixed_offset < (off_t)cfg->bd_size - 4096) {
 		/* ... v07 fixed-size internal meta data? */
 		PREAD(cfg->md_fd, on_disk_buffer, 4096, fixed_offset);
 	

From drbd-cvs at lists.linbit.com  Thu Aug 30 21:45:30 2007
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Thu Aug 30 21:45:33 2007
Subject: [DRBD-cvs] svn commit by phil - r3037 - in branches/drbd-8.0:
	documentation scripts user - Implemented the
	"become-primary-on" option for the star
Message-ID: <20070830194530.7D19B2C05A@garcon2.linbit.com>

Author: phil
Date: 2007-08-30 21:45:14 +0200 (Thu, 30 Aug 2007)
New Revision: 3037

Modified:
   branches/drbd-8.0/documentation/drbd.conf.sgml
   branches/drbd-8.0/documentation/drbd.sgml
   branches/drbd-8.0/documentation/drbdadm.sgml
   branches/drbd-8.0/documentation/drbddisk.sgml
   branches/drbd-8.0/documentation/drbdmeta.sgml
   branches/drbd-8.0/documentation/drbdsetup.sgml
   branches/drbd-8.0/scripts/drbd
   branches/drbd-8.0/scripts/drbd.conf
   branches/drbd-8.0/user/drbdadm_main.c
   branches/drbd-8.0/user/drbdadm_scanner.fl
Log:
Implemented the "become-primary-on" option for the startup section.


Modified: branches/drbd-8.0/documentation/drbd.conf.sgml
===================================================================
--- branches/drbd-8.0/documentation/drbd.conf.sgml	2007-08-29 10:11:47 UTC (rev 3036)
+++ branches/drbd-8.0/documentation/drbd.conf.sgml	2007-08-30 19:45:14 UTC (rev 3037)
@@ -1,4 +1,4 @@
-<!DOCTYPE RefEntry PUBLIC "-//Davenport//DTD DocBook V3.0//EN" "/usr/share/xml/docbook/schema/dtd/3/docbookx.dtd" []>
+<!DOCTYPE RefEntry PUBLIC "-//Davenport//DTD DocBook V3.0//EN" []>
 <refentry>
 <docinfo><date>06 April 2006</date></docinfo>
 
@@ -217,8 +217,8 @@
     <manvolnum>8</manvolnum></citerefentry> for a detailed description
     of this section's parameters.
     Optional parameters:
-    <option>wfc-timeout</option>, <option>degr-wfc-timeout</option> and
-    <option>wait-after-sb</option>.
+    <option>wfc-timeout</option>, <option>degr-wfc-timeout</option>,
+    <option>wait-after-sb</option> and <option>become-primary-on</option>.
   </para>
   </listitem>
 </varlistentry>
@@ -846,6 +846,18 @@
 </varlistentry>
 
 <varlistentry>
+  <term><option>become-primary-on <replaceable>node-name</replaceable></option></term>
+  <listitem><para>
+  Sets on which node the device should be promoted to primary role by
+  the init script. The <replaceable>node-name</replaceable> might either
+  be a host name or the key word <option>both</option>. When this option is 
+  not set the devices stay in secondary role on both nodes. Usually
+  one deligates the role assignment to a cluster manager (e.g. heartbeat).
+  </para>
+  </listitem>
+</varlistentry>
+
+<varlistentry>
   <term><option>rate <replaceable>rate</replaceable></option></term>
   <listitem><para>
   <indexterm><primary>drbd.conf</primary><secondary>rate </secondary></indexterm>

Modified: branches/drbd-8.0/documentation/drbd.sgml
===================================================================
--- branches/drbd-8.0/documentation/drbd.sgml	2007-08-29 10:11:47 UTC (rev 3036)
+++ branches/drbd-8.0/documentation/drbd.sgml	2007-08-30 19:45:14 UTC (rev 3037)
@@ -1,4 +1,4 @@
-<!DOCTYPE RefEntry PUBLIC "-//Davenport//DTD DocBook V3.0//EN" "/usr/share/xml/docbook/schema/dtd/3/docbookx.dtd" []>
+<!DOCTYPE RefEntry PUBLIC "-//Davenport//DTD DocBook V3.0//EN" []>
 <refentry>
 <docinfo><date>01 Oct 2001</date></docinfo>
 

Modified: branches/drbd-8.0/documentation/drbdadm.sgml
===================================================================
--- branches/drbd-8.0/documentation/drbdadm.sgml	2007-08-29 10:11:47 UTC (rev 3036)
+++ branches/drbd-8.0/documentation/drbdadm.sgml	2007-08-30 19:45:14 UTC (rev 3037)
@@ -1,4 +1,4 @@
-<!DOCTYPE RefEntry PUBLIC "-//Davenport//DTD DocBook V3.0//EN" "/usr/share/xml/docbook/schema/dtd/3/docbookx.dtd" []>
+<!DOCTYPE RefEntry PUBLIC "-//Davenport//DTD DocBook V3.0//EN" []>
 <refentry>
   <docinfo><date>09 Feb 2004</date></docinfo>
 

Modified: branches/drbd-8.0/documentation/drbddisk.sgml
===================================================================
--- branches/drbd-8.0/documentation/drbddisk.sgml	2007-08-29 10:11:47 UTC (rev 3036)
+++ branches/drbd-8.0/documentation/drbddisk.sgml	2007-08-30 19:45:14 UTC (rev 3037)
@@ -1,4 +1,4 @@
-<!DOCTYPE RefEntry PUBLIC "-//Davenport//DTD DocBook V3.0//EN" "/usr/share/xml/docbook/schema/dtd/3/docbookx.dtd" []>
+<!DOCTYPE RefEntry PUBLIC "-//Davenport//DTD DocBook V3.0//EN" []>
 <refentry>
 <docinfo><date>30 Aug 2005</date></docinfo>
 

Modified: branches/drbd-8.0/documentation/drbdmeta.sgml
===================================================================
--- branches/drbd-8.0/documentation/drbdmeta.sgml	2007-08-29 10:11:47 UTC (rev 3036)
+++ branches/drbd-8.0/documentation/drbdmeta.sgml	2007-08-30 19:45:14 UTC (rev 3037)
@@ -1,4 +1,4 @@
-<!DOCTYPE RefEntry PUBLIC "-//Davenport//DTD DocBook V3.0//EN" "/usr/share/xml/docbook/schema/dtd/3/docbookx.dtd" []>
+<!DOCTYPE RefEntry PUBLIC "-//Davenport//DTD DocBook V3.0//EN" []>
 <refentry>
   <docinfo><date>31 March 2006</date></docinfo>
 

Modified: branches/drbd-8.0/documentation/drbdsetup.sgml
===================================================================
--- branches/drbd-8.0/documentation/drbdsetup.sgml	2007-08-29 10:11:47 UTC (rev 3036)
+++ branches/drbd-8.0/documentation/drbdsetup.sgml	2007-08-30 19:45:14 UTC (rev 3037)
@@ -1,4 +1,4 @@
-<!DOCTYPE RefEntry PUBLIC "-//Davenport//DTD DocBook V3.0//EN" "/usr/share/xml/docbook/schema/dtd/3/docbookx.dtd" []>
+<!DOCTYPE RefEntry PUBLIC "-//Davenport//DTD DocBook V3.0//EN" []>
 <refentry>
   <docinfo><date>30 March 2006</date></docinfo>
 

Modified: branches/drbd-8.0/scripts/drbd
===================================================================
--- branches/drbd-8.0/scripts/drbd	2007-08-29 10:11:47 UTC (rev 3036)
+++ branches/drbd-8.0/scripts/drbd	2007-08-30 19:45:14 UTC (rev 3037)
@@ -96,6 +96,8 @@
 	[ -d /var/lock/subsys ] && touch /var/lock/subsys/drbd  # for RedHat
 	echo "."
 	$DRBDADM wait-con-int # User interruptible version of wait-connect all
+
+	$DRBDADM sh-b-pri all # Become primary if configured
 	;;
     stop)
 	echo -n "Stopping all DRBD resources"

Modified: branches/drbd-8.0/scripts/drbd.conf
===================================================================
--- branches/drbd-8.0/scripts/drbd.conf	2007-08-29 10:11:47 UTC (rev 3036)
+++ branches/drbd-8.0/scripts/drbd.conf	2007-08-30 19:45:14 UTC (rev 3037)
@@ -170,6 +170,11 @@
     # it to continue waiting in this case set this option.
     # 
     # wait-after-sb;
+
+    # In case you are using DRBD for GFS/OCFS2 you want that the
+    # startup script promotes it to primary. Nodenames are also
+    # possible instead of "both".
+    # become-primary-on both;
   }
 
   disk {

Modified: branches/drbd-8.0/user/drbdadm_main.c
===================================================================
--- branches/drbd-8.0/user/drbdadm_main.c	2007-08-29 10:11:47 UTC (rev 3036)
+++ branches/drbd-8.0/user/drbdadm_main.c	2007-08-30 19:45:14 UTC (rev 3037)
@@ -105,11 +105,14 @@
 static int sh_ll_dev(struct d_resource* ,const char* );
 static int sh_md_dev(struct d_resource* ,const char* );
 static int sh_md_idx(struct d_resource* ,const char* );
+static int sh_b_pri(struct d_resource* ,const char* );
 static int admm_generic(struct d_resource* ,const char* );
 static int adm_khelper(struct d_resource* ,const char* );
 static int adm_generic_b(struct d_resource* ,const char* );
 static int hidden_cmds(struct d_resource* ,const char* );
 
+static char* get_opt_val(struct d_option*,const char*,char*);
+
 static struct ifreq* get_ifreq();
 
 char ss_buffer[255];
@@ -230,6 +233,7 @@
   { "sh-md-dev",         sh_md_dev,     2,1,0 },
   { "sh-md-idx",         sh_md_idx,     2,1,0 },
   { "sh-ip",             sh_ip,         0,1,0 },
+  { "sh-b-pri",          sh_b_pri,      2,1,0 },
   { "pri-on-incon-degr", adm_khelper,   3,1,0 },
   { "pri-lost-after-sb", adm_khelper,   3,1,0 },
   { "outdate-peer",      adm_khelper,   3,1,0 },
@@ -537,7 +541,18 @@
   return 0;
 }
 
+static int sh_b_pri(struct d_resource *res,const char* unused __attribute((unused)))
+{
+  char* val;
 
+  val = get_opt_val(res->startup_options, "become-primary-on", NULL);
+  if ( val && ( !strcmp(val,nodeinfo.nodename) ||
+		!strcmp(val,"both") ) ) {
+    return adm_generic_s(res,"primary");
+  }
+  return 0;
+}
+
 static int sh_mod_parms(struct d_resource* res __attribute((unused)),const char* unused __attribute((unused)))
 {
   int mc=global_options.minor_count;
@@ -759,6 +774,19 @@
     OPT=OPT->next; \
   }
 
+#define make_options_wait(OPT) \
+  while(OPT) { \
+    if(!strcmp(OPT->name,"become-primary-on")) {\
+      OPT=OPT->next; continue; \
+    } \
+    if(OPT->value) { \
+      ssprintf(argv[NA(argc)],"--%s=%s",OPT->name,OPT->value); \
+    } else { \
+      ssprintf(argv[NA(argc)],"--%s",OPT->name); \
+    } \
+    OPT=OPT->next; \
+  }
+
 int adm_attach(struct d_resource* res,const char* unused __attribute((unused)))
 {
   char* argv[MAX_ARGS];
@@ -891,8 +919,6 @@
   return rv;
 }
 
-static char* get_opt_val(struct d_option*,const char*,char*);
-
 static int adm_khelper(struct d_resource* res ,const char* cmd)
 {
   int rv=0;
@@ -1012,7 +1038,7 @@
   argv[NA(argc)]=res->me->device;
   argv[NA(argc)]="wait-connect";
   opt=res->startup_options;
-  make_options(opt);
+  make_options_wait(opt);
   argv[NA(argc)]=0;
 
   rv = m_system(argv,SLEEPS_FOREVER);
@@ -1203,7 +1229,7 @@
     argv[NA(argc)]=res->me->device;
     argv[NA(argc)]="wait-connect";
     opt=res->startup_options;
-    make_options(opt);
+    make_options_wait(opt);
     argv[NA(argc)]=0;
 
     pids[i++]=m_system(argv,RETURN_PID);
@@ -1551,6 +1577,7 @@
 void validate_resource(struct d_resource * res)
 {
   struct d_option* opt;
+  char *bpo;
 
   if (!res->protocol) {
     if (!common || !common->protocol) {
@@ -1607,6 +1634,16 @@
   if ( (opt = find_opt(res->handlers, "outdate-peer")) ) {
     if(strstr(opt->value,"drbd-peer-outdater")) sanity_check_perm();
   }
+
+  bpo = get_opt_val(res->startup_options, "become-primary-on", "undef");
+  opt = find_opt(res->net_options, "allow-two-primaries");
+  if(!strcmp(bpo,"both") && opt == NULL) {
+    fprintf(stderr,
+	    "In resource %s:\n"
+	    "become-primary-on is set to both, but allow-two-primaries "
+	    "is not set.\n", res->name);
+    config_valid = 0;
+  }
 }
 
 static void global_validate(void)

Modified: branches/drbd-8.0/user/drbdadm_scanner.fl
===================================================================
--- branches/drbd-8.0/user/drbdadm_scanner.fl	2007-08-29 10:11:47 UTC (rev 3036)
+++ branches/drbd-8.0/user/drbdadm_scanner.fl	2007-08-30 19:45:14 UTC (rev 3037)
@@ -88,6 +88,7 @@
 al-extents		{ DP; CP; RC(AL_EXTENTS); return TK_SYNCER_OPTION;}
 wfc-timeout		{ DP; CP; RC(WFC_TIMEOUT); return TK_STARTUP_OPTION;}
 degr-wfc-timeout	{ DP; CP; RC(DEGR_WFC_TIMEOUT); return TK_STARTUP_OPTION;}
+become-primary-on	{ DP; CP; return TK_STARTUP_OPTION;     }
 wait-after-sb		{ DP; CP; return TK_STARTUP_SWITCH;     }
 pri-on-incon-degr	{ DP; CP; return TK_HANDLER_OPTION;	}
 pri-lost-after-sb	{ DP; CP; return TK_HANDLER_OPTION;	}

From drbd-cvs at lists.linbit.com  Thu Aug 30 22:17:26 2007
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Thu Aug 30 22:17:28 2007
Subject: [DRBD-cvs] svn commit by phil - r3038 - in branches/drbd-8.0: .
	scripts - Florian's nice Xen-DRBD script. 
Message-ID: <20070830201726.4886A2C05A@garcon2.linbit.com>

Author: phil
Date: 2007-08-30 22:17:24 +0200 (Thu, 30 Aug 2007)
New Revision: 3038

Added:
   branches/drbd-8.0/scripts/block-drbd
Modified:
   branches/drbd-8.0/drbd.spec.in
   branches/drbd-8.0/scripts/Makefile
Log:
Florian's nice Xen-DRBD script.


Modified: branches/drbd-8.0/drbd.spec.in
===================================================================
--- branches/drbd-8.0/drbd.spec.in	2007-08-30 19:45:14 UTC (rev 3037)
+++ branches/drbd-8.0/drbd.spec.in	2007-08-30 20:17:24 UTC (rev 3038)
@@ -122,6 +122,7 @@
 /sbin/drbdmeta
 /usr/lib/drbd/outdate-peer.sh
 /etc/ha.d/resource.d/drbddisk
+/etc/xen/scripts/block-drbd
 
 %defattr(644,root,root)
 %config(noreplace) /etc/drbd.conf

Modified: branches/drbd-8.0/scripts/Makefile
===================================================================
--- branches/drbd-8.0/scripts/Makefile	2007-08-30 19:45:14 UTC (rev 3037)
+++ branches/drbd-8.0/scripts/Makefile	2007-08-30 20:17:24 UTC (rev 3038)
@@ -62,6 +62,8 @@
 	install -m 755 drbddisk $(PREFIX)/etc/ha.d/resource.d
 	install -d $(PREFIX)/usr/lib/drbd
 	install -m 755 outdate-peer.sh $(PREFIX)/usr/lib/drbd
+	mkdir -p $(PREFIX)/etc/xen/scripts
+	install -m 755 block-drbd $(PREFIX)/etc/xen/scripts
 ifeq ($(DIST),suselike)
 	ln -sf ../etc/init.d/drbd $(PREFIX)/sbin/rcdrbd
 endif
@@ -77,4 +79,5 @@
 uninstall:
 	rm $(INITD)drbd
 	rm $(PREFIX)/etc/ha.d/resource.d/drbddisk
+	rm $(PREFIX)/etc/xen/scripts/block-drbd
 	! test -L $(PREFIX)/sbin/rcdrbd || rm $(PREFIX)/sbin/rcdrbd

Added: branches/drbd-8.0/scripts/block-drbd
===================================================================
--- branches/drbd-8.0/scripts/block-drbd	2007-08-30 19:45:14 UTC (rev 3037)
+++ branches/drbd-8.0/scripts/block-drbd	2007-08-30 20:17:24 UTC (rev 3038)
@@ -0,0 +1,278 @@
+#!/bin/bash
+#
+# A modified version of Xen's block script for use with DRBD.
+#
+# The idea is to give over the role assignment of DRBD
+# devices to this script. It will promote a DRBD device to primary
+# role when the Xen DomU gets started. During a Xen live migration
+# both DRBD devices will be primary for a short time. Other
+# than that only one side of the DRBD device pair will be 
+# primary at a time.
+#
+# Syntax example for a DomU.cfg. 'r0' is the DRBD resource name.
+#  disk = [ 'drbd:r0,sda1,w' ]
+#
+# Of course you have to set the "allow-two-primaries" in the
+# DRBD config.
+#
+# By Florian Haas, LINBIT Information Technologies 2007.
+#
+
+dir=$(dirname "$0")
+. "$dir/block-common.sh"
+
+##
+# canonicalise_mode mode
+#
+# Takes the given mode, which may be r, w, ro, rw, w!, or rw!, or variations
+# thereof, and canonicalises them to one of
+#
+#   'r': perform checks for a new read-only mount;
+#   'w': perform checks for a read-write mount; or
+#   '!': perform no checks at all.
+#
+canonicalise_mode()
+{
+  local mode="$1"
+
+  if ! expr index "$mode" 'w' >/dev/null
+  then
+    echo 'r'
+  elif ! expr index "$mode" '!' >/dev/null
+  then
+    echo 'w'
+  else
+    echo '!'
+  fi
+}
+
+
+##
+# check_sharing device mode
+#
+# Check whether the device requested is already in use.  To use the device in
+# read-only mode, it may be in use in read-only mode, but may not be in use in
+# read-write anywhere at all.  To use the device in read-write mode, it must
+# not be in use anywhere at all.
+#
+# Prints one of
+#
+#    'local': the device may not be used because it is mounted in the current
+#             (i.e. the privileged domain) in a way incompatible with the
+#             requested mode;
+#    'guest': the device may not be used because it already mounted by a guest
+#             in a way incompatible with the requested mode; or
+#    'ok':    the device may be used.
+#
+check_sharing()
+{
+  local dev="$1"
+  local mode="$2"
+
+  local devmm=$(device_major_minor "$dev")
+  local file
+
+  if [ "$mode" = 'w' ]
+  then
+    toskip="^$"
+  else
+    toskip="^[^ ]* [^ ]* [^ ]* ro[, ]"
+  fi
+
+  for file in $(cat /proc/mounts | grep -v "$toskip" | cut -f 1 -d ' ')
+  do
+    if [ -e "$file" ]
+    then
+      local d=$(device_major_minor "$file")
+
+      if [ "$d" = "$devmm" ]
+      then
+        echo 'local'
+        return
+      fi
+    fi
+  done
+
+  local base_path="$XENBUS_BASE_PATH/$XENBUS_TYPE"
+  for dom in $(xenstore-list "$base_path")
+  do
+    for dev in $(xenstore-list "$base_path/$dom")
+    do
+      d=$(xenstore_read_default "$base_path/$dom/$dev/physical-device" "")
+
+      if [ "$d" = "$devmm" ]
+      then
+        if [ "$mode" = 'w' ]
+        then
+          if ! same_vm $dom
+          then
+            echo 'guest'
+            return
+          fi
+        else
+          local m=$(xenstore_read "$base_path/$dom/$dev/mode")
+          m=$(canonicalise_mode "$m")
+
+          if [ "$m" = 'w' ]
+          then
+            if ! same_vm $dom
+            then
+              echo 'guest'
+              return
+            fi
+          fi
+        fi
+      fi
+    done
+  done
+
+  echo 'ok'
+}
+
+
+same_vm()
+{
+  local otherdom="$1"
+  # Note that othervm can be MISSING here, because Xend will be racing with
+  # the hotplug scripts -- the entries in /local/domain can be removed by
+  # Xend before the hotplug scripts have removed the entry in
+  # /local/domain/0/backend/.  In this case, we want to pretend that the
+  # VM is the same as FRONTEND_UUID, because that way the 'sharing' will be
+  # allowed.
+  local othervm=$(xenstore_read_default "/local/domain/$otherdom/vm"         \
+                  "$FRONTEND_UUID")
+
+  [ "$FRONTEND_UUID" = "$othervm" ]
+}
+
+
+##
+# check_device_sharing dev mode
+#
+# Perform the sharing check for the given physical device and mode.
+#
+check_device_sharing()
+{
+  local dev="$1"
+  local mode=$(canonicalise_mode "$2")
+  local result
+
+  if [ "x$mode" = 'x!' ]
+  then
+    return 0
+  fi
+
+  result=$(check_sharing "$dev" "$mode")
+
+  if [ "$result" != 'ok' ]
+  then
+    do_ebusy "Device $dev is mounted " "$mode" "$result"
+  fi
+}
+
+
+##
+# do_ebusy prefix mode result
+#
+# Helper function for check_device_sharing check_file_sharing, calling ebusy
+# with an error message constructed from the given prefix, mode, and result
+# from a call to check_sharing.
+#
+do_ebusy()
+{
+  local prefix="$1"
+  local mode="$2"
+  local result="$3"
+
+  if [ "$result" = 'guest' ]
+  then
+    dom='a guest '
+    when='now'
+  else
+    dom='the privileged '
+    when='by a guest'
+  fi
+
+  if [ "$mode" = 'w' ]
+  then
+    m1=''
+    m2=''
+  else
+    m1='read-write '
+    m2='read-only '
+  fi
+
+  release_lock "block"
+  ebusy \
+"${prefix}${m1}in ${dom}domain,
+and so cannot be mounted ${m2}${when}."
+}
+
+
+t=$(xenstore_read_default "$XENBUS_PATH/type" 'MISSING')
+
+case "$command" in
+  add)
+    phys=$(xenstore_read_default "$XENBUS_PATH/physical-device" 'MISSING')
+    if [ "$phys" != 'MISSING' ]
+    then
+      # Depending upon the hotplug configuration, it is possible for this
+      # script to be called twice, so just bail.
+      exit 0
+    fi
+
+    if [ -n "$t" ]
+    then
+      p=$(xenstore_read "$XENBUS_PATH/params")
+      mode=$(xenstore_read "$XENBUS_PATH/mode")
+    fi
+
+    case $t in 
+      drbd)
+        drbd_resource=$p
+        drbd_state="$(/sbin/drbdadm state $drbd_resource)"
+        drbd_lstate="${drbd_state%%/*}"
+        drbd_dev="$(/sbin/drbdadm sh-dev $drbd_resource)"
+	if [ "$drbd_lstate" != 'Primary' ]; then
+	  /sbin/drbdadm primary $drbd_resource
+	fi
+        dev=$drbd_dev
+        FRONTEND_ID=$(xenstore_read "$XENBUS_PATH/frontend-id")
+        FRONTEND_UUID=$(xenstore_read_default \
+            "/local/domain/$FRONTEND_ID/vm" 'unknown')
+        claim_lock "block"
+        check_device_sharing "$dev" "$mode"
+	write_dev "$dev"
+        release_lock "block"
+	exit 0
+	;;
+      "")
+        claim_lock "block"
+        success
+        release_lock "block"
+	;;
+    esac
+    ;;
+
+  remove)
+    case $t in 
+      drbd)
+        p=$(xenstore_read "$XENBUS_PATH/params")
+	drbd_resource=$p
+	drbd_state="$(/sbin/drbdadm state $drbd_resource)"
+	drbd_lstate="${drbd_state%%/*}"
+	drbd_dev="$(/sbin/drbdadm sh-dev $drbd_resource)"
+
+	if [ "$drbd_lstate" != 'Secondary' ]; then
+	  /sbin/drbdadm secondary $drbd_resource
+	fi
+	exit 0
+	;;
+
+      "")
+        exit 0
+	;;
+    esac
+    ;;
+
+esac


Property changes on: branches/drbd-8.0/scripts/block-drbd
___________________________________________________________________
Name: svn:executable
   + *

From drbd-cvs at lists.linbit.com  Fri Aug 31 09:41:42 2007
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Fri Aug 31 09:41:44 2007
Subject: [DRBD-cvs] svn commit by florian - r3039 -
	branches/drbd-8.0/scripts - Added extensive comments.
	Sanitized device sharing chec
Message-ID: <20070831074142.BC5102C05A@garcon2.linbit.com>

Author: florian
Date: 2007-08-31 09:41:41 +0200 (Fri, 31 Aug 2007)
New Revision: 3039

Modified:
   branches/drbd-8.0/scripts/block-drbd
Log:
Added extensive comments. Sanitized device sharing check for DRBD.


Modified: branches/drbd-8.0/scripts/block-drbd
===================================================================
--- branches/drbd-8.0/scripts/block-drbd	2007-08-30 20:17:24 UTC (rev 3038)
+++ branches/drbd-8.0/scripts/block-drbd	2007-08-31 07:41:41 UTC (rev 3039)
@@ -1,22 +1,58 @@
 #!/bin/bash
 #
-# A modified version of Xen's block script for use with DRBD.
+# Copyright (c) 2007 LINBIT Information Technologies GmbH
+# Based on the original "block" VBD script by XenSource Inc.
 #
-# The idea is to give over the role assignment of DRBD
-# devices to this script. It will promote a DRBD device to primary
-# role when the Xen DomU gets started. During a Xen live migration
-# both DRBD devices will be primary for a short time. Other
-# than that only one side of the DRBD device pair will be 
-# primary at a time.
+# This script implements the "drbd" VBD type. To use a DRBD resource
+# as a virtual block device, include a line similar to this in your
+# domU configuration:
 #
-# Syntax example for a DomU.cfg. 'r0' is the DRBD resource name.
-#  disk = [ 'drbd:r0,sda1,w' ]
+# disk = [ 'drbd:myresource,xvda1,w' ]
 #
-# Of course you have to set the "allow-two-primaries" in the
-# DRBD config.
+# This will direct Xen to put the DRBD resource named 'myresource'
+# into the Primary role, and configure it as device xvda1 in your
+# domU. You may use as many DRBD resources as you like. If you are
+# using DRBD in dual-Primary mode (available in DRBD versions 8.0 and
+# up), your DRBD-backed domU will be live migration capable. 
 #
-# By Florian Haas, LINBIT Information Technologies 2007.
+# IMPORTANT: If you run DRBD in dual-Primary mode with Xen, you MUST
+#            ensure that the only time the resource is accessed by
+#            both nodes is during domain migration. If you fire up a
+#            DRBD-backed domU simultaneously on two nodes, you WILL
+#            wreck your VBD data. DO NOT attempt to set up a live
+#            migration capable, DRBD-backed domU unless you
+#            understand these implications.
 #
+# This script will not load the DRBD kernel module for you, nor will
+# it attach, detach, connect, or disconnect your resource. The init
+# script distributed with DRBD will do that for you. Make sure it is
+# started before attempting to start a DRBD-backed domU.
+#
+# Known limitations:
+#
+# - With 'file' and 'phy' VBD's, Xen will allow one block device to be
+#   made available read-only to multiple domU's, or be mounted
+#   read-only in the dom0 and be made available read-only to
+#   domU's. This is not supported by the 'drbd' VBD type.
+# - Tested only on Debian etch with Xen 3.0.3, and on SLES 10 SP1 with
+#   Xen 3.0.4. 
+#
+# For more information about DRBD, visit http://www.drbd.org/.
+#   
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of version 2.1 of the GNU Lesser General Public
+# License as published by the Free Software Foundation.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+#
 
 dir=$(dirname "$0")
 . "$dir/block-common.sh"
@@ -72,12 +108,9 @@
   local devmm=$(device_major_minor "$dev")
   local file
 
-  if [ "$mode" = 'w' ]
-  then
-    toskip="^$"
-  else
-    toskip="^[^ ]* [^ ]* [^ ]* ro[, ]"
-  fi
+  # Here, different from the original 'block' script, we don't check
+  # explicitly for read/write mounts. See "known limitations" above.
+  toskip="^$"
 
   for file in $(cat /proc/mounts | grep -v "$toskip" | cut -f 1 -d ' ')
   do
@@ -102,25 +135,13 @@
 
       if [ "$d" = "$devmm" ]
       then
-        if [ "$mode" = 'w' ]
+        # Here, different from the original 'block' script, we don't
+        # check explicitly for read/write mounts. See "known
+        # limitations" above.
+        if ! same_vm $dom
         then
-          if ! same_vm $dom
-          then
-            echo 'guest'
-            return
-          fi
-        else
-          local m=$(xenstore_read "$base_path/$dom/$dev/mode")
-          m=$(canonicalise_mode "$m")
-
-          if [ "$m" = 'w' ]
-          then
-            if ! same_vm $dom
-            then
-              echo 'guest'
-              return
-            fi
-          fi
+          echo 'guest'
+          return
         fi
       fi
     done

From drbd-cvs at lists.linbit.com  Fri Aug 31 09:51:08 2007
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Fri Aug 31 09:51:10 2007
Subject: [DRBD-cvs] svn commit by florian - r3040 -
	branches/drbd-8.0/scripts - M-x untabify 
Message-ID: <20070831075108.CB5C12C05A@garcon2.linbit.com>

Author: florian
Date: 2007-08-31 09:51:08 +0200 (Fri, 31 Aug 2007)
New Revision: 3040

Modified:
   branches/drbd-8.0/scripts/block-drbd
Log:
M-x untabify


Modified: branches/drbd-8.0/scripts/block-drbd
===================================================================
--- branches/drbd-8.0/scripts/block-drbd	2007-08-31 07:41:41 UTC (rev 3039)
+++ branches/drbd-8.0/scripts/block-drbd	2007-08-31 07:51:08 UTC (rev 3040)
@@ -254,24 +254,24 @@
         drbd_state="$(/sbin/drbdadm state $drbd_resource)"
         drbd_lstate="${drbd_state%%/*}"
         drbd_dev="$(/sbin/drbdadm sh-dev $drbd_resource)"
-	if [ "$drbd_lstate" != 'Primary' ]; then
-	  /sbin/drbdadm primary $drbd_resource
-	fi
+        if [ "$drbd_lstate" != 'Primary' ]; then
+          /sbin/drbdadm primary $drbd_resource
+        fi
         dev=$drbd_dev
         FRONTEND_ID=$(xenstore_read "$XENBUS_PATH/frontend-id")
         FRONTEND_UUID=$(xenstore_read_default \
             "/local/domain/$FRONTEND_ID/vm" 'unknown')
         claim_lock "block"
         check_device_sharing "$dev" "$mode"
-	write_dev "$dev"
+        write_dev "$dev"
         release_lock "block"
-	exit 0
-	;;
+        exit 0
+        ;;
       "")
         claim_lock "block"
         success
         release_lock "block"
-	;;
+        ;;
     esac
     ;;
 
@@ -279,20 +279,20 @@
     case $t in 
       drbd)
         p=$(xenstore_read "$XENBUS_PATH/params")
-	drbd_resource=$p
-	drbd_state="$(/sbin/drbdadm state $drbd_resource)"
-	drbd_lstate="${drbd_state%%/*}"
-	drbd_dev="$(/sbin/drbdadm sh-dev $drbd_resource)"
+        drbd_resource=$p
+        drbd_state="$(/sbin/drbdadm state $drbd_resource)"
+        drbd_lstate="${drbd_state%%/*}"
+        drbd_dev="$(/sbin/drbdadm sh-dev $drbd_resource)"
 
-	if [ "$drbd_lstate" != 'Secondary' ]; then
-	  /sbin/drbdadm secondary $drbd_resource
-	fi
-	exit 0
-	;;
+        if [ "$drbd_lstate" != 'Secondary' ]; then
+          /sbin/drbdadm secondary $drbd_resource
+        fi
+        exit 0
+        ;;
 
       "")
         exit 0
-	;;
+        ;;
     esac
     ;;
 

From drbd-cvs at lists.linbit.com  Fri Aug 31 13:10:42 2007
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Fri Aug 31 13:10:44 2007
Subject: [DRBD-cvs] svn commit by phil - r3041 - in branches/drbd-8.0: .
	debian drbd/linux - Preparing 8.0.6 for release on Monday 
Message-ID: <20070831111042.3A38F2C05A@garcon2.linbit.com>

Author: phil
Date: 2007-08-31 13:10:40 +0200 (Fri, 31 Aug 2007)
New Revision: 3041

Modified:
   branches/drbd-8.0/ChangeLog
   branches/drbd-8.0/debian/changelog
   branches/drbd-8.0/drbd.spec.in
   branches/drbd-8.0/drbd/linux/drbd_config.h
Log:
Preparing 8.0.6 for release on Monday


Modified: branches/drbd-8.0/ChangeLog
===================================================================
--- branches/drbd-8.0/ChangeLog	2007-08-31 07:51:08 UTC (rev 3040)
+++ branches/drbd-8.0/ChangeLog	2007-08-31 11:10:40 UTC (rev 3041)
@@ -4,6 +4,22 @@
  Cumulative changes since last tarball.
  For even more detail, use "svn log" and "svn diff".
 
+8.0.6 (api:86/proto:86)
+--------
+ * Fixed DRBD to not deadlock while doing bitmap updates on Linux
+   2.6.22 and later.
+ * Make it compile on Linux-2.6.22 and later.
+ * Removed a hardcoded path to docbook DTDs from our sgml files,
+   maybe improving the situation with building the documentation.
+ * drbdmeta can now also initialize meta data on meta devices
+   smaller than 128MB.
+ * Added an explicit NULL argument to our ioctl() calls in drbdmeta.
+ * Added scripts/block-drbd, which is a nice way hand over DRBD
+   role assignment to Xen, allowing one to do Xen live migrations
+   in a sane way.
+ * Added an option to drbd.conf which instructs the init script
+   to promote DRBD devices to primary role upon machine start up.
+
 8.0.5 (api:86/proto:86)
 --------
  * Changed the default behaviour of the init script. Now the init

Modified: branches/drbd-8.0/debian/changelog
===================================================================
--- branches/drbd-8.0/debian/changelog	2007-08-31 07:51:08 UTC (rev 3040)
+++ branches/drbd-8.0/debian/changelog	2007-08-31 11:10:40 UTC (rev 3041)
@@ -1,3 +1,9 @@
+drbd8 (8.0.6-0) unstable; urgency=low
+
+  * New upstream release.
+
+ -- Philipp Reisner <phil@linbit.com>  Fri, 3 Sep 2007 10:00:00 +0200
+
 drbd8 (8.0.5-0) unstable; urgency=low
 
   * New upstream release.

Modified: branches/drbd-8.0/drbd/linux/drbd_config.h
===================================================================
--- branches/drbd-8.0/drbd/linux/drbd_config.h	2007-08-31 07:51:08 UTC (rev 3040)
+++ branches/drbd-8.0/drbd/linux/drbd_config.h	2007-08-31 11:10:40 UTC (rev 3041)
@@ -22,7 +22,7 @@
 
 extern const char * drbd_buildtag(void);
 
-#define REL_VERSION "8.0.5"
+#define REL_VERSION "8.0.6"
 #define API_VERSION 86
 #define PRO_VERSION 86
 

Modified: branches/drbd-8.0/drbd.spec.in
===================================================================
--- branches/drbd-8.0/drbd.spec.in	2007-08-31 07:51:08 UTC (rev 3040)
+++ branches/drbd-8.0/drbd.spec.in	2007-08-31 11:10:40 UTC (rev 3041)
@@ -192,6 +192,22 @@
 /sbin/depmod -a -F /boot/System.map-%{kernelversion} %{kernelversion} >/dev/null 2>&1 || true
 
 %changelog
+* Fri Seg  3 2007 10:00:00 +0200 Philipp Reisner <phil@linbit.com>
+- drbd (8.0.6-1)
+ * Fixed DRBD to not deadlock while doing bitmap updates on Linux
+   2.6.22 and later.
+ * Make it compile on Linux-2.6.22 and later.
+ * Removed a hardcoded path to docbook DTDs from our sgml files,
+   maybe improving the situation with building the documentation.
+ * drbdmeta can now also initialize meta data on meta devices
+   smaller than 128MB.
+ * Added an explicit NULL argument to our ioctl() calls in drbdmeta.
+ * Added scripts/block-drbd, which is a nice way hand over DRBD
+   role assignment to Xen, allowing one to do Xen live migrations
+   in a sane way.
+ * Added an option to drbd.conf which instructs the init script
+   to promote DRBD devices to primary role upon machine start up.
+
 * Fri Aug  3 2007 09:34:49 +0200 Philipp Reisner <phil@linbit.com>
 - drbd (8.0.5-1)
  * Changed the default behaviour of the init script. Now the init

From drbd-cvs at lists.linbit.com  Fri Aug 31 14:33:55 2007
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Fri Aug 31 14:33:57 2007
Subject: [DRBD-cvs] svn commit by florian - r3042 -
	branches/drbd-8.0/scripts - Updated comments. 
Message-ID: <20070831123355.7CC192C05A@garcon2.linbit.com>

Author: florian
Date: 2007-08-31 14:33:54 +0200 (Fri, 31 Aug 2007)
New Revision: 3042

Modified:
   branches/drbd-8.0/scripts/block-drbd
Log:
Updated comments.


Modified: branches/drbd-8.0/scripts/block-drbd
===================================================================
--- branches/drbd-8.0/scripts/block-drbd	2007-08-31 11:10:40 UTC (rev 3041)
+++ branches/drbd-8.0/scripts/block-drbd	2007-08-31 12:33:54 UTC (rev 3042)
@@ -34,8 +34,7 @@
 #   made available read-only to multiple domU's, or be mounted
 #   read-only in the dom0 and be made available read-only to
 #   domU's. This is not supported by the 'drbd' VBD type.
-# - Tested only on Debian etch with Xen 3.0.3, and on SLES 10 SP1 with
-#   Xen 3.0.4. 
+# - Tested, thus far, only on Debian etch with Xen 3.0.3.
 #
 # For more information about DRBD, visit http://www.drbd.org/.
 #   

From drbd-cvs at lists.linbit.com  Fri Aug 31 23:24:41 2007
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Fri Aug 31 23:24:42 2007
Subject: [DRBD-cvs] svn commit by phil - r3043 - in branches/drbd-8.0/drbd:
	. linux - When you let DRBD connect to an listening TCP port and 
Message-ID: <20070831212441.3C41E2C05A@garcon2.linbit.com>

Author: phil
Date: 2007-08-31 23:24:39 +0200 (Fri, 31 Aug 2007)
New Revision: 3043

Modified:
   branches/drbd-8.0/drbd/drbd_main.c
   branches/drbd-8.0/drbd/drbd_receiver.c
   branches/drbd-8.0/drbd/drbd_strings.c
   branches/drbd-8.0/drbd/linux/drbd.h
Log:
When you let DRBD connect to an listening TCP port and close
that, then allowing it to connect a second time you trigger
an workaround from the DRBD-0.7 days. It is printed to the
syslog as "My msock connect got accepted onto peer's sock!".
The the receiver sleeps for connect_int/2.

When you droped the network config during this time with
"drbdadm disconnect", you hit an OOPS.

The root of this bug was the the

if(drbd_request_state(mdev,NS(conn,WFConnection)) < SS_Success ) ...

statement in drbd_connect() elevated the connection state from
StandAlone to WFConnection. Later we dereference mdev->net_conf
and OOPS...

I fixed this by allowing that state change only when the connection
state before was >= Unconnected (I.e. we had a network config).


Modified: branches/drbd-8.0/drbd/drbd_main.c
===================================================================
--- branches/drbd-8.0/drbd/drbd_main.c	2007-08-31 12:33:54 UTC (rev 3042)
+++ branches/drbd-8.0/drbd/drbd_main.c	2007-08-31 21:24:39 UTC (rev 3043)
@@ -595,6 +595,9 @@
 	if( ns.disk > Attaching && os.disk == Diskless)
 		rv=SS_IsDiskLess;
 
+	if ( ns.conn == WFConnection && os.conn < Unconnected )
+		rv=SS_NoNetConfig;
+
 	return rv;
 }
 

Modified: branches/drbd-8.0/drbd/drbd_receiver.c
===================================================================
--- branches/drbd-8.0/drbd/drbd_receiver.c	2007-08-31 12:33:54 UTC (rev 3042)
+++ branches/drbd-8.0/drbd/drbd_receiver.c	2007-08-31 21:24:39 UTC (rev 3043)
@@ -706,16 +706,18 @@
  *   0 oops, did not work out, please try again
  *  -1 peer talks different language,
  *     no point in trying again, please go standalone.
+ *  -2 We do not have a network config...
  */
 int drbd_connect(drbd_dev *mdev)
 {
 	struct socket *s, *sock,*msock;
 	int try,h;
 
-	D_ASSERT(mdev->state.conn >= Unconnected);
 	D_ASSERT(!mdev->data.socket);
 
-	if(drbd_request_state(mdev,NS(conn,WFConnection)) < SS_Success ) return 0;
+	if (_drbd_request_state(mdev,NS(conn,WFConnection),0) < SS_Success )
+		return -2;
+
 	clear_bit(DISCARD_CONCURRENT, &mdev->flags);
 
 	sock  = NULL;
@@ -2688,6 +2690,7 @@
 	int rv=SS_UnknownError;
 
 	D_ASSERT(mdev->state.conn < Connected);
+	if (mdev->state.conn == StandAlone) return;
 	/* FIXME verify that:
 	 * the state change magic prevents us from becoming >= Connected again
 	 * while we are still cleaning up.
@@ -3102,7 +3105,7 @@
 			drbd_disconnect(mdev);
 			schedule_timeout(HZ);
 		}
-		if( h < 0 ) {
+		if( h == -1 ) {
 			WARN("Discarding network configuration.\n");
 			drbd_force_state(mdev,NS(conn,Disconnecting));
 		}

Modified: branches/drbd-8.0/drbd/drbd_strings.c
===================================================================
--- branches/drbd-8.0/drbd/drbd_strings.c	2007-08-31 12:33:54 UTC (rev 3042)
+++ branches/drbd-8.0/drbd/drbd_strings.c	2007-08-31 21:24:39 UTC (rev 3043)
@@ -80,7 +80,8 @@
 	[-SS_CW_FailedByPeer] = "State changed was refused by peer node",
 	[-SS_IsDiskLess] = 
 		"Device is diskless, the requesed operation requires a disk",
-	[-SS_DeviceInUse] = "Device is held open by someone"
+	[-SS_DeviceInUse] = "Device is held open by someone",
+	[-SS_NoNetConfig] = "Have no net/connection configuration"
 };
 
 const char* conns_to_name(drbd_conns_t s) {
@@ -100,7 +101,7 @@
 }
 
 const char* set_st_err_name(set_st_err_t err) {
-	return err < SS_DeviceInUse ? "TOO_SMALL" :
+	return err < SS_NoNetConfig ? "TOO_SMALL" :
 	       err > SS_TwoPrimaries ? "TOO_LARGE"
 		        : drbd_state_sw_errors[-err];
 }

Modified: branches/drbd-8.0/drbd/linux/drbd.h
===================================================================
--- branches/drbd-8.0/drbd/linux/drbd.h	2007-08-31 12:33:54 UTC (rev 3042)
+++ branches/drbd-8.0/drbd/linux/drbd.h	2007-08-31 21:24:39 UTC (rev 3043)
@@ -207,7 +207,8 @@
 	SS_AlreadyStandAlone=-9,
 	SS_CW_FailedByPeer=-10,
 	SS_IsDiskLess=-11,
-	SS_DeviceInUse=-12
+	SS_DeviceInUse=-12,
+	SS_NoNetConfig=-13
 } set_st_err_t;
 
 /* from drbd_strings.c */

