[DRBD-cvs] svn commit by lars - r3064 - in branches/drbd-8.1: . debian documentation drbd drbd/linux scripts user - svnp run. Investigated 3035 to 3063 r3037 by phil on 20

drbd-cvs at lists.linbit.com drbd-cvs at lists.linbit.com
Wed Sep 19 18:50:34 CEST 2007


Author: lars
Date: 2007-09-19 18:50:30 +0200 (Wed, 19 Sep 2007)
New Revision: 3064

Added:
   branches/drbd-8.1/scripts/block-drbd
   branches/drbd-8.1/scripts/pretty-proc-drbd.sh
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/drbd.sgml
   branches/drbd-8.1/documentation/drbdadm.sgml
   branches/drbd-8.1/documentation/drbddisk.sgml
   branches/drbd-8.1/documentation/drbdmeta.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_receiver.c
   branches/drbd-8.1/drbd/drbd_strings.c
   branches/drbd-8.1/drbd/linux/drbd.h
   branches/drbd-8.1/scripts/Makefile
   branches/drbd-8.1/scripts/drbd
   branches/drbd-8.1/scripts/drbd.conf
   branches/drbd-8.1/user/drbdadm_main.c
   branches/drbd-8.1/user/drbdadm_scanner.fl
Log:
svnp run. Investigated 3035 to 3063

r3037 by phil on 2007-08-30 21:45:14 +0200 (Thu, 30 Aug 2007) 
  Changed paths:
     M /branches/drbd-8.0/documentation/drbd.conf.sgml
     M /branches/drbd-8.0/documentation/drbd.sgml
     M /branches/drbd-8.0/documentation/drbdadm.sgml
     M /branches/drbd-8.0/documentation/drbddisk.sgml
     M /branches/drbd-8.0/documentation/drbdmeta.sgml
     M /branches/drbd-8.0/documentation/drbdsetup.sgml
     M /branches/drbd-8.0/scripts/drbd
     M /branches/drbd-8.0/scripts/drbd.conf
     M /branches/drbd-8.0/user/drbdadm_main.c
     M /branches/drbd-8.0/user/drbdadm_scanner.fl
  
  Implemented the "become-primary-on" option for the startup section.
  

r3038 by phil on 2007-08-30 22:17:24 +0200 (Thu, 30 Aug 2007) 
  Changed paths:
     M /branches/drbd-8.0/drbd.spec.in
     M /branches/drbd-8.0/scripts/Makefile
     A /branches/drbd-8.0/scripts/block-drbd
  
  Florian's nice Xen-DRBD script.
  

r3039 by florian on 2007-08-31 09:41:41 +0200 (Fri, 31 Aug 2007) 
  Changed paths:
     M /branches/drbd-8.0/scripts/block-drbd
  
  Added extensive comments. Sanitized device sharing check for DRBD.
  

r3040 by florian on 2007-08-31 09:51:08 +0200 (Fri, 31 Aug 2007) 
  Changed paths:
     M /branches/drbd-8.0/scripts/block-drbd
  
  M-x untabify
  

r3041 by phil on 2007-08-31 13:10:40 +0200 (Fri, 31 Aug 2007) 
  Changed paths:
     M /branches/drbd-8.0/ChangeLog
     M /branches/drbd-8.0/debian/changelog
     M /branches/drbd-8.0/drbd/linux/drbd_config.h
     M /branches/drbd-8.0/drbd.spec.in
  
  Preparing 8.0.6 for release on Monday
  

r3042 by florian on 2007-08-31 14:33:54 +0200 (Fri, 31 Aug 2007) 
  Changed paths:
     M /branches/drbd-8.0/scripts/block-drbd
  
  Updated comments.
  

r3043 by phil on 2007-08-31 23:24:39 +0200 (Fri, 31 Aug 2007) 
  Changed paths:
     M /branches/drbd-8.0/drbd/drbd_main.c
     M /branches/drbd-8.0/drbd/drbd_receiver.c
     M /branches/drbd-8.0/drbd/drbd_strings.c
     M /branches/drbd-8.0/drbd/linux/drbd.h
  
  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).
  

r3044 by phil on 2007-09-01 08:47:22 +0200 (Sat, 01 Sep 2007) 
  Changed paths:
     M /branches/drbd-8.0/drbd/drbd_receiver.c
  
  Fixed possible socket leakage.
  

r3046 by lars on 2007-09-01 23:39:01 +0200 (Sat, 01 Sep 2007) 
  Changed paths:
     A /branches/drbd-8.0/scripts/pretty-proc-drbd.sh
  
  pretty print /proc/drbd
  output defaults to one line per resource, prepends resource name
   -c add color
   -v adds all the details back in
  have fun
  

r3047 by phil on 2007-09-03 10:28:49 +0200 (Mon, 03 Sep 2007) 
  Changed paths:
     M /branches/drbd-8.0/ChangeLog
     M /branches/drbd-8.0/drbd.spec.in
  
  Last changes to ChangeLog.
  

r3048 by phil on 2007-09-03 10:33:37 +0200 (Mon, 03 Sep 2007) 
  Changed paths:
     M /branches/drbd-8.0/debian/changelog
     M /branches/drbd-8.0/drbd.spec.in
  
  Fixing stupid typo bugs in changelogs
  

r3050 by phil on 2007-09-04 15:46:40 +0200 (Tue, 04 Sep 2007) 
  Changed paths:
     M /branches/drbd-8.0/drbd/drbd_receiver.c
  
  Removed a workaround from the 0.7 time, that hinders us now 
  while developing drbd-proxy.
  

r3054 by phil on 2007-09-06 17:25:55 +0200 (Thu, 06 Sep 2007) 
  Changed paths:
     M /branches/drbd-8.0/drbd/drbd_compat_wrappers.h
  
  [Do not propagate]
  
  crypto_alloc_hash() has to use the ERR_PTR() macros for reporting
  errors.
  

r3056 by phil on 2007-09-06 17:47:39 +0200 (Thu, 06 Sep 2007) 
  Changed paths:
     M /branches/drbd-8.0/drbd/drbd_compat_wrappers.h
  
  Thanks Simon!
  

r3063 by lars on 2007-09-19 17:48:47 +0200 (Wed, 19 Sep 2007) 
  Changed paths:
     M /branches/drbd-8.0/user/drbdadm_main.c
  
  would you please initialize an array before iterating over it?



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

Modified: branches/drbd-8.1/ChangeLog
===================================================================
--- branches/drbd-8.1/ChangeLog	2007-09-19 15:48:47 UTC (rev 3063)
+++ branches/drbd-8.1/ChangeLog	2007-09-19 16:50:30 UTC (rev 3064)
@@ -20,6 +20,27 @@
 Changelog for fixes propagated from 8.0.x:
 ------------------------------------------
 
+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.
+ * When a drbd connect attempt gets accepted onto a other program,
+   that simply closes the socket, drbd stays for some seconds in the
+   "BrokenPipe" network state. When one removed the network
+   config during that time, drbd OOPSed. This is fixed now.
+ * 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 scripts/pretty-proc-drbd.sh
+ * 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.1/debian/changelog
===================================================================
--- branches/drbd-8.1/debian/changelog	2007-09-19 15:48:47 UTC (rev 3063)
+++ branches/drbd-8.1/debian/changelog	2007-09-19 16:50:30 UTC (rev 3064)
@@ -1,3 +1,9 @@
+drbd8 (8.0.6-0) unstable; urgency=low
+
+  * New upstream release.
+
+ -- Philipp Reisner <phil at linbit.com>  Mon, 3 Sep 2007 10:00:00 +0200
+
 drbd8 (8.0.5-0) unstable; urgency=low
 
   * New upstream release.

Modified: branches/drbd-8.1/documentation/drbd.conf.sgml
===================================================================
--- branches/drbd-8.1/documentation/drbd.conf.sgml	2007-09-19 15:48:47 UTC (rev 3063)
+++ branches/drbd-8.1/documentation/drbd.conf.sgml	2007-09-19 16:50:30 UTC (rev 3064)
@@ -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.1/documentation/drbd.sgml
===================================================================
--- branches/drbd-8.1/documentation/drbd.sgml	2007-09-19 15:48:47 UTC (rev 3063)
+++ branches/drbd-8.1/documentation/drbd.sgml	2007-09-19 16:50:30 UTC (rev 3064)
@@ -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.1/documentation/drbdadm.sgml
===================================================================
--- branches/drbd-8.1/documentation/drbdadm.sgml	2007-09-19 15:48:47 UTC (rev 3063)
+++ branches/drbd-8.1/documentation/drbdadm.sgml	2007-09-19 16:50:30 UTC (rev 3064)
@@ -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.1/documentation/drbddisk.sgml
===================================================================
--- branches/drbd-8.1/documentation/drbddisk.sgml	2007-09-19 15:48:47 UTC (rev 3063)
+++ branches/drbd-8.1/documentation/drbddisk.sgml	2007-09-19 16:50:30 UTC (rev 3064)
@@ -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.1/documentation/drbdmeta.sgml
===================================================================
--- branches/drbd-8.1/documentation/drbdmeta.sgml	2007-09-19 15:48:47 UTC (rev 3063)
+++ branches/drbd-8.1/documentation/drbdmeta.sgml	2007-09-19 16:50:30 UTC (rev 3064)
@@ -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.1/documentation/drbdsetup.sgml
===================================================================
--- branches/drbd-8.1/documentation/drbdsetup.sgml	2007-09-19 15:48:47 UTC (rev 3063)
+++ branches/drbd-8.1/documentation/drbdsetup.sgml	2007-09-19 16:50:30 UTC (rev 3064)
@@ -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.1/drbd/drbd_main.c
===================================================================
--- branches/drbd-8.1/drbd/drbd_main.c	2007-09-19 15:48:47 UTC (rev 3063)
+++ branches/drbd-8.1/drbd/drbd_main.c	2007-09-19 16:50:30 UTC (rev 3064)
@@ -610,6 +610,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.1/drbd/drbd_receiver.c
===================================================================
--- branches/drbd-8.1/drbd/drbd_receiver.c	2007-09-19 15:48:47 UTC (rev 3063)
+++ branches/drbd-8.1/drbd/drbd_receiver.c	2007-09-19 16:50:30 UTC (rev 3064)
@@ -554,14 +554,15 @@
 	struct socket *sock;
 	struct sockaddr_in src_in;
 
+	if (!inc_net(mdev)) return NULL;
+
 	err = sock_create_kern(AF_INET, SOCK_STREAM, IPPROTO_TCP, &sock);
 	if (err) {
+		dec_net(mdev);
 		ERR("sock_creat(..)=%d\n", err);
 		return NULL;
 	}
 
-	if (!inc_net(mdev)) return NULL;
-
 	sock->sk->sk_rcvtimeo =
 	sock->sk->sk_sndtimeo =  mdev->net_conf->try_connect_int*HZ;
 
@@ -604,14 +605,15 @@
 	int err;
 	struct socket *sock, *sock2;
 
+	if (!inc_net(mdev)) return NULL;
+
 	err = sock_create_kern(AF_INET, SOCK_STREAM, IPPROTO_TCP, &sock2);
 	if (err) {
+		dec_net(mdev);
 		ERR("sock_creat(..)=%d\n", err);
 		return NULL;
 	}
 
-	if (!inc_net(mdev)) return NULL;
-
 	sock2->sk->sk_reuse    = 1; /* SO_REUSEADDR */
 	sock2->sk->sk_rcvtimeo =
 	sock2->sk->sk_sndtimeo =  mdev->net_conf->try_connect_int*HZ;
@@ -664,17 +666,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(struct drbd_conf *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;
@@ -2613,6 +2616,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.
@@ -2789,11 +2793,11 @@
 
 	rv = drbd_send_handshake(mdev);
 	if (!rv)
-		goto break_c_loop;
+		return 0;
 
 	rv = drbd_recv_header(mdev, &p->head);
 	if (!rv)
-		goto break_c_loop;
+		return 0;
 
 	if (p->head.command != HandShake) {
 		ERR( "expected HandShake packet, received: %s (0x%04x)\n",
@@ -2841,23 +2845,6 @@
 	}
 
 	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
-	   connect-int, we might get into the situation that this
-	   node's msock gets connected to the peer's sock!
-
-	   To break out of this endless loop behaviour, we need to
-	   wait unti the peer's msock connect tries are over. (1 Second)
-
-	   Additionally we wait connect-int/2 to hit with our next
-	   connect try exactly in the peer's window of expectation. */
-
-	set_current_state(TASK_INTERRUPTIBLE);
-	schedule_timeout(HZ + (mdev->net_conf->try_connect_int*HZ)/2);
-
-	return 0;
 }
 
 #if !defined(CONFIG_CRYPTO_HMAC) && !defined(CONFIG_CRYPTO_HMAC_MODULE)
@@ -3028,7 +3015,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.1/drbd/drbd_strings.c
===================================================================
--- branches/drbd-8.1/drbd/drbd_strings.c	2007-09-19 15:48:47 UTC (rev 3063)
+++ branches/drbd-8.1/drbd/drbd_strings.c	2007-09-19 16:50:30 UTC (rev 3064)
@@ -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(enum drbd_conns s)
@@ -101,7 +102,7 @@
 
 const char *set_st_err_name(enum set_st_err 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.1/drbd/linux/drbd.h
===================================================================
--- branches/drbd-8.1/drbd/linux/drbd.h	2007-09-19 15:48:47 UTC (rev 3063)
+++ branches/drbd-8.1/drbd/linux/drbd.h	2007-09-19 16:50:30 UTC (rev 3064)
@@ -218,7 +218,8 @@
 	SS_AlreadyStandAlone = -9,
 	SS_CW_FailedByPeer = -10,
 	SS_IsDiskLess = -11,
-	SS_DeviceInUse = -12
+	SS_DeviceInUse = -12,
+	SS_NoNetConfig = -13
 };
 
 /* from drbd_strings.c */

Modified: branches/drbd-8.1/drbd.spec.in
===================================================================
--- branches/drbd-8.1/drbd.spec.in	2007-09-19 15:48:47 UTC (rev 3063)
+++ branches/drbd-8.1/drbd.spec.in	2007-09-19 16:50:30 UTC (rev 3064)
@@ -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
@@ -191,6 +192,27 @@
 /sbin/depmod -a -F /boot/System.map-%{kernelversion} %{kernelversion} >/dev/null 2>&1 || true
 
 %changelog
+* Mon Sep  3 2007 10:00:00 +0200 Philipp Reisner <phil at 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.
+ * When a drbd connect attempt gets accepted onto a other program,
+   that simply closes the socket, drbd stays for some seconds in the
+   "BrokenPipe" network state. When one removed the network
+   config during that time, drbd OOPSed. This is fixed now.
+ * 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 scripts/pretty-proc-drbd.sh
+ * 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 at linbit.com>
 - drbd (8.0.5-1)
  * Changed the default behaviour of the init script. Now the init

Modified: branches/drbd-8.1/scripts/Makefile
===================================================================
--- branches/drbd-8.1/scripts/Makefile	2007-09-19 15:48:47 UTC (rev 3063)
+++ branches/drbd-8.1/scripts/Makefile	2007-09-19 16:50:30 UTC (rev 3064)
@@ -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

Copied: branches/drbd-8.1/scripts/block-drbd (from rev 3038, 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.1/scripts/block-drbd	2007-09-19 16:50:30 UTC (rev 3064)
@@ -0,0 +1,298 @@
+#!/bin/bash
+#
+# Copyright (c) 2007 LINBIT Information Technologies GmbH
+# Based on the original "block" VBD script by XenSource Inc.
+#
+# 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:
+#
+# disk = [ 'drbd:myresource,xvda1,w' ]
+#
+# 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. 
+#
+# 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, thus far, only on Debian etch with Xen 3.0.3.
+#
+# 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"
+
+##
+# 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
+
+  # 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
+    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
+        # 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
+          echo 'guest'
+          return
+        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

Modified: branches/drbd-8.1/scripts/drbd
===================================================================
--- branches/drbd-8.1/scripts/drbd	2007-09-19 15:48:47 UTC (rev 3063)
+++ branches/drbd-8.1/scripts/drbd	2007-09-19 16:50:30 UTC (rev 3064)
@@ -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.1/scripts/drbd.conf
===================================================================
--- branches/drbd-8.1/scripts/drbd.conf	2007-09-19 15:48:47 UTC (rev 3063)
+++ branches/drbd-8.1/scripts/drbd.conf	2007-09-19 16:50:30 UTC (rev 3064)
@@ -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 {

Copied: branches/drbd-8.1/scripts/pretty-proc-drbd.sh (from rev 3046, branches/drbd-8.0/scripts/pretty-proc-drbd.sh)

Modified: branches/drbd-8.1/user/drbdadm_main.c
===================================================================
--- branches/drbd-8.1/user/drbdadm_main.c	2007-09-19 15:48:47 UTC (rev 3063)
+++ branches/drbd-8.1/user/drbdadm_main.c	2007-09-19 16:50:30 UTC (rev 3064)
@@ -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);
@@ -1196,6 +1222,9 @@
   sigaction(SIGCHLD,&sa,&so);
 
   pids = alloca( nr_resources * sizeof(pid_t) );
+  /* alloca can not fail, it can "only" overflow the stack :)
+   * but it needs to be initialized anyways! */
+  memset(pids,0,nr_resources * sizeof(pid_t));
 
   for_each_resource(res,t,config) {
     argc=0;
@@ -1203,7 +1232,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 +1580,7 @@
 void validate_resource(struct d_resource * res)
 {
   struct d_option* opt;
+  char *bpo;
 
   if (!res->protocol) {
     if (!common || !common->protocol) {
@@ -1607,6 +1637,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.1/user/drbdadm_scanner.fl
===================================================================
--- branches/drbd-8.1/user/drbdadm_scanner.fl	2007-09-19 15:48:47 UTC (rev 3063)
+++ branches/drbd-8.1/user/drbdadm_scanner.fl	2007-09-19 16:50:30 UTC (rev 3064)
@@ -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;	}



More information about the drbd-cvs mailing list