From drbd-cvs at lists.linbit.com  Tue Apr  4 16:11:15 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Tue Apr  4 16:11:20 2006
Subject: [DRBD-cvs] svn commit by phil - r2130 - in trunk: . scripts user -
	Made drbdmeta to destroy any v07 superblocks when a v08
Message-ID: <20060404141115.4028115CD2@mail.linbit.com>

Author: phil
Date: 2006-04-04 16:11:13 +0200 (Tue, 04 Apr 2006)
New Revision: 2130

Modified:
   trunk/ROADMAP
   trunk/scripts/drbd.conf
   trunk/user/drbdmeta.c
Log:
Made drbdmeta to destroy any v07 superblocks when a v08 meta
data area is initialized.
When using internal meta data the superblocks of v07 and v08 are
in different locations.



Modified: trunk/ROADMAP
===================================================================
--- trunk/ROADMAP	2006-03-31 13:12:56 UTC (rev 2129)
+++ trunk/ROADMAP	2006-04-04 14:11:13 UTC (rev 2130)
@@ -687,14 +687,20 @@
 31 Resizing several GB results in ko-count timeouts, maybe since the
    secondary node does the enlargement of the bitmap in the receiver (?)
 
+   DONE, by using the async bitmap IO code.
+
 32 drbdmeta: with internal meta-data v07 and v08 meta-data super blocks
    are in different places. -> It is possible to have v07 AND v08 meta
    data on one device. 
    => drbdmeta should make sure that it overwrites the other location
       in case it create a meta-data block.
 
-33? Online verification.
+   99% DONE
 
+33 Save the minor number and the backing device in the (external) meta
+   data as sanity check.
+
+
 plus-banches:
 ----------------------
 

Modified: trunk/scripts/drbd.conf
===================================================================
--- trunk/scripts/drbd.conf	2006-03-31 13:12:56 UTC (rev 2129)
+++ trunk/scripts/drbd.conf	2006-04-04 14:11:13 UTC (rev 2130)
@@ -275,7 +275,7 @@
     #                     the current secondary's data. Otherwise disconnect.
     #    "discard-secondary"     
     #                     discard the version of the secondary.
-    #    "panic-primary"  Always honour the outcome of the "after-sb-2sc"
+    #    "panic-primary"  Always honour the outcome of the "after-sb-0pri"
     #                     algorithm. In case it decides the the current
     #                     secondary has the right data, it panics the
     #                     current primary.

Modified: trunk/user/drbdmeta.c
===================================================================
--- trunk/user/drbdmeta.c	2006-03-31 13:12:56 UTC (rev 2129)
+++ trunk/user/drbdmeta.c	2006-04-04 14:11:13 UTC (rev 2130)
@@ -306,9 +306,9 @@
 	int (*open) (struct format *);
 	int (*close) (struct format *);
 	int (*md_initialize) (struct format *);
-	int (*md_get_byte_offset) (struct format *);
 	int (*md_disk_to_cpu) (struct format *);
 	int (*md_cpu_to_disk) (struct format *);
+	void (*md_erase_other_sbs) (struct format *);
 	void (*get_gi) (struct md_cpu *md);
 	void (*show_gi) (struct md_cpu *md);
 	void (*set_gi) (struct md_cpu *md, char **argv, int argc);
@@ -660,6 +660,7 @@
 int v06_parse(struct format *cfg, char **argv, int argc, int *ai);
 int v06_md_open(struct format *cfg);
 int v06_md_initialize(struct format *cfg);
+void v06_md_erase_others(struct format *cfg);
 
 int v07_md_close(struct format *cfg);
 int v07_md_cpu_to_disk(struct format *cfg);
@@ -667,13 +668,15 @@
 int v07_md_open(struct format *cfg);
 int v07_parse(struct format *cfg, char **argv, int argc, int *ai);
 int v07_md_initialize(struct format *cfg);
-int v07_md_get_byte_offset(struct format * cfg);
+void v07_md_erase_others(struct format *cfg);
+u64 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);
-int v08_md_get_byte_offset(struct format * cfg);
+void v08_md_erase_others(struct format *cfg);
+u64 v08_md_get_byte_offset(struct format * cfg);
 
 struct format_ops f_ops[] = {
 	[Drbd_06] = {
@@ -683,9 +686,9 @@
 		     .open = v06_md_open,
 		     .close = v06_md_close,
 		     .md_initialize = v06_md_initialize,
-		     .md_get_byte_offset = NULL, /* unused */
 		     .md_disk_to_cpu = v06_md_disk_to_cpu,
 		     .md_cpu_to_disk = v06_md_cpu_to_disk,
+		     .md_erase_other_sbs = v06_md_erase_others,
 		     .get_gi = m_get_gc,
 		     .show_gi = m_show_gc,
 		     .set_gi = m_set_gc,
@@ -698,9 +701,9 @@
 		     .open = v07_md_open,
 		     .close = v07_md_close,
 		     .md_initialize = v07_md_initialize,
-		     .md_get_byte_offset = v07_md_get_byte_offset,
 		     .md_disk_to_cpu = v07_md_disk_to_cpu,
 		     .md_cpu_to_disk = v07_md_cpu_to_disk,
+		     .md_erase_other_sbs = v07_md_erase_others,
 		     .get_gi = m_get_gc,
 		     .show_gi = m_show_gc,
 		     .set_gi = m_set_gc,
@@ -713,9 +716,9 @@
 		     .open = v08_md_open,
 		     .close = v07_md_close,
 		     .md_initialize = v08_md_initialize,
-		     .md_get_byte_offset = v08_md_get_byte_offset,
 		     .md_disk_to_cpu = v08_md_disk_to_cpu,
 		     .md_cpu_to_disk = v08_md_cpu_to_disk,
+		     .md_erase_other_sbs = v08_md_erase_others,
 		     .get_gi = m_get_uuid,
 		     .show_gi = m_show_uuid,
 		     .set_gi = m_set_uuid,
@@ -769,9 +772,6 @@
 	{"dump-md", 0, meta_dump_md, 1},
 	{"restore-md", "file", meta_restore_md, 1},
 	{"create-md", 0, meta_create_md, 1},
-	/* FIXME convert still missing.
-	 * implicit convert from v07 to v08 by create-md
-	 * see comments there */
 	{"outdate", 0, meta_outdate, 1},
 	{"dstate", 0, meta_dstate, 1},
 	{"read-dev-uuid", "VAL",  meta_read_dev_uuid,  0},
@@ -848,7 +848,9 @@
 	printf("\n}\n");
 }
 
-int v07_style_md_open(struct format *cfg, size_t size)
+int v07_style_md_open(struct format *cfg,
+		      u64 (*md_get_byte_offset) (struct format *),
+		      size_t size)
 {
 	struct stat sb;
 	unsigned long words;
@@ -875,7 +877,7 @@
 		PERROR("WARN: ioctl(,BLKFLSBUF,) failed");
 	}
 
-	(void) cfg->ops->md_get_byte_offset(cfg);
+	cfg->md_offset = md_get_byte_offset(cfg);
 	// fprintf(stderr,"offset: "U64"\n", cfg->md_offset);
 
 	cfg->md_mmaped_length = size;
@@ -924,6 +926,39 @@
 	return 0;
 }
 
+void md_erase_sb(struct format *cfg,
+		 u64 (*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
+	   of the meta data area. */
+
+	unsigned char zero_sector[512];
+	struct format cfg_f;
+	u64 offset;
+	int bw;
+	
+	if(cfg->md_index == DRBD_MD_INDEX_INTERNAL ||
+	   cfg->md_index == DRBD_MD_INDEX_FLEX_INT ) {
+		memset(zero_sector,0,512);
+		cfg_f = *cfg;
+		cfg_f.md_index = DRBD_MD_INDEX_INTERNAL;
+		/* Need to set it to INTERNAL, to hit the superblock
+		   in the front of the meta data area. */
+
+		offset = md_get_byte_offset(&cfg_f);
+		if(lseek64(cfg->md_fd, offset, SEEK_SET) == -1) {
+			PERROR("lseek64() failed");
+			exit(20);
+		}
+
+		if( (bw=write(cfg->md_fd,zero_sector,512)) != 512) {
+			PERROR("write() returned %d",bw);
+			exit(20);
+		}
+	}
+}
+
 void m_get_gc(struct md_cpu *md)
 {
 	dt_print_gc(md->gc);
@@ -1191,6 +1226,11 @@
 	return 0;
 }
 
+void v06_md_erase_others(struct format *cfg __attribute((unused)))
+{
+	/* nothing to do */
+}
+
 /******************************************
   }}} end of v06
  ******************************************/
@@ -1303,7 +1343,7 @@
  begin of v07 {{{
  ******************************************/
 
-int v07_md_get_byte_offset(struct format *cfg)
+u64 v07_md_get_byte_offset(struct format *cfg)
 {
 	u64 offset;
 
@@ -1325,8 +1365,8 @@
 		offset = 0;
 		break;
 	}
-	cfg->md_offset = offset;
-	return 0;
+
+	return offset;
 }
 
 int v07_md_disk_to_cpu(struct format *cfg)
@@ -1391,7 +1431,9 @@
 
 int v07_md_open(struct format *cfg)
 {
-	return v07_style_md_open(cfg, sizeof(struct md_on_disk_07));
+	return v07_style_md_open(cfg, 
+				 &v07_md_get_byte_offset,
+				 sizeof(struct md_on_disk_07));
 }
 
 int v07_md_close(struct format *cfg)
@@ -1430,6 +1472,11 @@
 	return md_initialize_common(cfg);
 }
 
+void v07_md_erase_others(struct format *cfg)
+{
+	md_erase_sb(cfg,&v08_md_get_byte_offset);
+}
+
 /******************************************
   }}} end of v07
  ******************************************/
@@ -1437,7 +1484,7 @@
  begin of v08 {{{
  ******************************************/
 
-int v08_md_get_byte_offset(struct format *cfg)
+u64 v08_md_get_byte_offset(struct format *cfg)
 {
 	u64 offset;
 
@@ -1456,8 +1503,8 @@
 		offset = 0;
 		break;
 	}
-	cfg->md_offset = offset;
-	return 0;
+
+	return offset;
 }
 
 int v08_md_disk_to_cpu(struct format *cfg)
@@ -1487,7 +1534,9 @@
 
 int v08_md_open(struct format *cfg)
 {
-	return v07_style_md_open(cfg, sizeof(struct md_on_disk_08));
+	return v07_style_md_open(cfg, 
+				 &v08_md_get_byte_offset,
+				 sizeof(struct md_on_disk_08));
 }
 
 int v08_md_initialize(struct format *cfg)
@@ -1506,6 +1555,11 @@
 	return md_initialize_common(cfg);
 }
 
+void v08_md_erase_others(struct format *cfg)
+{
+	md_erase_sb(cfg,&v07_md_get_byte_offset);
+}
+
 /******************************************
   }}} end of v08
  ******************************************/
@@ -2036,6 +2090,7 @@
 		}
 	}
 
+	cfg->ops->md_erase_other_sbs(cfg);
 	printf("Creating meta data...\n");
 	MEMSET(&cfg->md, 0, sizeof(cfg->md));
 	err = cfg->ops->md_initialize(cfg);

From drbd-cvs at lists.linbit.com  Wed Apr  5 12:17:58 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Wed Apr  5 12:17:59 2006
Subject: [DRBD-cvs] svn commit by phil - r2131 - in trunk: . scripts - A big
	updated in the way should deal with resource and 
Message-ID: <20060405101758.CC0CE16229@mail.linbit.com>

Author: phil
Date: 2006-04-05 12:17:57 +0200 (Wed, 05 Apr 2006)
New Revision: 2131

Modified:
   trunk/ROADMAP
   trunk/scripts/drbd.conf
Log:
A big updated in the way should deal with resource and node fencing
(stonith).



Modified: trunk/ROADMAP
===================================================================
--- trunk/ROADMAP	2006-04-04 14:11:13 UTC (rev 2130)
+++ trunk/ROADMAP	2006-04-05 10:17:57 UTC (rev 2131)
@@ -116,13 +116,13 @@
     In the other case it modifies the meta data directly by 
     calling drbdmeta.
 
-  remove option value: on-disconnect=suspend_io
+  remove option: on-disconnect
 
   New meta-data flag: "Outdated"
 
   introduce:
   disk {
-    split-brain-fix;
+    fencing [ dont-care | resource-only | resource-and-stonith ];
   }
 
   handlers {
@@ -133,10 +133,11 @@
   handler (yes a call to userspace from kernel space). The handler's
   returncodes are:
 
-  3 -> peer is inconsistent
-  4 -> peer is outdated (presumabely this handler outdated it)
+  3 -> peer is inconsistent 
+  4 -> peer is outdated (this handler outdated it) [ resource fencing ]
   5 -> peer was down / unreachable
   6 -> peer is primary
+  7 -> peer got stonithed [ node fencing ]
 
   Let us assume that we have two boxes (N1 and N2) and that these
   two boxes are connected by two networks (net and cnet [ clinets'-net ]).
@@ -144,15 +145,15 @@
   Net is used by DRBD, while heartbeat uses both, net and cnet
 
   I know that you are talking about fencing by STONITH, but DRBD is
-  not limited to that. Here comes my understanding of how fencing
-  (other than STONITH) should work with DRBD-0.8 :
+  not limited to that. Here comes my understanding of how resource fencing
+  should works with DRBDv8 :
 
    N1  net   N2
    P/S ---  S/P     everything up and running.
    P/? - -  S/?     network breaks ; N1 freezes IO
    P/? - -  S/?     N1 fences N2:
                     In the STONITH case: turn off N2.
-                    In the "smart" case: 
+                    In the resource fencing case: 
                     N1 asks N2 to fence itself from the storage via cnet.
                     HB calls "drbdadm outdate r0" on N2.
                     N2 replies to N1 that fencing is done via cnet.
@@ -162,15 +163,40 @@
   N2 got the the "Outdated" flag set in its meta-data, by the outdate 
   command. 
 
-  The "split-brain-fix" enables this behaviour. If this option is
-  omitted, the handler is not called nor IO is frozen on disconnect.
+  The fencing is set to resource-only enables this behaviour. In the 
+  resource-only case the outdate-peer handler should have a return
+  value of 3, 4, 5 or 6, but should not return 7.
 
-  Eventually introduce a "suspend" and a "resume" command to 
-  to reach the freezed state without the need to disconnect the peer. 
-  It might turn out to be usefull for other tasks as well.
+  In case "fencing" is set to "resource-and-stonith", all IO operations
+  get immediately frozen (even all currently outstanding IO operations
+  will not finish) upon loss of connection.
 
-  66% DONE / TODO: IO freezing is not done yet.
+  Then the "outdate-peer" handler is started. In this configuration
+  the outdate peer handler might return any of the documented return
+  values.
 
+  When the outdate-peer handler returns IO is resumed.
+
+  Notes: 
+  * Why do we need to freeze IO in the "resource-and-stonith" case:
+      Stonith protects you when all communication pathes fail. In
+      that case both (isolated) nodes try to stonith each other.
+      If the current primary would continue to allow IO it could
+      accept transactions, but could get stonithed by the 
+      currently secondary node. 
+      -> Therefore others could see commited transactions that
+         would be gone after the successfull stonith operation.
+
+  * The outedate peer handler also gets called if an unconnected
+    secondary wants to become primary.
+    In other words it only may become primary when it knows that
+    the peer is outdated/inconsistent.
+
+  * We need to store the fact that the peer is outdated/inconsistent
+    in the meta-data. To allow an stand allone primary to be rebooted.
+
+  50% DONE / TODO: IO freezing is not done yet.
+
 8 New command drbdmeta
 
   We move the read_gc.pl/write_gc.pl to the user directory. 
@@ -481,7 +507,7 @@
            NB: If they are needed, I think they can be implemented
                as special UUID values.
 
-  99% DONE. Kernel part is implemented, userlang parts are implemented,
+  99% DONE. Kernel part is implemented, userland parts are implemented,
 	    --humand and --timeout-expired are removed.
 	    Everything seems to work so far.
 

Modified: trunk/scripts/drbd.conf
===================================================================
--- trunk/scripts/drbd.conf	2006-04-04 14:11:13 UTC (rev 2130)
+++ trunk/scripts/drbd.conf	2006-04-05 10:17:57 UTC (rev 2131)
@@ -178,13 +178,20 @@
     #
     on-io-error   detach;
 
-    # Enables the use of the outdate-peer handler, as well as freezing
-    # of IO while we are primary and the peer's disk state is unknown.
-    #  The outdate-peer handler is used then to resove the situation
-    #  as quick as possible.
-    # BTW, becoming primary on a disconnected node may also trigger the
-    # execution of the outdate-peer handler.
-    # split-brain-fix;
+    # Controls the fencing policy, default is "dont-care". Before you
+    # set any policy you need to make sure that you have a working
+    # outdate-peer handler. Possible values are:
+    #  "dont-care"     -> Never call the outdate-peer handler. [ DEFAULT ]
+    #  "resource-only" -> Call the outdate-peer handler if we primary and
+    #			  loose the connection to the secondary. As well
+    #			  whenn a unconnected secondary wants to become
+    #			  primary.
+    #  "resource-and-stonith"
+    #                  -> Calls the outdate-peer handler and freezes local
+    #                     IO immediately after loss of connection. This is
+    #			  necessary if your heartbeat can STONITH the other
+    #                     node.
+    # fencing resource-only;
 
     # In case you only want to use a fraction of the available space
     # you might use the "size" option here.
@@ -220,13 +227,6 @@
     # considered dead, even if it still answers ping requests.
     # ko-count 4;
 
-    # if the connection to the peer is lost you have the choice of
-    #  "reconnect"   -> Try to reconnect (AKA WFConnection state)
-    #  "stand_alone" -> Do not reconnect (AKA StandAlone state)
-    #  "freeze_io"   -> Try to reconnect but freeze all IO until
-    #                   the connection is established again.
-    # on-disconnect reconnect;
-
     # If you want to use OCFS2/openGFS on top of DRBD enable
     # this optione, and only enable it if you are going to use
     # one of these filesystems. Do not enable it for ext2,

From drbd-cvs at lists.linbit.com  Wed Apr  5 20:01:14 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Wed Apr  5 20:01:15 2006
Subject: [DRBD-cvs] svn commit by phil - r2132 - in trunk: . drbd drbd/linux
	user - Implemented the IO freezing for "fencing = stonith" 
Message-ID: <20060405180114.4973D16191@mail.linbit.com>

Author: phil
Date: 2006-04-05 20:01:11 +0200 (Wed, 05 Apr 2006)
New Revision: 2132

Modified:
   trunk/ROADMAP
   trunk/drbd/drbd_fs.c
   trunk/drbd/drbd_int.h
   trunk/drbd/drbd_main.c
   trunk/drbd/drbd_receiver.c
   trunk/drbd/drbd_req.c
   trunk/drbd/linux/drbd.h
   trunk/user/drbdadm_scanner.fl
   trunk/user/drbdmeta.c
   trunk/user/drbdsetup.c
   trunk/user/drbdtool_common.c
Log:
Implemented the IO freezing for "fencing = stonith"



Modified: trunk/ROADMAP
===================================================================
--- trunk/ROADMAP	2006-04-05 10:17:57 UTC (rev 2131)
+++ trunk/ROADMAP	2006-04-05 18:01:11 UTC (rev 2132)
@@ -195,7 +195,9 @@
   * We need to store the fact that the peer is outdated/inconsistent
     in the meta-data. To allow an stand allone primary to be rebooted.
 
-  50% DONE / TODO: IO freezing is not done yet.
+  80% DONE
+       The only missing thing is a fallback mechanism to unfreeze
+       IO in case the script failed.
 
 8 New command drbdmeta
 

Modified: trunk/drbd/drbd_fs.c
===================================================================
--- trunk/drbd/drbd_fs.c	2006-04-05 10:17:57 UTC (rev 2131)
+++ trunk/drbd/drbd_fs.c	2006-04-05 18:01:11 UTC (rev 2132)
@@ -308,7 +308,8 @@
 	struct drbd_backing_dev* nbc; // new_backing_conf
 	struct inode *inode, *inode2;
 	struct lru_cache* resync_lru = NULL;
-	drbd_disks_t nds;
+	drbd_state_t ns,os;
+	int rv;
 
 	minor=(int)(mdev-drbd_conf);
 
@@ -436,6 +437,7 @@
 	nbc->md_index = new_conf.meta_index;
 	nbc->u_size = new_conf.disk_size;
 	nbc->on_io_error = new_conf.on_io_error;
+	nbc->fencing = new_conf.fencing;
 	drbd_md_set_sector_offsets(mdev,nbc);
 
 	retcode = drbd_md_read(mdev,nbc);
@@ -462,9 +464,6 @@
 	mdev->bc = nbc;
 	mdev->resync = resync_lru;
 
-	if (new_conf.split_brain_fix) set_bit(SPLIT_BRAIN_FIX,&mdev->flags);
-	else clear_bit(SPLIT_BRAIN_FIX,&mdev->flags);
-
 	mdev->send_cnt = 0;
 	mdev->recv_cnt = 0;
 	mdev->read_cnt = 0;
@@ -526,6 +525,9 @@
 		drbd_send_state(mdev);
 		drbd_thread_start(&mdev->worker);
 	} else {
+		spin_lock_irq(&mdev->req_lock);
+		os = mdev->state;
+		ns.i = os.i;
 		/* If MDF_Consistent is not set go into inconsistent state, 
 		   otherwise investige MDF_WasUpToDate...
 		   If MDF_WasUpToDate is not set go into Outdated disk state, 
@@ -533,20 +535,33 @@
 		*/
 		if(drbd_md_test_flag(mdev->bc,MDF_Consistent)) {
 			if(drbd_md_test_flag(mdev->bc,MDF_WasUpToDate)) {
-				nds = Consistent;
+				ns.disk = Consistent;
 			} else {
-				nds = Outdated;
+				ns.disk = Outdated;
 			}
 		} else {
-			nds = Inconsistent;
+			ns.disk = Inconsistent;
 		}
 
+		if(drbd_md_test_flag(mdev->bc,MDF_PeerOutDated)) {
+			ns.pdsk = Outdated;
+		}
+		
 		/* All tests on MDF_PrimaryInd, MDF_ConnectedInd, 
 		   MDF_Consistent and MDF_WasUpToDate must happen before 
 		   this point, because drbd_request_state() modifies these
 		   flags. */
-		if(drbd_request_state(mdev,NS(disk,nds)) >= SS_Success ) {
+
+		rv = _drbd_set_state(mdev, ns, ChgStateVerbose);
+		ns = mdev->state;
+		spin_unlock_irq(&mdev->req_lock);
+		after_state_ch(mdev,os,ns);
+
+		if(rv >= SS_Success ) {
 			drbd_thread_start(&mdev->worker);
+		} else {
+			drbd_bm_unlock(mdev);
+			goto  release_bdev3_fail_ioctl;
 		}
 	}
 
@@ -557,6 +572,7 @@
 
  release_bdev3_fail_ioctl:
 	drbd_force_state(mdev,NS(disk,Diskless));
+	drbd_md_sync(mdev);
  release_bdev2_fail_ioctl:
 	bd_release(nbc->md_bdev);
  release_bdev_fail_ioctl:
@@ -785,9 +801,16 @@
 {
 	int r;
 	drbd_disks_t nps;
+	enum fencing_policy fp;
 
 	D_ASSERT(mdev->state.pdsk == DUnknown);
 
+	fp = DontCare;
+	if(inc_local(mdev)) {
+		fp = mdev->bc->fencing;
+		dec_local(mdev);
+	}
+
 	r=drbd_khelper(mdev,"outdate-peer");
 
 	switch( (r>>8) & 0xff ) {
@@ -806,10 +829,15 @@
 		nps = DUnknown;
 		drbd_request_state(mdev,NS(disk,Outdated));
 		break;
+	case 7:
+		if( fp != Stonith ) {
+			ERR("outdate-peer() = 7 && fencing != Stonith !!!\n");
+		}
+		nps = Outdated;
+		break;
 	default:
 		/* The script is broken ... */
 		nps = DUnknown;
-		drbd_request_state(mdev,NS(disk,Outdated));
 		ERR("outdate-peer helper broken, returned %d \n",(r>>8)&0xff);
 		return nps;
 	}
@@ -1063,13 +1091,15 @@
 	}
 	ns = mdev->state;
 	spin_unlock_irq(&mdev->req_lock);
+	after_state_ch(mdev,os,ns);
 
 	if( r == SS_NothingToDo ) return 0;
 	if( r == -999 ) {
 		return -EINVAL;
 	}
-	after_state_ch(mdev,os,ns);
 
+	drbd_md_sync(mdev);
+	
 	if( r < SS_Success ) {
 		err = put_user(r, reason);
 		if(!err) err=-EIO;

Modified: trunk/drbd/drbd_int.h
===================================================================
--- trunk/drbd/drbd_int.h	2006-04-05 10:17:57 UTC (rev 2131)
+++ trunk/drbd/drbd_int.h	2006-04-05 18:01:11 UTC (rev 2132)
@@ -649,7 +649,6 @@
 	MD_DIRTY,		// current gen counts and flags not yet on disk
 	SYNC_STARTED,		// Needed to agree on the exact point in time..
 	UNIQUE,                 // Set on one node, cleared on the peer!
-	SPLIT_BRAIN_FIX,        // Set if split-brain-fix is configured
 	USE_DEGR_WFC_T		// Use degr-wfc-timeout instead of wfc-timeout.
 };
 
@@ -714,6 +713,7 @@
 	struct file *md_file;
 	int md_index;
 	enum io_error_handler on_io_error;
+	enum fencing_policy fencing;
 	sector_t u_size;   /* user provided size */
 	struct drbd_md md;
 };
@@ -1164,6 +1164,7 @@
 
 #define peer_mask role_mask
 #define pdsk_mask disk_mask
+#define susp_mask 1
 
 #define NS(T,S) ({drbd_state_t mask; mask.i=0; mask.T = T##_mask; mask;}), \
                 ({drbd_state_t val; val.i=0; val.T = (S); val;})

Modified: trunk/drbd/drbd_main.c
===================================================================
--- trunk/drbd/drbd_main.c	2006-04-05 10:17:57 UTC (rev 2131)
+++ trunk/drbd/drbd_main.c	2006-04-05 18:01:11 UTC (rev 2132)
@@ -566,12 +566,61 @@
 		              A##s_to_name(ns.A)); \
 	} })
 
+STATIC int pre_state_checks(drbd_dev* mdev, drbd_state_t ns)
+{
+	/* See drbd_state_sw_errors in drbd_strings.c */
 
-/* PRE TODO: Should return ernno numbers from the pre-state-change checks. */
+	enum fencing_policy fp;
+	int rv=SS_Success;
+
+	fp = DontCare;
+	if(inc_local(mdev)) {
+		fp = mdev->bc->fencing;
+		dec_local(mdev);
+	}
+
+	if(inc_net(mdev)) {
+		if( !mdev->net_conf->two_primaries &&
+		    ns.role == Primary && ns.peer == Primary ) 
+			rv=SS_TowPrimaries;
+		dec_net(mdev);
+	}
+
+	if( rv <= 0 ) /* already found a reason to abort */;
+	else if( ns.role == Primary && ns.conn < Connected &&
+		 ns.disk <= Outdated ) rv=SS_NoConsistnetDisk;
+
+	else if( fp >= Resource &&
+		 ns.role == Primary && ns.conn < Connected &&
+		 ns.pdsk >= DUnknown ) rv=SS_PrimaryNOP;
+
+	else if( ns.role == Primary && ns.disk <= Inconsistent &&
+		 ns.pdsk <= Inconsistent ) rv=SS_NoConsistnetDisk;
+	
+	else if( ns.conn > Connected &&
+		 ns.disk < UpToDate && ns.pdsk < UpToDate ) 
+		rv=SS_BothInconsistent;
+
+	else if( ns.conn > Connected &&
+		 (ns.disk == Diskless || ns.pdsk == Diskless ) )
+		rv=SS_SyncingDiskless;
+
+	else if( (ns.conn == Connected ||
+		  ns.conn == SkippedSyncS ||
+		  ns.conn == WFBitMapS ||
+		  ns.conn == SyncSource ||
+		  ns.conn == PausedSyncS) &&
+		 ns.disk == Outdated ) rv=SS_ConnectedOutdates;
+
+	return rv;
+}
+
+
 int _drbd_set_state(drbd_dev* mdev, drbd_state_t ns,enum chg_state_flags flags)
 {
 	drbd_state_t os;
 	int rv=SS_Success, warn_sync_abort=0;
+	enum fencing_policy fp;
 
 	MUST_HOLD(&mdev->req_lock);
 
@@ -579,6 +628,12 @@
 
 	if( ns.i == os.i ) return SS_NothingToDo;
 
+	fp = DontCare;
+	if(inc_local(mdev)) {
+		fp = mdev->bc->fencing;
+		dec_local(mdev);
+	}
+
 	/*  State sanitising  */
 	if( ns.conn < Connected ) {
 		ns.peer = Unknown;
@@ -644,43 +699,33 @@
 		}
 	}
 
-
+	if( fp == Stonith ) {
+		if( !(os.role == Primary && os.conn < Connected) &&
+		     (ns.role == Primary && ns.conn < Connected) ) {
+			ns.susp = 1;
+			ERR("ap_pending_cnt = %d while suspending IO.\n",
+			    atomic_read(&mdev->ap_pending_cnt));
+		}
+	}
+	
 	if( !(flags & ChgStateHard) ) {
 		/*  pre-state-change checks ; only look at ns  */
 		/* See drbd_state_sw_errors in drbd_strings.c */
 
-		if(inc_net(mdev)) {
-			if( !mdev->net_conf->two_primaries &&
-			    ns.role == Primary && ns.peer == Primary ) 
-				rv=SS_TowPrimaries;
-			dec_net(mdev);
+		rv = pre_state_checks(mdev,ns);
+		if(rv < SS_Success) {
+			/* If the old state was illegal as well, then let
+			   this happen...*/
+
+			if( pre_state_checks(mdev,os) == rv ) {
+				ERR("State change from bad state. "
+				    "Error would be: '%s'\n", 
+				    set_st_err_name(rv));
+				print_st(mdev,"old",os);
+				print_st(mdev,"new",ns);
+				rv = SS_Success;
+			}
 		}
-
-		if( rv <= 0 ) /* already found a reason to abort */;
-		else if( ns.role == Primary && ns.conn < Connected &&
-			 ns.disk <= Outdated ) rv=SS_NoConsistnetDisk;
-
-		else if( test_bit(SPLIT_BRAIN_FIX,&mdev->flags) &&
-			 ns.role == Primary && ns.conn < Connected &&
-			 ns.pdsk >= DUnknown ) rv=SS_PrimaryNOP;
-
-		else if( ns.role == Primary && ns.disk <= Inconsistent &&
-			 ns.pdsk <= Inconsistent ) rv=SS_NoConsistnetDisk;
-
-		else if( ns.conn > Connected &&
-			 ns.disk < UpToDate && ns.pdsk < UpToDate ) 
-			rv=SS_BothInconsistent;
-
-		else if( ns.conn > Connected &&
-			 (ns.disk == Diskless || ns.pdsk == Diskless ) )
-			rv=SS_SyncingDiskless;
-
-		else if( (ns.conn == Connected ||
-			  ns.conn == SkippedSyncS ||
-			  ns.conn == WFBitMapS ||
-			  ns.conn == SyncSource ||
-			  ns.conn == PausedSyncS) &&
-			 ns.disk == Outdated ) rv=SS_ConnectedOutdates;
 	}
 
 	if(rv < SS_Success) {
@@ -758,15 +803,24 @@
 
 void after_state_ch(drbd_dev* mdev, drbd_state_t os, drbd_state_t ns)
 {
+	enum fencing_policy fp;
 	u32 mdf;
 
+	fp = DontCare;
+	if(inc_local(mdev)) {
+		fp = mdev->bc->fencing;
+		dec_local(mdev);
+	}
+
 	if(mdev->bc) {
 		mdf = mdev->bc->md.flags & ~(MDF_Consistent|MDF_PrimaryInd|
-					     MDF_ConnectedInd|MDF_WasUpToDate);
+					     MDF_ConnectedInd|MDF_WasUpToDate|
+					     MDF_PeerOutDated );
 		if (mdev->state.role == Primary)       mdf |= MDF_PrimaryInd;
 		if (mdev->state.conn > WFReportParams) mdf |= MDF_ConnectedInd;
 		if (mdev->state.disk > Inconsistent)   mdf |= MDF_Consistent;
 		if (mdev->state.disk > Outdated)       mdf |= MDF_WasUpToDate;
+		if (mdev->state.pdsk <= Outdated)      mdf |= MDF_PeerOutDated;
 
 		if( mdf != mdev->bc->md.flags) {
 			mdev->bc->md.flags = mdf;
@@ -777,6 +831,19 @@
 	/* Here we have the actions that are performed after a
 	   state change. This function might sleep */
 
+	if( fp == Stonith && ns.susp && os.susp ) {
+		// case1: The outdate peer handler is successfull:
+		// case2: The connection was established again:
+		if ( (os.pdsk > Outdated  && ns.pdsk <= Outdated) || // case1
+		     (os.conn < Connected && ns.conn >= Connected) ) {
+			tl_clear(mdev);
+			spin_lock_irq(&mdev->req_lock);
+			_drbd_set_state(mdev,_NS(susp,0), 
+					ChgStateVerbose | ScheduleAfter );
+			spin_unlock_irq(&mdev->req_lock);
+		}
+	}
+	// Do not change the order of the if above and below...
 	if (os.conn != WFBitMapS && ns.conn == WFBitMapS) {
 		wait_event(mdev->cstate_wait,!atomic_read(&mdev->ap_bio_cnt));
 		drbd_bm_lock(mdev);   // {

Modified: trunk/drbd/drbd_receiver.c
===================================================================
--- trunk/drbd/drbd_receiver.c	2006-04-05 10:17:57 UTC (rev 2131)
+++ trunk/drbd/drbd_receiver.c	2006-04-05 18:01:11 UTC (rev 2132)
@@ -2334,8 +2334,16 @@
 
 STATIC void drbd_disconnect(drbd_dev *mdev)
 {
+	enum fencing_policy fp;
+
 	D_ASSERT(mdev->state.conn < Connected);
 
+	fp = DontCare;
+	if(inc_local(mdev)) {
+		fp = mdev->bc->fencing;
+		dec_local(mdev);
+	}
+
 	/* in case we have been syncing, and then we drop the connection,
 	 * we need to "w_resume_next_sg", which we try to achieve by
 	 * setting the STOP_SYNC_TIMER bit, and schedulung the timer for
@@ -2397,11 +2405,21 @@
 	spin_unlock_irq(&mdev->ee_lock);
 
 	// primary
-	tl_clear(mdev);
 	clear_bit(ISSUE_BARRIER,&mdev->flags);
-	wait_event( mdev->cstate_wait, atomic_read(&mdev->ap_pending_cnt)==0 );
-	D_ASSERT(mdev->oldest_barrier->n_req == 0);
 
+	if(fp != Stonith ) {
+		tl_clear(mdev);
+		wait_event( mdev->cstate_wait, 
+			    atomic_read(&mdev->ap_pending_cnt)==0 );
+		D_ASSERT(mdev->oldest_barrier->n_req == 0);
+
+		if(atomic_read(&mdev->ap_pending_cnt)) {
+			ERR("ap_pending_cnt = %d\n",
+			    atomic_read(&mdev->ap_pending_cnt));
+			atomic_set(&mdev->ap_pending_cnt,0);
+		}
+	}
+
 	D_ASSERT(atomic_read(&mdev->pp_in_use) == 0);
 	D_ASSERT(list_empty(&mdev->read_ee)); // done by termination of worker
 	D_ASSERT(list_empty(&mdev->active_ee)); // done here
@@ -2427,11 +2445,6 @@
 	   on the fly. */
 	atomic_set(&mdev->rs_pending_cnt,0);
 
-	if(atomic_read(&mdev->ap_pending_cnt)) {
-		ERR("ap_pending_cnt = %d\n",atomic_read(&mdev->ap_pending_cnt));
-		atomic_set(&mdev->ap_pending_cnt,0);
-	}
-
 	wake_up(&mdev->cstate_wait);
 
 	if (get_t_state(&mdev->receiver) == Exiting) {
@@ -2442,9 +2455,9 @@
 		drbd_thread_start(&mdev->worker);
 	}
 
-	if ( mdev->state.role == Primary ) {
-		if ( test_bit(SPLIT_BRAIN_FIX,&mdev->flags) &&
-		     mdev->state.pdsk >= DUnknown ) {
+	if ( mdev->state.role == Primary ) {		
+		if( fp >= Resource &&
+		    mdev->state.pdsk >= DUnknown ) {
 			drbd_disks_t nps = drbd_try_outdate_peer(mdev);
 			drbd_request_state(mdev,NS(pdsk,nps));
 		}

Modified: trunk/drbd/drbd_req.c
===================================================================
--- trunk/drbd/drbd_req.c	2006-04-05 10:17:57 UTC (rev 2131)
+++ trunk/drbd/drbd_req.c	2006-04-05 18:01:11 UTC (rev 2132)
@@ -245,8 +245,9 @@
 	// down_read(mdev->device_lock);
 
 	wait_event( mdev->cstate_wait,
-		    (volatile int)(mdev->state.conn < WFBitMapS ||
-				   mdev->state.conn > WFBitMapT) );
+		    (volatile int)((mdev->state.conn < WFBitMapS ||
+				    mdev->state.conn > WFBitMapT) &&
+				   !mdev->state.susp ) );
 
 	local = inc_local(mdev);
 	if (rw == READ || rw == READA) {
@@ -452,7 +453,6 @@
 		return 0;
 	}
 
-
 	/*
 	 * what we "blindly" assume:
 	 */

Modified: trunk/drbd/linux/drbd.h
===================================================================
--- trunk/drbd/linux/drbd.h	2006-04-05 10:17:57 UTC (rev 2131)
+++ trunk/drbd/linux/drbd.h	2006-04-05 18:01:11 UTC (rev 2132)
@@ -69,6 +69,11 @@
 	Detach
 };
 
+enum fencing_policy {
+	DontCare,
+	Resource,
+	Stonith
+};
 
 struct disk_config {
 	IN __u64    disk_size;
@@ -76,7 +81,7 @@
 	IN enum io_error_handler on_io_error;
 	IN int      meta_device;
 	IN int      meta_index;
-	IN int      split_brain_fix;
+	IN enum fencing_policy fencing;
 	const int   _pad;
 };
 
@@ -299,12 +304,14 @@
 	__MDF_ConnectedInd,
 	__MDF_FullSync,
 	__MDF_WasUpToDate,
+	__MDF_PeerOutDated // or less/lower.
 };
 #define MDF_Consistent      (1<<__MDF_Consistent)
 #define MDF_PrimaryInd      (1<<__MDF_PrimaryInd)
 #define MDF_ConnectedInd    (1<<__MDF_ConnectedInd)
 #define MDF_FullSync        (1<<__MDF_FullSync)
 #define MDF_WasUpToDate     (1<<__MDF_WasUpToDate)
+#define MDF_PeerOutDated    (1<<__MDF_PeerOutDated)
 
 enum UuidIndex {
 	Current,

Modified: trunk/user/drbdadm_scanner.fl
===================================================================
--- trunk/user/drbdadm_scanner.fl	2006-04-05 10:17:57 UTC (rev 2131)
+++ trunk/user/drbdadm_scanner.fl	2006-04-05 18:01:11 UTC (rev 2132)
@@ -68,7 +68,7 @@
 usage-count 		{ DP; return TK_USAGE_COUNT;		}
 size			{ DP; CP; RC(DISK_SIZE); return TK_DISK_OPTION;	}
 on-io-error		{ DP; CP; return TK_DISK_OPTION;	}
-split-brain-fix		{ DP; CP; return TK_DISK_SWITCH;	}
+fencing			{ DP; CP; return TK_DISK_OPTION;	}
 timeout			{ DP; CP; RC(TIMEOUT); return TK_NET_OPTION;	}
 ko-count		{ DP; CP; RC(KO_COUNT); return TK_NET_OPTION;	}
 ping-int		{ DP; CP; RC(PING_INT); return TK_NET_OPTION;	}

Modified: trunk/user/drbdmeta.c
===================================================================
--- trunk/user/drbdmeta.c	2006-04-05 10:17:57 UTC (rev 2131)
+++ trunk/user/drbdmeta.c	2006-04-05 18:01:11 UTC (rev 2132)
@@ -1093,6 +1093,7 @@
 		if (!m_strsep_bit(str, &md->flags, MDF_PrimaryInd)) break;
 		if (!m_strsep_bit(str, &md->flags, MDF_ConnectedInd)) break;
 		if (!m_strsep_bit(str, &md->flags, MDF_FullSync)) break;
+		if (!m_strsep_bit(str, &md->flags, MDF_PeerOutDated)) break;
 	} while (0);
 }
 
@@ -1814,7 +1815,7 @@
 	printf("Converting meta data...\n");
 	cfg->md.magic = DRBD_MD_MAGIC_08;
 
-	// The MDF Flags are the same in 07 and 08
+	// The MDF Flags are (nearly) the same in 07 and 08
 	cfg->md.flags = cfg->md.gc[Flags];
 	/* 
 	 */

Modified: trunk/user/drbdsetup.c
===================================================================
--- trunk/user/drbdsetup.c	2006-04-05 10:17:57 UTC (rev 2131)
+++ trunk/user/drbdsetup.c	2006-04-05 18:01:11 UTC (rev 2132)
@@ -69,6 +69,7 @@
 #define DEF_ON_IO_ERROR         PassOn
 #define DEF_KO_COUNT                 0
 #define DEF_ON_DISCONNECT       Reconnect
+#define DEF_FENCING             DontCare
 #define DEF_TWO_PRIMARIES            0
 #define DEF_AFTER_SB_0P       Disconnect
 #define DEF_AFTER_SB_1P       Disconnect
@@ -179,7 +180,7 @@
    (struct option[]) {
      { "size",       required_argument, 0, 'd' },
      { "on-io-error",required_argument, 0, 'e' },
-     { "split-brain-fix",  no_argument, 0, 'b' },
+     { "fencing",    required_argument, 0, 'f' },
      { 0,            0,                 0, 0 } } },
   {"resize", cmd_disk_size,             0,
    (struct option[]) {
@@ -207,6 +208,12 @@
   // [FreezeIO]    = "freeze_io" // TODO on the kernel side...
 };
 
+const char *fencing_names[] = {
+  [DontCare] = "dont-care",
+  [Resource] = "resource-only",
+  [Stonith]  = "resource-and-stonith" 
+};
+
 const char *asb0p_names[] = {
   [Disconnect]        = "disconnect",
   [DiscardYoungerPri] = "discard-younger-primary",
@@ -410,6 +417,12 @@
     if(i < ARRY_SIZE(dh_names)-1) printf(",");
   }
 
+  printf("\nAvailable fencing policies:");
+  for(i=0;i<ARRY_SIZE(fencing_names);i++) {
+    printf(" %s",fencing_names[i]);
+    if(i < ARRY_SIZE(fencing_names)-1) printf(",");
+  }
+
   printf("\n\nVersion: "REL_VERSION" (api:%d)\n%s\n",
 		  API_VERSION, drbd_buildtag());
   if (addinfo)
@@ -449,7 +462,7 @@
 {
   cn->config.disk_size = 0; /* default not known */
   cn->config.on_io_error = DEF_ON_IO_ERROR;
-  cn->config.split_brain_fix = 0;
+  cn->config.fencing = DEF_FENCING;
 
   if(argc==0) return 0;
 
@@ -475,8 +488,13 @@
 	    return 20;
 	  }
 	  break;
-	case 'b':
-	  cn->config.split_brain_fix = 1;
+	case 'f':
+	  cn->config.fencing = lookup_handler(optarg,fencing_names);
+	  if( cn->config.fencing == -1U ) {
+	    fprintf(stderr,"%s: '%s' is an invalid fency policy.\n",
+		    cmdname,optarg);
+	    return 20;
+	  }
 	  break;
 	case 1:	// non option argument. see getopt_long(3)
 	  fprintf(stderr,"%s: Unexpected nonoption argument '%s'\n",cmdname,optarg);

Modified: trunk/user/drbdtool_common.c
===================================================================
--- trunk/user/drbdtool_common.c	2006-04-05 10:17:57 UTC (rev 2131)
+++ trunk/user/drbdtool_common.c	2006-04-05 18:01:11 UTC (rev 2132)
@@ -326,12 +326,13 @@
 	for ( i=History_start ; i<=History_end ; i++ ) {
 		printf(X64(016)":", uuid[i]);
 	}
-	printf("%d:%d:%d:%d:%d\n",
+	printf("%d:%d:%d:%d:%d:%d\n",
 	       flags & MDF_Consistent ? 1 : 0,
 	       flags & MDF_WasUpToDate ? 1 : 0,
 	       flags & MDF_PrimaryInd ? 1 : 0,
 	       flags & MDF_ConnectedInd ? 1 : 0,
-	       flags & MDF_FullSync ? 1 : 0);
+	       flags & MDF_FullSync ? 1 : 0,
+	       flags & MDF_PeerOutDated ? 1 : 0);
 }
 
 void dt_pretty_print_uuids(const __u64* uuid, unsigned int flags)
@@ -345,12 +346,13 @@
 "       V               V                 V         V\n");               
 	dt_print_uuids(uuid, flags);
 	printf(
-"                                                                    ^ ^ ^ ^ ^\n"
-"                                      -<  Data consistancy flag  >--+ | | | |\n"
-"                             -<  Data was/is currently up-to-date  >--+ | | |\n"
-"                                  -<  Node was/is currently primary  >--+ | |\n"
-"                                  -<  Node was/is currently connected  >--+ |\n"
-"         -<  Node was in the progress of setting all bits in the bitmap  >--+\n"
+"                                                                    ^ ^ ^ ^ ^ ^\n"
+"                                      -<  Data consistancy flag  >--+ | | | | |\n"
+"                             -<  Data was/is currently up-to-date  >--+ | | | |\n"
+"                                  -<  Node was/is currently primary  >--+ | | |\n"
+"                                  -<  Node was/is currently connected  >--+ | |\n"
+"         -<  Node was in the progress of setting all bits in the bitmap  >--+ |\n"
+"                        -<  The peer's disk was out-dated or inconsistent  >--+\n"
 "\n");
 }
 

From drbd-cvs at lists.linbit.com  Thu Apr  6 12:12:52 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Thu Apr  6 12:13:00 2006
Subject: [DRBD-cvs] svn commit by phil - r2133 - trunk/user - Included the
	flags in the md-dump format. 
Message-ID: <20060406101253.1B22215CE6@mail.linbit.com>

Author: phil
Date: 2006-04-06 12:12:51 +0200 (Thu, 06 Apr 2006)
New Revision: 2133

Modified:
   trunk/user/drbd_endian.h
   trunk/user/drbdmeta.c
   trunk/user/drbdmeta_parser.h
   trunk/user/drbdmeta_scanner.fl
Log:
Included the flags in the md-dump format.


Modified: trunk/user/drbd_endian.h
===================================================================
--- trunk/user/drbd_endian.h	2006-04-05 18:01:11 UTC (rev 2132)
+++ trunk/user/drbd_endian.h	2006-04-06 10:12:51 UTC (rev 2133)
@@ -166,16 +166,14 @@
  */
 
 #if BITS_PER_LONG == 32
-# define X32 "%X"
-//# define X64 "%llX"
+# define X32(a) "%"#a"X"
 # define X64(a) "%"#a"llX"
 # define D32 "%d"
 # define D64 "%lld"
 # define U32 "%u"
 # define U64 "%llu"
 #elif BITS_PER_LONG == 64
-# define X32 "%X"
-//# define X64 "%lX"
+# define X32(a) "%"#a"X"
 # define X64(a) "%"#a"lX"
 # define D32 "%d"
 # define D64 "%ld"

Modified: trunk/user/drbdmeta.c
===================================================================
--- trunk/user/drbdmeta.c	2006-04-05 18:01:11 UTC (rev 2132)
+++ trunk/user/drbdmeta.c	2006-04-06 10:12:51 UTC (rev 2133)
@@ -1681,13 +1681,16 @@
 		for (i = 0; i < GEN_CNT_SIZE; i++) {
 			printf(" %d;", cfg->md.gc[i]);
 		}
+		printf("\n}\n");
 	} else { // >= 08
 		printf("uuid {\n   ");
 		for ( i=Current ; i<UUID_SIZE ; i++ ) {
 			printf(" 0x"X64(016)";", cfg->md.uuid[i]);
 		}
+		printf("\n");
+		printf("    flags 0x"X32(08)";\n",cfg->md.flags);
+		printf("}\n");
 	}
-	printf("\n}\n");
 
 	if (format_version(cfg) >= Drbd_07) {
 		printf("la-size-sect "U64";\n", cfg->md.la_sect);
@@ -1748,12 +1751,14 @@
 			cfg->md.gc[i] = yylval.u64;
 		}
 		EXP('}');
-	} else { // >? 08
+	} else { // >= 08
 		EXP(TK_UUID); EXP('{');
 		for ( i=Current ; i<UUID_SIZE ; i++ ) {
 			EXP(TK_U64); EXP(';');
 			cfg->md.uuid[i] = yylval.u64;
 		}
+		EXP(TK_FLAGS); EXP(TK_U32); EXP(';');
+		cfg->md.flags = (u32)yylval.u64;
 		EXP('}');
 	}
 	EXP(TK_LA_SIZE); EXP(TK_NUM); EXP(';');

Modified: trunk/user/drbdmeta_parser.h
===================================================================
--- trunk/user/drbdmeta_parser.h	2006-04-05 18:01:11 UTC (rev 2132)
+++ trunk/user/drbdmeta_parser.h	2006-04-06 10:12:51 UTC (rev 2133)
@@ -12,6 +12,7 @@
 enum yytokentype {
 	TK_STRING = 258,
 	TK_U64,
+	TK_U32,
 	TK_NUM,
 	TK_GC,
 	TK_BM,
@@ -20,7 +21,8 @@
 	TK_LA_SIZE,
 	TK_BM_BYTE_PER_BIT,
 	TK_DEVICE_UUID,
-	TK_TIMES
+	TK_TIMES,
+	TK_FLAGS,
 };
 
 /* avoid compiler warnings about implicit declaration */

Modified: trunk/user/drbdmeta_scanner.fl
===================================================================
--- trunk/user/drbdmeta_scanner.fl	2006-04-05 18:01:11 UTC (rev 2132)
+++ trunk/user/drbdmeta_scanner.fl	2006-04-06 10:12:51 UTC (rev 2133)
@@ -18,6 +18,7 @@
 COMMENT		\#[^\n]*
 NUM		[0-9]{1,9}
 U64		0x[0-9A-Fa-f]{16}
+U32		0x[0-9A-Fa-f]{8}
 OP		[{};]
 STRING		\"[^\"]*\"
 
@@ -28,6 +29,7 @@
 {OP}		DP; return yytext[0];
 {STRING}	unescape(); yylval.txt=yytext; DP; return TK_STRING; 
 {U64}		yylval.u64 = strto_u64(yytext, NULL, 16); DP; return TK_U64;
+{U32}		yylval.u64 = strto_u64(yytext, NULL, 16); DP; return TK_U32;
 {NUM}		yylval.u64 = strto_u64(yytext, NULL, 10); DP; return TK_NUM;
 gc		DP; return TK_GC;
 bm		DP; return TK_BM;
@@ -37,6 +39,7 @@
 bm-byte-per-bit DP; return TK_BM_BYTE_PER_BIT;
 device-uuid	DP; return TK_DEVICE_UUID;
 times		DP; return TK_TIMES;
+flags		DP; return TK_FLAGS;
 
 %%
 

From drbd-cvs at lists.linbit.com  Thu Apr  6 13:03:39 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Thu Apr  6 13:03:41 2006
Subject: [DRBD-cvs] svn commit by phil - r2134 - in trunk: . drbd drbd/linux
	user - Added a fallback mechanism to unfreeze IO on a device i
Message-ID: <20060406110339.AAA6516190@mail.linbit.com>

Author: phil
Date: 2006-04-06 13:03:37 +0200 (Thu, 06 Apr 2006)
New Revision: 2134

Modified:
   trunk/ROADMAP
   trunk/drbd/drbd_fs.c
   trunk/drbd/drbd_strings.c
   trunk/drbd/linux/drbd.h
   trunk/user/drbdadm_main.c
   trunk/user/drbdsetup.c
Log:
Added a fallback mechanism to unfreeze IO on a device in case
the "outdate-peer" handler fails miserably.
drbdadm suspend-io res
  For sake of completness, it added "drbdadm resume-io res" as well.


Modified: trunk/ROADMAP
===================================================================
--- trunk/ROADMAP	2006-04-06 10:12:51 UTC (rev 2133)
+++ trunk/ROADMAP	2006-04-06 11:03:37 UTC (rev 2134)
@@ -195,9 +195,7 @@
   * We need to store the fact that the peer is outdated/inconsistent
     in the meta-data. To allow an stand allone primary to be rebooted.
 
-  80% DONE
-       The only missing thing is a fallback mechanism to unfreeze
-       IO in case the script failed.
+  99% DONE
 
 8 New command drbdmeta
 

Modified: trunk/drbd/drbd_fs.c
===================================================================
--- trunk/drbd/drbd_fs.c	2006-04-06 10:12:51 UTC (rev 2133)
+++ trunk/drbd/drbd_fs.c	2006-04-06 11:03:37 UTC (rev 2134)
@@ -1185,7 +1185,7 @@
 int drbd_ioctl(struct inode *inode, struct file *file,
 			   unsigned int cmd, unsigned long arg)
 {
-	int r,minor,err=0;
+	int r,minor,err=0,io_suspend=0;
 	long time;
 	struct Drbd_Conf *mdev;
 	struct ioctl_wait* wp;
@@ -1462,6 +1462,17 @@
 	case DRBD_IOCTL_RESUME_SYNC:
 		if(!drbd_resync_resume(mdev, UserImposed)) err = -EINPROGRESS;
 		break;
+		
+	case DRBD_IOCTL_SUSPEND_IO:
+		io_suspend=1;
+	case DRBD_IOCTL_RESUME_IO:
+		r = drbd_request_state(mdev,NS(susp,io_suspend));
+		if( r < SS_Success ) {
+			err = put_user(r, (int *) arg);
+			if(!err) err=-EIO;
+			else err=-EINVAL;
+		}
+		break;
 
 	default:
 		err = -EINVAL;

Modified: trunk/drbd/drbd_strings.c
===================================================================
--- trunk/drbd/drbd_strings.c	2006-04-06 10:12:51 UTC (rev 2133)
+++ trunk/drbd/drbd_strings.c	2006-04-06 11:03:37 UTC (rev 2134)
@@ -64,7 +64,6 @@
 	[-SS_TowPrimaries] = "Multiple primaries now allowed by config",
 	[-SS_NoConsistnetDisk] = 
 		"Refusing to be Primary without at least one consistent disk",
-	[-SS_REMOVE_ME] = "Refusing to make peer Primary without disk",
 	[-SS_BothInconsistent] = "Refusing to be inconsistent on both nodes",
 	[-SS_SyncingDiskless] = "Refusing to be syncing and diskless",
 	[-SS_ConnectedOutdates] = "Refusing to be Outdated while Connected",

Modified: trunk/drbd/linux/drbd.h
===================================================================
--- trunk/drbd/linux/drbd.h	2006-04-06 10:12:51 UTC (rev 2133)
+++ trunk/drbd/linux/drbd.h	2006-04-06 11:03:37 UTC (rev 2134)
@@ -265,7 +265,6 @@
 	SS_UnknownError=0,
 	SS_TowPrimaries=-1,
 	SS_NoConsistnetDisk=-2,
-	SS_REMOVE_ME=-3,
 	SS_BothInconsistent=-4,
 	SS_SyncingDiskless=-5,
 	SS_ConnectedOutdates=-6,
@@ -361,6 +360,8 @@
 #define DRBD_IOCTL_GET_UUIDS        _IOR( DRBD_IOCTL_LETTER, 0x16, struct ioctl_get_uuids )
 #define DRBD_IOCTL_PAUSE_SYNC       _IO ( DRBD_IOCTL_LETTER, 0x17)
 #define DRBD_IOCTL_RESUME_SYNC      _IO ( DRBD_IOCTL_LETTER, 0x18)
+#define DRBD_IOCTL_SUSPEND_IO       _IOW( DRBD_IOCTL_LETTER, 0x19, int )
+#define DRBD_IOCTL_RESUME_IO        _IOW( DRBD_IOCTL_LETTER, 0x1A, int )
 
 #endif
 

Modified: trunk/user/drbdadm_main.c
===================================================================
--- trunk/user/drbdadm_main.c	2006-04-06 10:12:51 UTC (rev 2133)
+++ trunk/user/drbdadm_main.c	2006-04-06 11:03:37 UTC (rev 2134)
@@ -215,6 +215,8 @@
   { "pri-lost-after-sb", adm_khelper,   3,1,0 },
   { "outdate-peer",      adm_khelper,   3,1,0 },
   { "set-gi",            admm_generic,  4,1,0 },
+  { "suspend-io",        adm_generic_s, 4,1,0 },
+  { "resume-io",         adm_generic_s, 4,1,0 },
 };
 
 /*** These functions are used to the print the config ***/

Modified: trunk/user/drbdsetup.c
===================================================================
--- trunk/user/drbdsetup.c	2006-04-06 10:12:51 UTC (rev 2133)
+++ trunk/user/drbdsetup.c	2006-04-06 11:03:37 UTC (rev 2134)
@@ -126,7 +126,10 @@
 int cmd_dstate(int drbd_fd,char** argv,int argc,struct option *options);
 int cmd_show_gi(int drbd_fd,char** argv,int argc,struct option *options);
 int cmd_get_gi(int drbd_fd,char** argv,int argc,struct option *options);
+int cmd_suspend_io(int drbd_fd,char** argv,int argc,struct option *options);
+int cmd_resume_io(int drbd_fd,char** argv,int argc,struct option *options);
 
+
 struct drbd_cmd commands[] = {
   {"primary", cmd_primary,           0,
    (struct option[]) {
@@ -194,6 +197,8 @@
   {"show-gi", cmd_show_gi,           0, 0, },
   {"get-gi", cmd_get_gi,             0, 0, },
   {"show", cmd_show,                 0, 0, },
+  {"suspend-io", cmd_suspend_io,     0, 0, },
+  {"resume-io", cmd_resume_io,       0, 0, },
 };
 
 const char *eh_names[] = {
@@ -1505,6 +1510,46 @@
   return 0;
 }
 
+int cmd_suspend_io(int drbd_fd,char** argv __attribute((unused)),int argc __attribute((unused)),struct option *options __attribute((unused)))
+{
+  int err;
+  int reason;
+
+  err=ioctl(drbd_fd,DRBD_IOCTL_SUSPEND_IO, &reason);
+  if(err)
+    {
+      err=errno;
+      PERROR("ioctl(,DRBD_IOCTL_SUSPEND_IO) failed");
+      if(err==EIO) 
+	{
+	  fprintf(stderr,"%s\n",set_st_err_name(reason));
+	}
+      return 20;
+    }
+  
+  return 0;
+}
+
+int cmd_resume_io(int drbd_fd,char** argv __attribute((unused)),int argc __attribute((unused)),struct option *options __attribute((unused)))
+{
+  int err;
+  int reason;
+
+  err=ioctl(drbd_fd,DRBD_IOCTL_RESUME_IO, &reason);
+  if(err)
+    {
+      err=errno;
+      PERROR("ioctl(,DRBD_IOCTL_RESUME_IO) failed");
+      if(err==EIO) 
+	{
+	  fprintf(stderr,"%s\n",set_st_err_name(reason));
+	}
+      return 20;
+    }
+  
+  return 0;
+}
+
 int main(int argc, char** argv)
 {
   int drbd_fd;

From drbd-cvs at lists.linbit.com  Thu Apr  6 13:39:25 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Thu Apr  6 13:39:26 2006
Subject: [DRBD-cvs] svn commit by phil - r2135 - trunk - Micro updates to
	the spec file 
Message-ID: <20060406113925.22AA116191@mail.linbit.com>

Author: phil
Date: 2006-04-06 13:39:24 +0200 (Thu, 06 Apr 2006)
New Revision: 2135

Modified:
   trunk/drbd.spec.in
Log:
Micro updates to the spec file


Modified: trunk/drbd.spec.in
===================================================================
--- trunk/drbd.spec.in	2006-04-06 11:03:37 UTC (rev 2134)
+++ trunk/drbd.spec.in	2006-04-06 11:39:24 UTC (rev 2135)
@@ -121,6 +121,8 @@
 %defattr(755,root,root)
 /sbin/drbdsetup
 /sbin/drbdadm
+/sbin/drbdmeta
+/usr/lib/drbd/outdate-peer.sh
 /etc/ha.d/resource.d/drbddisk
 
 %defattr(644,root,root)
@@ -132,6 +134,7 @@
 %{_mandir}/man8/drbdadm.8.gz
 %{_mandir}/man8/drbddisk.8.gz
 %{_mandir}/man5/drbd.conf.5.gz
+%{_mandir}/man8/drbdmeta.8.gz
 %doc scripts/drbd.conf
 %doc COPYING
 %doc README

From drbd-cvs at lists.linbit.com  Thu Apr  6 16:51:32 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Thu Apr  6 16:51:34 2006
Subject: [DRBD-cvs] svn commit by phil - r2136 - trunk/documentation - A bit
	of work on the documentation. 
Message-ID: <20060406145132.91BCE15CE6@mail.linbit.com>

Author: phil
Date: 2006-04-06 16:51:31 +0200 (Thu, 06 Apr 2006)
New Revision: 2136

Modified:
   trunk/documentation/drbd.conf.sgml
   trunk/documentation/drbdadm.sgml
   trunk/documentation/drbdsetup.sgml
Log:
A bit of work on the documentation.


Modified: trunk/documentation/drbd.conf.sgml
===================================================================
--- trunk/documentation/drbd.conf.sgml	2006-04-06 11:39:24 UTC (rev 2135)
+++ trunk/documentation/drbd.conf.sgml	2006-04-06 14:51:31 UTC (rev 2136)
@@ -1,6 +1,6 @@
 <!DOCTYPE RefEntry PUBLIC "-//Davenport//DTD DocBook V3.0//EN">
 <refentry>
-<docinfo><date>15 Apr 2001</date></docinfo>
+<docinfo><date>06 April 2006</date></docinfo>
 
 <refmeta>
  <refentrytitle>drbd.conf</refentrytitle>
@@ -16,46 +16,49 @@
  <title>Introduction</title>
  <para>
  The file <option>/etc/drbd.conf</option> is read by
- <option>/etc/init.d/drbd</option> and
- <option>/etc/ha.d/resource.d/drbddisk</option>
- which are included in the DRBD distribution.
+ <option>drbdaddm</option>.
  </para>
  <para>
  The file format was designed as to allow to have
  a verbatim copy of the file on both nodes of the cluster.
  It is highly recommended to do so in order to keep your configuration
  manageable. The file <option>/etc/drbd.conf</option> should be the same on both  nodes of the cluster. Changes to <option>/etc/drbd.conf</option> do not apply
- immediately.
+ immediately. 
 <example>
 <title>A small drbd.conf file</title>
 <programlisting>
-resource drbd0 {
-  protocol C;
-  incon-degr-cmd "halt -f";
-
-  on thost1 {
-    device    /dev/drbd1;
-    disk      /dev/hda7;
-    address   10.1.1.31:7789;
-    meta-disk  internal;
-  }
-
-  on thost2 {
-    device    /dev/drbd1;
-    disk      /dev/hda7;
-    address   10.1.1.32:7789;
-    meta-disk  internal;
-  }
+global { usage-count yes; }
+common { syncer { rate 10M; } }
+resource r0 {
+	protocol C;
+	net { 	
+		cram-hmac-alg sha1; 
+		shared-secret "FooFunFactory"; 
+	}
+	on thost1 {
+		device    /dev/drbd1;
+		disk      /dev/hda7;
+		address   10.1.1.31:7789;
+		meta-disk  internal;
+	}
+	on thost2 {
+		device    /dev/drbd1;
+		disk      /dev/hda7;
+		address   10.1.1.32:7789;
+		meta-disk  internal;
+	}
 }
 </programlisting>
 </example>
- In this example there is a single DRBD resource (called drbd0) which uses
+ In this example there is a single DRBD resource (called r0) which uses
  protocol C for the connection between its devices.
  The device which runs
  on host <replaceable>thost1</replaceable> uses
  <replaceable>/dev/drbd1</replaceable> as devices for its application, and
  <replaceable>/dev/hda7</replaceable> as low level storage for the data.
  The IP addresses are used to specify the networking interfaces to use.
+ An eventually running resyncprocess should use about 10MByte/second of IO 
+ bandwith.
  </para>
  <para>
  There may be multiple resource sections in a single drbd.conf file.
@@ -113,8 +116,8 @@
   <term><option>global</option></term>
   <listitem><para>
     Configures some global parameters. Currently only
-    <option>minor-count</option>, <option>dialog-refresh</option> 
-    and <option>disable-ip-verification</option>
+    <option>minor-count</option>, <option>dialog-refresh</option>,
+    <option>disable-ip-verification</option> and <option>usage-count</option>
     are allowed here. You may only have one global section, preferably
     as the first section.
   </para>
@@ -122,6 +125,19 @@
 </varlistentry>
 
 <varlistentry>
+  <term><option>common</option></term>
+  <listitem><para>
+    All resources interhit the options set in this section.
+    The common section might have a
+    a <option>startup</option>,
+    a <option>syncer</option>,
+    a <option>handlers</option>,
+    a <option>net</option> and a <option>disk</option> section.
+  </para>
+  </listitem>
+</varlistentry>
+
+<varlistentry>
   <term><option>resource <replaceable>name</replaceable></option></term>
   <listitem><para>
     Configures a DRBD resource.
@@ -130,9 +146,9 @@
     and may have
     a <option>startup</option>,
     a <option>syncer</option>,
+    a <option>handlers</option>,
     a <option>net</option> and a <option>disk</option> section.
     Required parameter in this section: <option>protocol</option>.
-    Optional parameter: <option>incon-degr-cmd</option>.
   </para>
   </listitem>
 </varlistentry>
@@ -175,7 +191,10 @@
     <option>sndbuf-size</option>, <option>timeout</option>,
     <option>connect-int</option>, <option>ping-int</option>,
     <option>max-buffers</option>, <option>max-epoch-size</option>,
-    <option>ko-count</option>, <option>on-disconnect</option>.
+    <option>ko-count</option>, <option>allow-two-primaries</option>,
+    <option>cram-hmac-alg</option>, <option>shared-secret</option>,
+    <option>after-sb-0pri</option>, <option>after-sb-1pri</option>,
+    <option>after-sb-2pri</option>
   </para>
   </listitem>
 </varlistentry>
@@ -202,10 +221,23 @@
     <manvolnum>8</manvolnum></citerefentry> for detailed description
     of this section's parameters.
     Optional parameters:
-    <option>rate</option>, <option>group</option>, <option>al-extents</option>.
+    <option>rate</option>, <option>after</option>, <option>al-extents</option>.
   </para>
   </listitem>
 </varlistentry>
+
+<varlistentry>
+  <term><option>handlers</option></term>
+  <listitem><para>
+    In this section can define handlers (executables) that are executed
+    by the DRBD system in response to certain events.
+    Optional parameters:
+    <option>pri-on-incon-degr</option>, <option>pri-lost-after-sb</option>, 
+    <option>outdate-peer</option>.
+  </para>
+  </listitem>
+</varlistentry>
+
 </variablelist>
 </refsect2>
 
@@ -253,6 +285,19 @@
 </varlistentry>
 
 <varlistentry>
+  <term><option>usage-count <replaceable>val</replaceable></option></term>
+  <listitem>
+  <para>Please participate in
+  <ulink url="http://usage.drbd.org">
+  <citetitle>DRBD's online usage counter</citetitle></ulink>. 
+  The most convenient way to do so
+  is to set this option to <option>yes</option>. Valid options are:
+  <option>yes</option>, <option>no</option> and <option>ask</option>.
+  </para>
+  </listitem>
+</varlistentry>
+
+<varlistentry>
   <term><option>protocol <replaceable>prot-id</replaceable></option></term>
   <listitem>
   <para>On the TCP/IP link the specified <replaceable>protocol</replaceable>
@@ -365,6 +410,42 @@
 </varlistentry>
 
 <varlistentry>
+  <term><option>fencing <replaceable>fencing_policy</replaceable></option></term>
+  <listitem><para>
+  Under <option>fencing</option> we understand preventative
+  measures to avoid situations where both nodes are primary
+  and disconnected (AKA split brain).
+  </para>
+  <para>Valid fencing policies are:</para>
+  <variablelist>
+    <varlistentry><term><option>dont-care</option></term>
+      <listitem><para>
+	This is the default policy. No fencing actions are untertaken.
+      </para></listitem></varlistentry>
+    <varlistentry><term><option>resource-only</option></term>
+      <listitem><para>
+	If a node becomes a disconnected primary it tries to outdate
+	the peer's disk. This is done by calling the outdate-peer
+	handler. The handler is supposed to reach the other node over
+	alternative communication pathes and call 'drbdadm outdate 
+	res' there.
+      </para></listitem></varlistentry>
+    <varlistentry><term><option>resource-and-stonith</option></term> 
+      <listitem><para>
+	If a node becomes a disconnected primary it freezes all
+	its IO operations and calls its outdate-peer handler. The
+	outdate-peer hander is supposed to reach the peer over
+	alternative communicaton pathes and call 'drbdadm outdate 
+	res' there. In case it can not reach the peer it should
+	stonith the peer. IO is resumed as soon as the situation
+	is resolved. In case your handler fails you can resume
+	IO with the <option>resume-io</option> command.
+      </para></listitem></varlistentry>
+    </variablelist>
+  </listitem>
+</varlistentry>
+
+<varlistentry>
   <term><option>sndbuf-size <replaceable>size</replaceable></option></term>
   <listitem><para>
   <replaceable>size</replaceable> is size of the TCP socket send buffer.
@@ -427,35 +508,121 @@
 </varlistentry>
 
 <varlistentry>
-  <term><option>ko-count <replaceable>count</replaceable></option></term>
+  <term><option>allow-two-primaries</option></term>
   <listitem><para>
-  In case the secondary node fails to complete a single write request
-for <replaceable>count</replaceable> times the
-<replaceable>timeout</replaceable>, it is expelled from the cluster.
-(I.e. the primary node goes into StandAlone mode.)
-The default is 0, which disables this feature.
+    With this option set you might make both nodes primary. You only should
+    use this options if you use a shared storage file system on top of
+    DRBD. At the time of writing the only ones are: OCFS2 and GFS. If you
+    use this option with any other filesystem you are goint to crash your
+    nodes and to corrupt your data!
   </para></listitem>
 </varlistentry>
 
 <varlistentry>
-  <term><option>on-disconnect <replaceable>handler</replaceable></option></term>
+  <term><option>cram-hmac-alg</option></term>
   <listitem><para>
-  When the connection to the peer is lost, DRBD can either
-  go into stand alone mode, try to reconnect to the peer or
-  freeze all further IO requests (think of an NFS hard mount).
-  Valid handler specifiers are <option>stand_alone</option>,
-  <option>reconnect</option> and <option>freeze_io</option>.
-  The default handler is <option>reconnect</option>.
-  </para>
-  <para><option>stand_alone</option>: Do not reconnect, go into
-  StandAlone state.</para>
-  <para><option>reconnect</option>: Try to reconnect.</para>
-  <para><option>freeze_io</option>: Try to reconnect, but freeze all
-  IO until the connection is established again.</para>
-  </listitem>
+    You need to specifying the HMAC algorithm to enable peer authentication
+    at all. It is strongly enouraged to use peer authentication. The HMAC
+    algorithm which will be used for the challenge response authentication
+    of the peer. You might specify any digest algorithm that is named in
+    /proc/crypto.
+  </para></listitem>
 </varlistentry>
 
 <varlistentry>
+  <term><option>shared-secret</option></term>
+  <listitem><para>
+    The shared secret used in peer authentication. May be up to 64 characters.
+  </para></listitem>
+</varlistentry>
+
+<varlistentry>
+  <term><option>after-sb-0pri </option><replaceable>policy</replaceable></term>
+	  <listitem>
+	    <para>
+	    possible policies are:
+	    </para>
+            <variablelist>
+              <varlistentry><term><option>disconnect</option></term>
+	        <listitem><para>
+		  No automatic resynchronisation, simply disconnect.
+		</para></listitem></varlistentry>
+	        <varlistentry><term><option>discard-younger-primary</option></term>
+		<listitem><para>
+		  Auto sync from the node that was primary before the split 
+		  brain situation happened.
+		</para></listitem></varlistentry>
+		<varlistentry><term><option>discard-older-primary</option></term> 
+		<listitem><para>
+		Auto sync from the node that became primary as second during 
+		the split brain situation.
+		</para></listitem></varlistentry>
+		<varlistentry><term><option>discard-least-changes</option></term> 
+		<listitem><para>
+		Auto sync from the node that touched more blocks during the 
+		split brain situation.
+		</para></listitem></varlistentry>
+		<varlistentry><term><option>discard-node-NODENAME</option></term> 
+		<listitem><para>
+		Auto sync to the named node.
+		</para></listitem></varlistentry>
+              </variablelist>
+	  </listitem>
+</varlistentry>
+
+<varlistentry>
+  <term><option>after-sb-1pri </option><replaceable>policy</replaceable></term>
+	  <listitem>
+	    <para>
+	    possible policies are:
+	    </para>
+            <variablelist>
+              <varlistentry><term><option>disconnect</option></term>
+	        <listitem><para>
+		  No automatic resynchronisation, simply disconnect.
+		</para></listitem></varlistentry>
+	        <varlistentry><term><option>consensus</option></term>
+		<listitem><para>
+		  Discard the version of the secondary if the outcome
+                  if the <option>after-sb-0pri</option> algorithm would also 
+		  destroy the current secondary's data. Otherwise disconnect.
+		</para></listitem></varlistentry>
+		<varlistentry><term><option>discard-secondary</option></term> 
+		<listitem><para>
+		  Discard the secondary's version.
+		</para></listitem></varlistentry>
+		<varlistentry><term><option>panic-primary</option></term> 
+		<listitem><para>
+		  Always honour the outcome of the <option>after-sb-0pri
+		  </option> algorithm. In case it decides the the current
+		  secondary has the right data, it panics the
+		  current primary.
+		</para></listitem></varlistentry>
+              </variablelist>
+	  </listitem>
+</varlistentry>
+
+<varlistentry>
+  <term><option>after-sb-2pri </option><replaceable>policy</replaceable></term>
+	  <listitem>
+	    <para>
+	    possible policies are:
+	    </para>
+            <variablelist>
+              <varlistentry><term><option>disconnect</option></term>
+	        <listitem><para>
+		  No automatic resynchronisation, simply disconnect.
+		</para></listitem></varlistentry>
+	        <varlistentry><term><option>panic</option></term>
+		<listitem><para>
+		  Honour the outcome of the <option>after-sb-0pri</option> 
+		  policy and panic the other node.
+		</para></listitem></varlistentry>
+              </variablelist>
+	  </listitem>
+</varlistentry>
+
+<varlistentry>
   <term><option>wfc-timeout <replaceable>time</replaceable></option></term>
   <listitem><para>Wait for connection timeout.
   The init script <citerefentry><refentrytitle>drbd</refentrytitle>
@@ -493,13 +660,12 @@
 </varlistentry>
 
 <varlistentry>
-  <term><option>group <replaceable>number</replaceable></option></term>
+  <term><option>after <replaceable>res-name</replaceable></option></term>
   <listitem><para>
-  Resynchronization of all devices in one group runs parallel.
-  Groups are serialized in ascending order. You should avoid,
-  that devices which lower devices share one and the same
-  physical disk sync in parallel. The default group is 0. I.e. per
-  default all devices sync parallel. Negative and positive numbers are allowed.
+  By default resynchronization of all devices would run in parallel. 
+  By defining an sync-after dependency the resynchronisation of this 
+  resource will start only if the resoruce <replaceable>res-name</replaceable>
+  is already in connected state (=finished its resynchronisation).
   </para></listitem>
 </varlistentry>
 
@@ -518,19 +684,32 @@
   127. (Minimum: 7, Maximum: 3843)
   </para>
   </listitem>
-</varlistentry>
 
+<varlistentry>
+  <term><option>pri-on-incon-degr <replaceable>cmd</replaceable></option></term>
+  <listitem><para> This handler is called if the node is primary, degraded
+  and the local copy of the data is inconsistent.</para></listitem>
+  </varlistentry> 
+
+<varlistentry>
+  <term><option>pri-lost-after-sb <replaceable>cmd</replaceable></option></term>
+  <listitem><para> The node is currently primary, but lost the after split
+  brain auto recovery procedure. As as consequence it should go away.
+  </para></listitem> </varlistentry> 
+
+<varlistentry>
+  <term><option>outdate-peer <replaceable>cmd</replaceable></option></term> 
+  <listitem><para> The handler is part of the <option>fencing</option>
+  mechanism.  This handler is called in case the node needs to outdate the
+  peer's disk. It should use other communication pathes then DRBD's network
+  link.  </para></listitem> </varlistentry>
+
 </variablelist>
 </refsect2>
 </refsect1>
 <refsect1>
-<title>Upgrade from DRBD Version 0.6.x</title>
-<simpara>...
-</simpara>
-</refsect1>
-<refsect1>
 <title>Version</title>
-<simpara>This document is correct for version 0.7.15 of the DRBD distribution.
+<simpara>This document was revised version 8.0 of the DRBD distribution.
 </simpara>
 </refsect1>
 <refsect1>

Modified: trunk/documentation/drbdadm.sgml
===================================================================
--- trunk/documentation/drbdadm.sgml	2006-04-06 11:39:24 UTC (rev 2135)
+++ trunk/documentation/drbdadm.sgml	2006-04-06 14:51:31 UTC (rev 2136)
@@ -31,9 +31,9 @@
     <title>Description</title>
     <para>
       Drbdadm is the high level tool of the DRBD program suite. Drbdadm is to 
-      drbdsetup and drbdmeta what ifup/ifdown is to ifconfig. Drbdadm reads its 
-      configuration file and performs the specified commands by calling the drbdsetup 
-      program.
+      drbdsetup and drbdmeta what ifup/ifdown is to ifconfig. Drbdadm reads its
+      configuration file and performs the specified commands by calling the 
+      drbdsetup and/or the drbdmeta program.
     </para>    
   </refsect1>
   <refsect1>
@@ -51,7 +51,7 @@
           <replaceable>file</replaceable></term>
         <listitem><para>
           Specifies the configuration file drbdadm will use. If this parameter
-	  is not specified, drbdadm will look for <option>/etc/drbd-07.conf</option> and
+	  is not specified, drbdadm will look for <option>/etc/drbd-08.conf</option> and
           <option>/etc/drbd.conf</option>.
 	</para></listitem>
       </varlistentry>
@@ -68,7 +68,8 @@
           <replaceable>file</replaceable></term>
         <listitem><para>
           Specifies the full path to the drbdmeta program. If this option is
-	  omitted, drbdadm will look for /sbin/drbdmeta and ./drbdsetup.
+	  omitted, drbdadm will look for <option>/sbin/drbdmeta</option> and 
+	  <option>./drbdsetup</option>.
 	</para></listitem>
       </varlistentry>
     </variablelist>
@@ -232,12 +233,53 @@
 	  be used to check the configuration file for syntactical correctness.
         </para></listitem>
       </varlistentry>
+
+      <varlistentry>
+        <term>outdate</term>
+        <listitem><para>
+          Used to mark the node's data as outdated. Usually used by the
+	  peer's oudate-peer handler.
+        </para></listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>pause-sync</term> 
+        <listitem><para> 
+          Temporarily suspend an ongoing resynchronisation by setting the
+          local pause flag. Resync only progresses if neighter the local
+          nor the remote pause flag is set. It might be desirable to
+          postpone DRBD's resynchronisation after eventual
+          resynchronisation of the backing storage's RAID setup.  
+        </para></listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>resume-sync</term>
+        <listitem><para>
+          Unset the local sync pause flag.
+        </para></listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>dstate</term>
+        <listitem><para>
+  	  Show the current state of the backing storeage devices. (local/peer)
+        </para></listitem>
+      </varlistentry>
+
+      <varlistentry>
+        <term>hidden-commands</term>
+        <listitem><para>
+  	  Shows all on purpose undocumented commands.
+        </para></listitem>
+      </varlistentry>
+
     </variablelist>
   </refsect1>
   <refsect1>
     <title>Version</title>
     <simpara>
-      This document is correct for version 0.7.15 of the DRBD distribution.
+      This document is correct for version 8.0 the DRBD distribution.
     </simpara>
   </refsect1>
 
@@ -270,6 +312,8 @@
       <manvolnum>8</manvolnum></citerefentry>
       <citerefentry><refentrytitle>drbdsetup</refentrytitle>
       <manvolnum>8</manvolnum></citerefentry>
+      <citerefentry><refentrytitle>drbdmeta</refentrytitle>
+      <manvolnum>8</manvolnum></citerefentry>
       <ulink url="http://www.drbd.org/">
       <citetitle>DRBD Homepage</citetitle></ulink>
     </para>

Modified: trunk/documentation/drbdsetup.sgml
===================================================================
--- trunk/documentation/drbdsetup.sgml	2006-04-06 11:39:24 UTC (rev 2135)
+++ trunk/documentation/drbdsetup.sgml	2006-04-06 14:51:31 UTC (rev 2136)
@@ -22,7 +22,8 @@
       <arg choice="req"><replaceable>meta_data_index</replaceable></arg>
       <arg>-d<arg choice="req"><replaceable>size</replaceable></arg></arg>
       <arg>-e<arg choice="req"><replaceable>err_handler</replaceable></arg></arg>
-      <arg>-b</arg>
+      <arg>-f<arg choice="req"><replaceable>fencing_policy</replaceable></arg></arg>
+
     </cmdsynopsis>
     <cmdsynopsis>
       <command>drbdsetup</command>
@@ -160,6 +161,16 @@
       <arg choice="req"><replaceable>device</replaceable></arg>
       <arg choice="req">show</arg>
     </cmdsynopsis>
+    <cmdsynopsis>
+      <command>drbdsetup</command>
+      <arg choice="req"><replaceable>device</replaceable></arg>
+      <arg choice="req">suspend-io</arg>
+    </cmdsynopsis>
+    <cmdsynopsis>
+      <command>drbdsetup</command>
+      <arg choice="req"><replaceable>device</replaceable></arg>
+      <arg choice="req">resume-io</arg>
+    </cmdsynopsis>
   </refsynopsisdiv>
 
   <refsect1>
@@ -233,19 +244,43 @@
 	  </listitem>
 	</varlistentry>
 	<varlistentry>
-	  <term><option>-b</option>,
-	  <option>--split-brain-fix</option></term>
+	  <term><option>-f</option>,
+	  <option>--fencing <replaceable>fencing_policy</replaceable></option></term>
 	  <listitem>
 	    <para>
-	      With that options set a primary node that looses contact to its
-	      its peer tries to outdate the peer. (This communication
-	      may happen over alternative communication pathes, see
-	      the <option>outdate-peer</option> handler). An outdated node
-	      refuses to become primary (although that can be overruled
-	      by an administrator).
-	      This mechanism helps to circumvent after split brain 
-	      situations before they happen.
+	      Under <option>fencing</option> we understand preventative
+	      measures to avoid situations where both nodes are primary
+	      and disconnected (AKA split brain).
 	    </para>
+	    <para>
+	      Valid fencing policies are:
+	    </para>
+
+            <variablelist>
+              <varlistentry><term><option>dont-care</option></term>
+	        <listitem><para>
+		  This is the default policy. No fencing actions are untertaken.
+		</para></listitem></varlistentry>
+	        <varlistentry><term><option>resource-only</option></term>
+		<listitem><para>
+		  If a node becomes a disconnected primary it tries to outdate
+		  the peer's disk. This is done by calling the outdate-peer
+		  handler. The handler is supposed to reach the other node over
+		  alternative communication pathes and call 'drbdadm outdate 
+		  res' there.
+		</para></listitem></varlistentry>
+		<varlistentry><term><option>resource-and-stonith</option></term> 
+		<listitem><para>
+		  If a node becomes a disconnected primary it freezes all
+		  its IO operations and calls its outdate-peer handler. The
+		  outdate-peer hander is supposed to reach the peer over
+		  alternative communicaton pathes and call 'drbdadm outdate 
+		  res' there. In case it can not reach the peer it should
+		  stonith the peer. IO is resumed as soon as the situation
+		  is resolved. In case your handler fails you can resume
+		  IO with the <option>resume-io</option> command.
+		</para></listitem></varlistentry>
+              </variablelist>
 	  </listitem>
 	</varlistentry>
       </variablelist>
@@ -414,7 +449,7 @@
 	</varlistentry>
 	<varlistentry>
 	  <term><option>-A</option>,
-	  <option>--asb-0p-policy </option><replaceable>asb-0p-policy</replaceable></term>
+	  <option>--after-sb-0pri </option><replaceable>asb-0p-policy</replaceable></term>
 	  <listitem>
 	    <para>
 	    possible policies are:
@@ -449,7 +484,7 @@
 
 	<varlistentry>
 	  <term><option>-B</option>,
-	  <option>--asb-1p-policy </option><replaceable>asb-1p-policy</replaceable></term>
+	  <option>--after-sb-1pri </option><replaceable>asb-1p-policy</replaceable></term>
 	  <listitem>
 	    <para>
 	    possible policies are:
@@ -482,7 +517,7 @@
 
 	<varlistentry>
 	  <term><option>-C</option>,
-	  <option>--asb-2p-policy </option><replaceable>asb-2p-policy</replaceable></term>
+	  <option>--after-sb-2pri </option><replaceable>asb-2p-policy</replaceable></term>
 	  <listitem>
 	    <para>
 	    possible policies are:
@@ -737,7 +772,7 @@
       <para>
         Temporarily suspend an ongoing resynchronisation by setting the local
 	pause flag. Resync only progresses if neighter the local nor the
-	remote pause flag is set.It might be desirable to postpone DRBD's 
+	remote pause flag is set. It might be desirable to postpone DRBD's 
 	resynchronisation after eventual resynchronisation of the backing
 	storage's RAID setup.
       </para>
@@ -753,8 +788,7 @@
       <para>
         Mark the data on the local backing storage as outdated. An outdated
 	device refuses to become primary. This is used in conjuction with 
-	<option>split-brain-fix</option> and by the peer's outdate-peer 
-	handler.
+	<option>fencing</option> and by the peer's outdate-peer handler.
       </para>
     </refsect2>
     <refsect2>
@@ -776,6 +810,23 @@
 	<replaceable>device</replaceable>.
       </para>
     </refsect2>
+    <refsect2>
+      <title>suspend-io</title>
+      <para>
+	This command is of no apparent use and just provided for the sake
+	of completeness.
+      </para>
+    </refsect2>
+    <refsect2>
+      <title>resume-io</title>
+      <para>
+	In the the outdate-peer handler fails to stonith the peer node,
+	and your <option>fencing</option> policy is set to
+	resource-and-stonith, you can unfreeze IO operations with this
+	command.
+      </para>
+    </refsect2>
+
   </refsect1>
   <refsect1>
     <title>Examples</title>

From drbd-cvs at lists.linbit.com  Thu Apr  6 18:16:08 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Thu Apr  6 18:16:10 2006
Subject: [DRBD-cvs] svn commit by phil - r2137 - trunk/debian - Imported
	Cyril Bouthors' excellent work on the debain p
Message-ID: <20060406161609.1847015CE6@mail.linbit.com>

Author: phil
Date: 2006-04-06 18:16:07 +0200 (Thu, 06 Apr 2006)
New Revision: 2137

Added:
   trunk/debian/drbd8-module-_KVERS_.postinst.modules.in
   trunk/debian/drbd8-module-source.dirs
   trunk/debian/drbd8-utils.dirs
   trunk/debian/drbd8-utils.postinst
   trunk/debian/drbd8-utils.postrm
   trunk/debian/drbd8-utils.prerm
   trunk/debian/modass.drbd8-module-source
Removed:
   trunk/debian/drbd0.7-module-_KVERS_.postinst.modules.in
   trunk/debian/drbd0.7-module-source.dirs
   trunk/debian/drbd0.7-utils.dirs
   trunk/debian/drbd0.7-utils.docs
   trunk/debian/drbd0.7-utils.postinst
   trunk/debian/drbd0.7-utils.postrm
   trunk/debian/drbd0.7-utils.prerm
   trunk/debian/modass.drbd0.7-module-source
Modified:
   trunk/debian/control
   trunk/debian/control.modules.in
   trunk/debian/rules
Log:
Imported Cyril Bouthors' excellent work on the debain package into
my DRBD repository.


Modified: trunk/debian/control
===================================================================
--- trunk/debian/control	2006-04-06 14:51:31 UTC (rev 2136)
+++ trunk/debian/control	2006-04-06 16:16:07 UTC (rev 2137)
@@ -1,16 +1,16 @@
-Source: drbd
+Source: drbd8
 Section: admin
 Priority: extra
 Maintainer: Cyril Bouthors <cyril@bouthors.org>
 Uploaders: David Krovich <dkrovich@csee.wvu.edu>, Philipp Hug <debian@hug.cx>
 Build-Depends: debhelper (>= 4), debconf-utils, sp, docbook-utils, bison, flex, dpatch
-Standards-Version: 3.6.1
+Standards-Version: 3.6.2.1
 
-Package: drbd0.7-utils
+Package: drbd8-utils
 Architecture: any
 Section: admin
-Depends: debconf
-Conflicts: drbd-utils, drbd
+Depends: debconf | debconf-2.0, ${shlibs:Depends}
+Conflicts: drbd-utils
 Provides: drbd-utils
 Replaces: drbd-utils, drbd
 Suggests: heartbeat
@@ -27,14 +27,14 @@
  .
  Homepage: http://www.drbd.org
 
-Package: drbd0.7-module-source
+Package: drbd8-module-source
 Architecture: all
 Section: admin
 Depends: module-assistant, debhelper (>= 4), dpatch
 Conflicts: drbd-module-source, drbd-source
 Provides: drbd-module-source
 Replaces: drbd-module-source, drbd-source
-Recommends:  dpkg-dev, kernel-package, debhelper (>= 4), debconf-utils
+Recommends:  dpkg-dev, kernel-package, debconf-utils
 Description: RAID 1 over tcp/ip for Linux module source
  Drbd is a block device which is designed to build high availability
  clusters by providing a virtual shared device which keeps disks in

Modified: trunk/debian/control.modules.in
===================================================================
--- trunk/debian/control.modules.in	2006-04-06 14:51:31 UTC (rev 2136)
+++ trunk/debian/control.modules.in	2006-04-06 16:16:07 UTC (rev 2137)
@@ -3,12 +3,12 @@
 Priority: extra
 Maintainer: David Krovich <dkrovich@csee.wvu.edu>
 Uploaders: Philipp Hug <debian@hug.cx>
-Build-Depends: debhelper (>= 4), drbd0.7-source
+Build-Depends: debhelper (>= 4), drbd8-source
 Standards-Version: 3.6.1
 
-Package: drbd0.7-module-_KVERS_
+Package: drbd8-module-_KVERS_
 Architecture: any
-Depends: drbd0.7-utils
+Depends: drbd8-utils
 Conflicts: drbd-module-_KVERS_
 Provides: drbd-module-_KVERS_
 Replaces: drbd-module-_KVERS_
@@ -17,13 +17,14 @@
 Description: RAID 1 over tcp/ip for Linux kernel module
  Drbd is a block device which is designed to build high availability
  clusters by providing a virtual shared device which keeps disks in nodes
- synchronised using TCP/IP. This simulates RAID 1 but avoiding the 
- use of uncommon hardware (shared SCSI buses or Fibre Channel). 
+ synchronised using TCP/IP. This simulates RAID 1 but avoiding the
+ use of uncommon hardware (shared SCSI buses or Fibre Channel).
  It is currently limited to fail-over HA clusters.
  .
- This package contains the drbd kernel module for the following kernel
- version: _KVERS_
- If you want to build drbd against your another kernel, install the
+ This package contains the DRBD kernel module for the kernel version
+ _KVERS_
+ .
+ If you want to build DRBD against your another kernel, install the
  drbd-source package and use module-assistant to create a new
  module package.
  .

Deleted: trunk/debian/drbd0.7-module-_KVERS_.postinst.modules.in
===================================================================
--- trunk/debian/drbd0.7-module-_KVERS_.postinst.modules.in	2006-04-06 14:51:31 UTC (rev 2136)
+++ trunk/debian/drbd0.7-module-_KVERS_.postinst.modules.in	2006-04-06 16:16:07 UTC (rev 2137)
@@ -1,8 +0,0 @@
-#!/bin/sh
-set -e
-
-if [ "`uname -r`" = _KVERS_ ] ; then
-   depmod -a &
-fi
-
-#DEBHELPER#

Deleted: trunk/debian/drbd0.7-module-source.dirs
===================================================================
--- trunk/debian/drbd0.7-module-source.dirs	2006-04-06 14:51:31 UTC (rev 2136)
+++ trunk/debian/drbd0.7-module-source.dirs	2006-04-06 16:16:07 UTC (rev 2137)
@@ -1,3 +0,0 @@
-usr/src/modules/drbd/debian
-usr/src/modules/drbd/drbd
-usr/share/modass/overrides

Deleted: trunk/debian/drbd0.7-utils.dirs
===================================================================
--- trunk/debian/drbd0.7-utils.dirs	2006-04-06 14:51:31 UTC (rev 2136)
+++ trunk/debian/drbd0.7-utils.dirs	2006-04-06 16:16:07 UTC (rev 2137)
@@ -1,3 +0,0 @@
-etc
-etc/init.d
-etc/ha.d/resource.d

Deleted: trunk/debian/drbd0.7-utils.docs
===================================================================
--- trunk/debian/drbd0.7-utils.docs	2006-04-06 14:51:31 UTC (rev 2136)
+++ trunk/debian/drbd0.7-utils.docs	2006-04-06 16:16:07 UTC (rev 2137)
@@ -1,2 +0,0 @@
-upgrade_0.6.x_to_0.7.0.txt
-upgrade_0.7.0_to_0.7.1.txt

Deleted: trunk/debian/drbd0.7-utils.postinst
===================================================================
--- trunk/debian/drbd0.7-utils.postinst	2006-04-06 14:51:31 UTC (rev 2136)
+++ trunk/debian/drbd0.7-utils.postinst	2006-04-06 16:16:07 UTC (rev 2137)
@@ -1,14 +0,0 @@
-#!/bin/sh
-
-if [ -x "/etc/init.d/drbd" ]; then
-	update-rc.d drbd defaults 70 8 >/dev/null
-fi
-
-# Make sure /dev/nb[0-7] devices exist
-# cd /dev; for a in `seq 0 7`; do MAKEDEV nb$a; done
-
-for i in `seq 0 15` ; do 
-    test -b /dev/drbd$i || mknod -m 0660 /dev/drbd$i b 147 $i; 
-done
-
-#DEBHELPER#

Deleted: trunk/debian/drbd0.7-utils.postrm
===================================================================
--- trunk/debian/drbd0.7-utils.postrm	2006-04-06 14:51:31 UTC (rev 2136)
+++ trunk/debian/drbd0.7-utils.postrm	2006-04-06 16:16:07 UTC (rev 2137)
@@ -1,6 +0,0 @@
-#!/bin/sh
-
-if [ "$1" = "purge" ] ; then
-	update-rc.d drbd remove >/dev/null
-fi
-#DEBHELPER#

Deleted: trunk/debian/drbd0.7-utils.prerm
===================================================================
--- trunk/debian/drbd0.7-utils.prerm	2006-04-06 14:51:31 UTC (rev 2136)
+++ trunk/debian/drbd0.7-utils.prerm	2006-04-06 16:16:07 UTC (rev 2137)
@@ -1,30 +0,0 @@
-#!/bin/sh
-
-# This script silently ignores the initscript return code if we remove
-# or deconfigure the package or carefully pay attention to it if we
-# upgrade the package.
-
-# Cyril Bouthors <cyril@bouthors.org>
-# Wed Feb 16 21:01:11 CET 2005
-
-set -e
-
-if [ -x "/etc/init.d/drbd" ]
-then
-    case "$1" in
-	remove|deconfigure)
-	    /etc/init.d/drbd stop || true
-	    ;;
-
-	upgrade|failed-upgrade)
-	    /etc/init.d/drbd stop
-	    ;;
-
-	*)
-	    echo "prerm called with unknown argument \`$1'" >&2
-	    exit 0
-	    ;;
-    esac
-fi
-
-#DEBHELPER#

Copied: trunk/debian/drbd8-module-_KVERS_.postinst.modules.in (from rev 2136, trunk/debian/drbd0.7-module-_KVERS_.postinst.modules.in)

Copied: trunk/debian/drbd8-module-source.dirs (from rev 2136, trunk/debian/drbd0.7-module-source.dirs)

Copied: trunk/debian/drbd8-utils.dirs (from rev 2136, trunk/debian/drbd0.7-utils.dirs)

Copied: trunk/debian/drbd8-utils.postinst (from rev 2136, trunk/debian/drbd0.7-utils.postinst)

Copied: trunk/debian/drbd8-utils.postrm (from rev 2136, trunk/debian/drbd0.7-utils.postrm)

Copied: trunk/debian/drbd8-utils.prerm (from rev 2136, trunk/debian/drbd0.7-utils.prerm)

Deleted: trunk/debian/modass.drbd0.7-module-source
===================================================================
--- trunk/debian/modass.drbd0.7-module-source	2006-04-06 14:51:31 UTC (rev 2136)
+++ trunk/debian/modass.drbd0.7-module-source	2006-04-06 16:16:07 UTC (rev 2137)
@@ -1,16 +0,0 @@
-#!/bin/sh
-#
-# (c) Eduard Bloch <blade@debian.org>, 2003
-# generic maintainer script for module-assistant controled packages
-# to be sourced or copied as example code
-
-# autodetecting values. They may be overriden by the caller.
-
-MA_DIR=${MA_DIR:-/usr/share/modass}
-
-TARBALL=/usr/src/drbd0.7.tar.gz
-BUILDDIR=${MODULE_LOC:-/usr/src/modules}/drbd
-
-. $MA_DIR/packages/generic.sh
-
-$1 "$@"

Copied: trunk/debian/modass.drbd8-module-source (from rev 2136, trunk/debian/modass.drbd0.7-module-source)
===================================================================
--- trunk/debian/modass.drbd0.7-module-source	2006-04-06 14:51:31 UTC (rev 2136)
+++ trunk/debian/modass.drbd8-module-source	2006-04-06 16:16:07 UTC (rev 2137)
@@ -0,0 +1,16 @@
+#!/bin/sh
+#
+# (c) Eduard Bloch <blade@debian.org>, 2003
+# generic maintainer script for module-assistant controled packages
+# to be sourced or copied as example code
+
+# autodetecting values. They may be overriden by the caller.
+
+MA_DIR=${MA_DIR:-/usr/share/modass}
+
+TARBALL=/usr/src/drbd8.tar.gz
+BUILDDIR=${MODULE_LOC:-/usr/src/modules}/drbd
+
+. $MA_DIR/packages/generic.sh
+
+$1 "$@"

Modified: trunk/debian/rules
===================================================================
--- trunk/debian/rules	2006-04-06 14:51:31 UTC (rev 2136)
+++ trunk/debian/rules	2006-04-06 16:16:07 UTC (rev 2137)
@@ -14,7 +14,7 @@
 # This has to be exported to make some magic below work.
 export DH_OPTIONS
 
-PACKAGE=drbd0.7-module
+PACKAGE=drbd8-module
 MA_DIR ?= /usr/share/modass
 -include $(MA_DIR)/include/generic.make
 -include $(MA_DIR)/include/common-rules.make
@@ -83,8 +83,8 @@
 	dh_testroot
 	rm -f build-arch-stamp build-indep-stamp #CONFIGURE-STAMP#
 #	remove these files from upstream tgz
-	rm -f debian/drbd0.7.*
-	rm -f debian/drbd0.7-source.dirs
+	rm -f debian/drbd8.*
+	rm -f debian/drbd8-source.dirs
 	rm -f debian/kernel-patch-wup.kpatches debian/kernel-patch-wup.README.Debian debian/kernel-export-wup.patch
 	-$(MAKE) -C user clean
 	-$(MAKE) -C scripts clean
@@ -103,15 +103,15 @@
 	cp Makefile debian/$(PACKAGE)-source/usr/src/modules/drbd
 	cp drbd/linux/drbd_config.h debian/$(PACKAGE)-source/usr/src/modules/drbd
 	mkdir debian/$(PACKAGE)-source/usr/src/modules/drbd/scripts/
-	cp -a scripts/adjust_drbd_config_h.sh debian/$(PACKAGE)-source/usr/src/modules/drbd/scripts/
+#	cp -a scripts/adjust_drbd_config_h.sh debian/$(PACKAGE)-source/usr/src/modules/drbd/scripts/
 
 #	 install debian/ files
 	cd debian ; cp changelog control compat *.modules.in rules copyright $(PACKAGE)-source/usr/src/modules/drbd/debian
 
 #	 tar the stuff
-	cd debian/$(PACKAGE)-source/usr/src/ ; tar pzfvc drbd0.7.tar.gz modules ; rm -rf modules
+	cd debian/$(PACKAGE)-source/usr/src/ ; tar pzfvc drbd8.tar.gz modules ; rm -rf modules
 
-	install -m 755 $(CURDIR)/debian/modass.drbd0.7-module-source $(CURDIR)/debian/$(PACKAGE)-source/usr/share/modass/overrides/drbd0.7-module-source
+	install -m 755 $(CURDIR)/debian/modass.drbd8-module-source $(CURDIR)/debian/$(PACKAGE)-source/usr/share/modass/overrides/drbd8-module-source
 	dh_install -i
 
 install-arch:
@@ -119,10 +119,10 @@
 	dh_testroot
 	dh_clean -k -s
 	dh_installdirs -s
-	$(MAKE) PREFIX=$(CURDIR)/debian/drbd0.7-utils/ -C user install
-	$(MAKE) PREFIX=$(CURDIR)/debian/drbd0.7-utils/ -C scripts install
-	$(MAKE) PREFIX=$(CURDIR)/debian/drbd0.7-utils/ -C benchmark install
-	$(MAKE) PREFIX=$(CURDIR)/debian/drbd0.7-utils/ -C documentation install
+	$(MAKE) PREFIX=$(CURDIR)/debian/drbd8-utils/ -C user install
+	$(MAKE) PREFIX=$(CURDIR)/debian/drbd8-utils/ -C scripts install
+	$(MAKE) PREFIX=$(CURDIR)/debian/drbd8-utils/ -C benchmark install
+	$(MAKE) PREFIX=$(CURDIR)/debian/drbd8-utils/ -C documentation install
 
 	dh_install -s
 # Must not depend on anything. This is to be called by

From drbd-cvs at lists.linbit.com  Thu Apr  6 18:20:20 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Thu Apr  6 18:20:22 2006
Subject: [DRBD-cvs] svn commit by phil - r2138 - in trunk: . debian
	documentation drbd drbd/linux - Preparing the 8.0-pre2 release 
Message-ID: <20060406162020.C7A2F15CE6@mail.linbit.com>

Author: phil
Date: 2006-04-06 18:20:18 +0200 (Thu, 06 Apr 2006)
New Revision: 2138

Modified:
   trunk/ChangeLog
   trunk/debian/changelog
   trunk/documentation/drbdmeta.sgml
   trunk/drbd.spec.in
   trunk/drbd/drbd_fs.c
   trunk/drbd/linux/drbd_config.h
Log:
Preparing the 8.0-pre2 release


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-04-06 16:16:07 UTC (rev 2137)
+++ trunk/ChangeLog	2006-04-06 16:20:18 UTC (rev 2138)
@@ -1,9 +1,20 @@
 Latest:
 ------
- ChangeLog last updated: r1806 2005-05-23
+ ChangeLog last updated: r2130 2006-04-06
  Cumulative changes since last tarball.
  For even more detail, use "svn log" and "svn diff".
 
+8.0-pre2 (api:81/proto:80)
+--------
+ * removed the "on-disconnect" and "split-brain-fix" config options and
+   added the "fencing" config option instead.
+ * Updated all manpages to cover drbd-8.0
+ * /proc/drbd shows the whole drbd_state_t, as well the logging of state
+   changes shows every field of drbd_state_t now.
+ * Deactivated most of the TCQ code for now, since it changed again
+   in the mainline kernel.
+ * Minor other fixes.
+
 8.0_pre1 (api:80/proto:80)
 --------
  * Removed support for Linux-2.4.x

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	2006-04-06 16:16:07 UTC (rev 2137)
+++ trunk/debian/changelog	2006-04-06 16:20:18 UTC (rev 2138)
@@ -1,3 +1,9 @@
+drbd (8.0-pre2-0) unstable; urgency=low
+
+  * New major release.
+
+ -- Philipp Reisner <phil@linbit.com>  Thu, 6 Apr 2006 17:53:56 +0200
+
 drbd (8.0_pre1-0) unstable; urgency=low
 
   * New major release.

Modified: trunk/documentation/drbdmeta.sgml
===================================================================
--- trunk/documentation/drbdmeta.sgml	2006-04-06 16:16:07 UTC (rev 2137)
+++ trunk/documentation/drbdmeta.sgml	2006-04-06 16:20:18 UTC (rev 2138)
@@ -111,7 +111,7 @@
         <listitem><para>
           Set-gi allows you to set the generation identifier. 
 	  <replaceable>Gi</replaceable> needs to be a generation 
-	  counter for the 0.6 and 0.7 format, and a UUID set for 0.8.
+	  counter for the 0.6 and 0.7 format, and a UUID set for 8.0.
 	  Specify it in the same way as get-gi shows it.
 	</para></listitem>
       </varlistentry>
@@ -128,7 +128,7 @@
   <refsect1>
     <title>Version</title>
     <simpara>
-      This document is correct for version 0.8 of the DRBD distribution.
+      This document is correct for version 8.0 of the DRBD distribution.
     </simpara>
   </refsect1>
 

Modified: trunk/drbd/drbd_fs.c
===================================================================
--- trunk/drbd/drbd_fs.c	2006-04-06 16:16:07 UTC (rev 2137)
+++ trunk/drbd/drbd_fs.c	2006-04-06 16:20:18 UTC (rev 2138)
@@ -838,6 +838,7 @@
 	default:
 		/* The script is broken ... */
 		nps = DUnknown;
+		drbd_request_state(mdev,NS(disk,Outdated));
 		ERR("outdate-peer helper broken, returned %d \n",(r>>8)&0xff);
 		return nps;
 	}

Modified: trunk/drbd/linux/drbd_config.h
===================================================================
--- trunk/drbd/linux/drbd_config.h	2006-04-06 16:16:07 UTC (rev 2137)
+++ trunk/drbd/linux/drbd_config.h	2006-04-06 16:20:18 UTC (rev 2138)
@@ -22,8 +22,8 @@
 
 extern const char * drbd_buildtag(void);
 
-#define REL_VERSION "8.0_pre1"
-#define API_VERSION 80
+#define REL_VERSION "8.0-pre2"
+#define API_VERSION 81
 #define PRO_VERSION 80
 
 // undef if you need the workaround in drbd_receiver

Modified: trunk/drbd.spec.in
===================================================================
--- trunk/drbd.spec.in	2006-04-06 16:16:07 UTC (rev 2137)
+++ trunk/drbd.spec.in	2006-04-06 16:20:18 UTC (rev 2138)
@@ -194,6 +194,17 @@
 
 %changelog
 
+* Tue Apr  6 2006 17:53:56 +0200 Philipp Reisner <phil@linbit.com>
+- drbd (8.0-pre2-1)
+ * removed the "on-disconnect" and "split-brain-fix" config options and
+   added the "fencing" config option instead.
+ * Updated all manpages to cover drbd-8.0
+ * /proc/drbd shows the whole drbd_state_t, as well the logging of state
+   changes shows every field of drbd_state_t now.
+ * Deactivated most of the TCQ code for now, since it changed again
+   in the mainline kernel.
+ * Minor other fixes.
+
 * Tue Mar 14 2006 11:37:56 +0200 Philipp Reisner <phil@linbit.com>
 - drbd (8.0_pre1-1)
  * Removed support for Linux-2.4.x

From drbd-cvs at lists.linbit.com  Thu Apr  6 18:28:41 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Thu Apr  6 18:28:42 2006
Subject: [DRBD-cvs] svn commit by phil - r2139 - trunk - Last pitfall ? 
Message-ID: <20060406162841.9E99015CE6@mail.linbit.com>

Author: phil
Date: 2006-04-06 18:28:41 +0200 (Thu, 06 Apr 2006)
New Revision: 2139

Modified:
   trunk/Makefile
Log:
Last pitfall ?


Modified: trunk/Makefile
===================================================================
--- trunk/Makefile	2006-04-06 16:20:18 UTC (rev 2138)
+++ trunk/Makefile	2006-04-06 16:28:41 UTC (rev 2139)
@@ -37,7 +37,7 @@
 	)-$(shell svnversion .)
 endif
 
-DIST_VERSION := $(subst -,_,$(REL_VERSION))
+DIST_VERSION := $(REL_VERSION)
 FDIST_VERSION := $(shell test -e .filelist && sed -ne 's,^drbd-\([^/]*\)/.*,\1,p;q' < .filelist)
 ifeq ($(FDIST_VERSION),)
 FDIST_VERSION := $(DIST_VERSION)

From drbd-cvs at lists.linbit.com  Thu Apr  6 18:31:56 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Thu Apr  6 18:31:58 2006
Subject: [DRBD-cvs] svn commit by phil - r2140 - tags - Tagging
	drbd-8.0-pre2 
Message-ID: <20060406163156.7454A15CE6@mail.linbit.com>

Author: phil
Date: 2006-04-06 18:31:56 +0200 (Thu, 06 Apr 2006)
New Revision: 2140

Added:
   tags/drbd-8.0-pre2/
Log:
Tagging drbd-8.0-pre2


Copied: tags/drbd-8.0-pre2 (from rev 2139, trunk)

From drbd-cvs at lists.linbit.com  Thu Apr  6 22:35:37 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Thu Apr  6 22:35:40 2006
Subject: [DRBD-cvs] svn commit by phil - r2141 - trunk/user - Reworked the
	format of drbdsetup /dev/drbdX show, in or
Message-ID: <20060406203538.7098F167CD@mail.linbit.com>

Author: phil
Date: 2006-04-06 22:35:37 +0200 (Thu, 06 Apr 2006)
New Revision: 2141

Modified:
   trunk/user/drbdsetup.c
Log:
Reworked the format of drbdsetup /dev/drbdX show, in order
to make a sane implementation of drbdadm adjust possible.


Modified: trunk/user/drbdsetup.c
===================================================================
--- trunk/user/drbdsetup.c	2006-04-06 16:31:56 UTC (rev 2140)
+++ trunk/user/drbdsetup.c	2006-04-06 20:35:37 UTC (rev 2141)
@@ -1309,6 +1309,7 @@
   struct ioctl_get_config cn;
   struct sockaddr_in *other_addr;
   struct sockaddr_in *my_addr;
+  struct stat sb;
   int err;
 
   err=ioctl(drbd_fd,DRBD_IOCTL_GET_CONFIG,&cn);
@@ -1318,86 +1319,103 @@
       return 20;
     }
 
-  if( cn.state.conn == StandAlone && cn.state.disk == Diskless)
-    {
-      printf("Not configured\n");
-      return 0;
-    }
+#define SHOW_I(T,U,M,D) \
+if(M==D) printf("\t# "); \
+else printf("\t"); \
+printf( T "\t%d; # " U "\n",M)
 
+#define SHOW_H(T,M,D,H) \
+if(M==D) printf("\t# "); \
+else printf("\t"); \
+printf( T "\t%s;\n",H[M])
+
   if( cn.state.disk > Diskless)
     {
-
-      printf("Lower device: %02d:%02d   (%s)\n",
-	     cn.lower_device_major,
-	     cn.lower_device_minor,
-	     check_dev_name(cn.lower_device_name,cn.lower_device_major,
-			    cn.lower_device_minor));
-      if( cn.lower_device_major == cn.meta_device_major && 
-	  cn.lower_device_minor == cn.meta_device_minor ) {
-	printf("Meta device: internal\n");
-      } else {
-	printf("Meta device: %02d:%02d   (%s)\n",
-	       cn.meta_device_major,
-	       cn.meta_device_minor,
-	       check_dev_name(cn.meta_device_name,cn.meta_device_major,
-			      cn.meta_device_minor));
-	printf("Meta index: %d\n",cn.meta_index);
-      }
-
-      printf("Disk options:\n");
-      if( cn.disk_size_user ) printf(" size = %lu KB\n",
+      printf("disk {\n");
+      SHOW_H("on-io-error",cn.on_io_error,DEF_ON_IO_ERROR,eh_names);
+      // SHOW_H("fencing",cn.fencing,DEF_FENCING,fencing_names);
+      if( cn.disk_size_user ) printf("\tsize\t%luK;\n",
 				     (unsigned long)cn.disk_size_user);
-      if( cn.on_io_error != DEF_ON_IO_ERROR) {
-	printf(" on-io-error = %s\n",eh_names[cn.on_io_error]);
-      }
-
+      printf("}\n");
     }
 
   if( cn.state.conn > StandAlone)
     {
-      my_addr = (struct sockaddr_in *)cn.nconf.my_addr;
-      other_addr = (struct sockaddr_in *)cn.nconf.other_addr;
-      printf("Local address: %s:%d\n",
-	     inet_ntoa(my_addr->sin_addr),
-	     ntohs(my_addr->sin_port));
-      printf("Remote address: %s:%d\n",
-	     inet_ntoa(other_addr->sin_addr),
-	     ntohs(other_addr->sin_port));
-      printf("Wire protocol: %c\n",'A'-1+cn.nconf.wire_protocol);
-      printf("Net options:\n");
-      printf(" timeout = %d.%d sec %s\n",cn.nconf.timeout/10,cn.nconf.timeout%10,
-	     cn.nconf.timeout == DEF_NET_TIMEOUT ? "(default)" : "" );
-
-#define SHOW_I(T,U,M,D) printf(" " T " = %d " U " %s\n", M, M == D ? "(default)" : "")
-
+      printf("net {\n");
+      SHOW_I("timeout","1/10 seconds",cn.nconf.timeout,DEF_NET_TIMEOUT);
       SHOW_I("connect-int","sec", cn.nconf.try_connect_int, DEF_NET_TRY_CON_I);
       SHOW_I("ping-int","sec", cn.nconf.ping_int, DEF_NET_PING_I);
       SHOW_I("max-epoch-size","", cn.nconf.max_epoch_size, DEF_MAX_EPOCH_SIZE);
       SHOW_I("max-buffers","", cn.nconf.max_buffers, DEF_MAX_BUFFERS);
       SHOW_I("sndbuf-size","", cn.nconf.sndbuf_size, DEF_SNDBUF_SIZE);
       SHOW_I("ko-count","", cn.nconf.ko_count, DEF_KO_COUNT);
-
-#define SHOW_H(T,M,D,H) if( M != D ) { printf(" " T " = %s\n",H[M]); }
       SHOW_H("on-disconnect",cn.nconf.on_disconnect,DEF_ON_DISCONNECT,dh_names);
-
-      if( cn.nconf.two_primaries ) printf(" allow-two-primaries\n");
-
       SHOW_H("after-sb-0pri",cn.nconf.after_sb_0p,DEF_AFTER_SB_0P,asb0p_names);
       SHOW_H("after-sb-1pri",cn.nconf.after_sb_1p,DEF_AFTER_SB_0P,asb1p_names);
       SHOW_H("after-sb-2pri",cn.nconf.after_sb_2p,DEF_AFTER_SB_0P,asb2p_names);
+      if( cn.nconf.two_primaries ) printf("\tallow-two-primaries;\n");
+      if( cn.nconf.want_lose ) printf("\tdiscard-my-data;\n");
+      printf("}\n");
+    }
 
-      if( cn.nconf.want_lose ) printf(" discard-my-data\n");
+  if( cn.state.conn > StandAlone)
+    {
+      printf("syncer {\n");
+      SHOW_I("rate\t","KB/sec", cn.sconf.rate, DEF_SYNC_RATE);
+      SHOW_I("after\t","", cn.sconf.after, DEF_SYNC_AFTER);
+      SHOW_I("al-extents","", cn.sconf.al_extents, DEF_SYNC_AL_EXTENTS);
+      if( cn.sconf.skip ) printf("\tskip-sync;\n");
+      if( cn.sconf.use_csums ) printf("\tuse-csums;\n");
+      printf("}\n");
+    }
 
-      printf("Syncer options:\n");
+  if( cn.state.disk > Diskless || cn.state.conn > StandAlone)
+    {
+      err=fstat(drbd_fd,&sb);
+      if(err)
+	{
+	  PERROR("fstat() failed");
+	  return 20;
+	}
+      printf("on _localhost_ {\n");
+      printf("\tdevice\t\t\"/dev/drbd%d\";\n",minor(sb.st_rdev));
+      printf("\tdisk\t\t\"/dev/%s\"; # (%d:%d)\n",
+	     check_dev_name(cn.lower_device_name,cn.lower_device_major,
+			    cn.lower_device_minor),
+	     cn.lower_device_major,
+	     cn.lower_device_minor);
 
-      SHOW_I("rate","KB/sec", cn.sconf.rate, DEF_SYNC_RATE);
-      SHOW_I("after","", cn.sconf.after, DEF_SYNC_AFTER);
-      SHOW_I("al-extents","", cn.sconf.al_extents, DEF_SYNC_AL_EXTENTS);
+      if( cn.lower_device_major == cn.meta_device_major && 
+	  cn.lower_device_minor == cn.meta_device_minor ) {
+	printf("\tmeta-disk\tinternal;\n");
+      } else {
+	printf("\tmeta-disk\t\"%s\" [%d]; #(%d:%d)\n",
+	       check_dev_name(cn.meta_device_name,cn.meta_device_major,
+			      cn.meta_device_minor),
+	       cn.meta_index,
+	       cn.meta_device_major,
+	       cn.meta_device_minor);
+      }
 
-      if( cn.sconf.skip ) printf(" skip-sync\n");
-      if( cn.sconf.use_csums ) printf(" use-csums\n");
+      if( cn.state.conn > StandAlone) {
+	my_addr = (struct sockaddr_in *)cn.nconf.my_addr;
+	printf("\taddress\t\t%s:%d;\n",
+	       inet_ntoa(my_addr->sin_addr),
+	       ntohs(my_addr->sin_port));
+      }
+      printf("}\n");
     }
 
+  if( cn.state.conn > StandAlone)
+    {
+      other_addr = (struct sockaddr_in *)cn.nconf.other_addr;
+      printf("on _remote_ {\n");
+      printf("\taddress\t%s:%d;\n",
+	     inet_ntoa(other_addr->sin_addr),
+	     ntohs(other_addr->sin_port));
+      printf("}\n");
+    }
+
   return 0;
 }
 

From drbd-cvs at lists.linbit.com  Fri Apr  7 16:37:13 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Fri Apr  7 16:37:14 2006
Subject: [DRBD-cvs] svn commit by phil - r2142 - in trunk: drbd drbd/linux
	user - Small pice of work on the new drbdsetup /dev/drbdX show
Message-ID: <20060407143713.C3CF316190@mail.linbit.com>

Author: phil
Date: 2006-04-07 16:37:12 +0200 (Fri, 07 Apr 2006)
New Revision: 2142

Modified:
   trunk/drbd/drbd_fs.c
   trunk/drbd/drbd_sizeof_sanity_check.c
   trunk/drbd/linux/drbd.h
   trunk/user/drbdsetup.c
Log:
Small pice of work on the new drbdsetup /dev/drbdX show code.


Modified: trunk/drbd/drbd_fs.c
===================================================================
--- trunk/drbd/drbd_fs.c	2006-04-06 20:35:37 UTC (rev 2141)
+++ trunk/drbd/drbd_fs.c	2006-04-07 14:37:12 UTC (rev 2142)
@@ -601,6 +601,7 @@
 		bdevname(mdev->bc->md_bdev,cn.meta_device_name);
 		cn.meta_index=mdev->bc->md_index;
 		cn.on_io_error=mdev->bc->on_io_error;
+		cn.fencing=mdev->bc->fencing;
 		dec_local(mdev);
 	}
 	cn.state=mdev->state;

Modified: trunk/drbd/drbd_sizeof_sanity_check.c
===================================================================
--- trunk/drbd/drbd_sizeof_sanity_check.c	2006-04-06 20:35:37 UTC (rev 2141)
+++ trunk/drbd/drbd_sizeof_sanity_check.c	2006-04-07 14:37:12 UTC (rev 2142)
@@ -18,7 +18,7 @@
 	SZO(struct ioctl_net_config,	456)
 	SZO(struct ioctl_syncer_config,	 32)
 	SZO(struct ioctl_wait,		 16)
-	SZO(struct ioctl_get_config,	576)
+	SZO(struct ioctl_get_config,	580)
 	SZO(struct ioctl_get_uuids,      48)
 	if (err) printk("<3>ioctls won't work, aborting\n");
 	return err;

Modified: trunk/drbd/linux/drbd.h
===================================================================
--- trunk/drbd/linux/drbd.h	2006-04-06 20:35:37 UTC (rev 2141)
+++ trunk/drbd/linux/drbd.h	2006-04-07 14:37:12 UTC (rev 2142)
@@ -290,6 +290,7 @@
 	OUT int               lower_device_major;
 	OUT int               lower_device_minor;
 	OUT enum io_error_handler on_io_error;
+	OUT enum fencing_policy fencing;
 	OUT int               meta_device_major;
 	OUT int               meta_device_minor;
 	OUT int               meta_index;

Modified: trunk/user/drbdsetup.c
===================================================================
--- trunk/user/drbdsetup.c	2006-04-06 20:35:37 UTC (rev 2141)
+++ trunk/user/drbdsetup.c	2006-04-07 14:37:12 UTC (rev 2142)
@@ -1333,7 +1333,7 @@
     {
       printf("disk {\n");
       SHOW_H("on-io-error",cn.on_io_error,DEF_ON_IO_ERROR,eh_names);
-      // SHOW_H("fencing",cn.fencing,DEF_FENCING,fencing_names);
+      SHOW_H("fencing\t",cn.fencing,DEF_FENCING,fencing_names);
       if( cn.disk_size_user ) printf("\tsize\t%luK;\n",
 				     (unsigned long)cn.disk_size_user);
       printf("}\n");
@@ -1341,6 +1341,7 @@
 
   if( cn.state.conn > StandAlone)
     {
+      printf("protocol %c;\n",'A'-1+cn.nconf.wire_protocol);
       printf("net {\n");
       SHOW_I("timeout","1/10 seconds",cn.nconf.timeout,DEF_NET_TIMEOUT);
       SHOW_I("connect-int","sec", cn.nconf.try_connect_int, DEF_NET_TRY_CON_I);

From drbd-cvs at lists.linbit.com  Fri Apr  7 18:21:03 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Fri Apr  7 18:21:04 2006
Subject: [DRBD-cvs] svn commit by phil - r2143 - trunk/user - After more
	thinking about the subject I came to the con
Message-ID: <20060407162103.5F14916190@mail.linbit.com>

Author: phil
Date: 2006-04-07 18:21:02 +0200 (Fri, 07 Apr 2006)
New Revision: 2143

Modified:
   trunk/user/drbdsetup.c
Log:
After more thinking about the subject I came to the conclusion,
that I will need some special keywords for the parser.

These keywords, which are used by drbdsetup's show command
all start with "_" .




Modified: trunk/user/drbdsetup.c
===================================================================
--- trunk/user/drbdsetup.c	2006-04-07 14:37:12 UTC (rev 2142)
+++ trunk/user/drbdsetup.c	2006-04-07 16:21:02 UTC (rev 2143)
@@ -1320,14 +1320,14 @@
     }
 
 #define SHOW_I(T,U,M,D) \
-if(M==D) printf("\t# "); \
-else printf("\t"); \
-printf( T "\t%d; # " U "\n",M)
+printf("\t" T "\t%d",M); \
+if(M==D) printf(" _is_default"); \
+printf(";   # " U "\n")
 
 #define SHOW_H(T,M,D,H) \
-if(M==D) printf("\t# "); \
-else printf("\t"); \
-printf( T "\t%s;\n",H[M])
+printf("\t" T "\t%s",H[M]); \
+if(M==D) printf(" _is_default"); \
+printf(";\n")
 
   if( cn.state.disk > Diskless)
     {
@@ -1343,13 +1343,13 @@
     {
       printf("protocol %c;\n",'A'-1+cn.nconf.wire_protocol);
       printf("net {\n");
-      SHOW_I("timeout","1/10 seconds",cn.nconf.timeout,DEF_NET_TIMEOUT);
-      SHOW_I("connect-int","sec", cn.nconf.try_connect_int, DEF_NET_TRY_CON_I);
-      SHOW_I("ping-int","sec", cn.nconf.ping_int, DEF_NET_PING_I);
-      SHOW_I("max-epoch-size","", cn.nconf.max_epoch_size, DEF_MAX_EPOCH_SIZE);
-      SHOW_I("max-buffers","", cn.nconf.max_buffers, DEF_MAX_BUFFERS);
-      SHOW_I("sndbuf-size","", cn.nconf.sndbuf_size, DEF_SNDBUF_SIZE);
-      SHOW_I("ko-count","", cn.nconf.ko_count, DEF_KO_COUNT);
+      SHOW_I("timeout\t","1/10 seconds",cn.nconf.timeout,DEF_NET_TIMEOUT);
+      SHOW_I("connect-int","seconds", cn.nconf.try_connect_int, DEF_NET_TRY_CON_I);
+      SHOW_I("ping-int","seconds", cn.nconf.ping_int, DEF_NET_PING_I);
+      SHOW_I("max-epoch-size","write requests", cn.nconf.max_epoch_size, DEF_MAX_EPOCH_SIZE);
+      SHOW_I("max-buffers","pages", cn.nconf.max_buffers, DEF_MAX_BUFFERS);
+      SHOW_I("sndbuf-size","byte", cn.nconf.sndbuf_size, DEF_SNDBUF_SIZE);
+      SHOW_I("ko-count","1", cn.nconf.ko_count, DEF_KO_COUNT);
       SHOW_H("on-disconnect",cn.nconf.on_disconnect,DEF_ON_DISCONNECT,dh_names);
       SHOW_H("after-sb-0pri",cn.nconf.after_sb_0p,DEF_AFTER_SB_0P,asb0p_names);
       SHOW_H("after-sb-1pri",cn.nconf.after_sb_1p,DEF_AFTER_SB_0P,asb1p_names);
@@ -1362,9 +1362,9 @@
   if( cn.state.conn > StandAlone)
     {
       printf("syncer {\n");
-      SHOW_I("rate\t","KB/sec", cn.sconf.rate, DEF_SYNC_RATE);
-      SHOW_I("after\t","", cn.sconf.after, DEF_SYNC_AFTER);
-      SHOW_I("al-extents","", cn.sconf.al_extents, DEF_SYNC_AL_EXTENTS);
+      SHOW_I("rate\t","KByte/second", cn.sconf.rate, DEF_SYNC_RATE);
+      SHOW_I("after\t","minor", cn.sconf.after, DEF_SYNC_AFTER);
+      SHOW_I("al-extents","4MByte", cn.sconf.al_extents, DEF_SYNC_AL_EXTENTS);
       if( cn.sconf.skip ) printf("\tskip-sync;\n");
       if( cn.sconf.use_csums ) printf("\tuse-csums;\n");
       printf("}\n");
@@ -1378,9 +1378,9 @@
 	  PERROR("fstat() failed");
 	  return 20;
 	}
-      printf("on _localhost_ {\n");
+      printf("_this_host {\n");
       printf("\tdevice\t\t\"/dev/drbd%d\";\n",minor(sb.st_rdev));
-      printf("\tdisk\t\t\"/dev/%s\"; # (%d:%d)\n",
+      printf("\tdisk\t\t\"/dev/%s\" _major %d _minor %d;\n",
 	     check_dev_name(cn.lower_device_name,cn.lower_device_major,
 			    cn.lower_device_minor),
 	     cn.lower_device_major,
@@ -1390,7 +1390,7 @@
 	  cn.lower_device_minor == cn.meta_device_minor ) {
 	printf("\tmeta-disk\tinternal;\n");
       } else {
-	printf("\tmeta-disk\t\"%s\" [%d]; #(%d:%d)\n",
+	printf("\tmeta-disk\t\"%s\" [%d] _major %d _minor %d;\n",
 	       check_dev_name(cn.meta_device_name,cn.meta_device_major,
 			      cn.meta_device_minor),
 	       cn.meta_index,
@@ -1410,7 +1410,7 @@
   if( cn.state.conn > StandAlone)
     {
       other_addr = (struct sockaddr_in *)cn.nconf.other_addr;
-      printf("on _remote_ {\n");
+      printf("_remote_host {\n");
       printf("\taddress\t%s:%d;\n",
 	     inet_ntoa(other_addr->sin_addr),
 	     ntohs(other_addr->sin_port));

From drbd-cvs at lists.linbit.com  Tue Apr 11 18:18:18 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Tue Apr 11 18:18:20 2006
Subject: [DRBD-cvs] svn commit by phil - r2144 - trunk/user - Finally a
	_sane_ implementation of the "drbdadm adjust"
Message-ID: <20060411161818.DE57A15CE2@mail.linbit.com>

Author: phil
Date: 2006-04-11 18:18:17 +0200 (Tue, 11 Apr 2006)
New Revision: 2144

Modified:
   trunk/user/drbdadm.h
   trunk/user/drbdadm_adjust.c
   trunk/user/drbdadm_main.c
   trunk/user/drbdadm_parser.c
   trunk/user/drbdadm_parser.h
   trunk/user/drbdadm_scanner.fl
   trunk/user/drbdsetup.c
Log:
Finally a _sane_ implementation of the "drbdadm adjust" command.


Modified: trunk/user/drbdadm.h
===================================================================
--- trunk/user/drbdadm.h	2006-04-07 16:21:02 UTC (rev 2143)
+++ trunk/user/drbdadm.h	2006-04-11 16:18:17 UTC (rev 2144)
@@ -53,9 +53,13 @@
   char* name;
   char* device;
   char* disk;
+  int disk_major;
+  int disk_minor;
   char* address;
   char* port;
   char* meta_disk;
+  int meta_major;
+  int meta_minor;
   char* meta_index;
 };
 
@@ -64,7 +68,8 @@
   char* name;
   char* value;
   struct d_option* next;
-  int mentioned; // for the adjust command.
+  unsigned int mentioned  :1 ; // for the adjust command.
+  unsigned int is_default :1 ; // for the adjust command.
 };
 
 struct d_resource
@@ -97,6 +102,8 @@
 
 extern void uc_node(enum usage_count_type type);
 extern int adm_create_md(struct d_resource* res ,const char* cmd);
+extern void convert_discard_opt(struct d_resource* res);
+extern void convert_after_option(struct d_resource* res);
 
 extern char* config_file;
 extern int config_valid;

Modified: trunk/user/drbdadm_adjust.c
===================================================================
--- trunk/user/drbdadm_adjust.c	2006-04-07 16:21:02 UTC (rev 2143)
+++ trunk/user/drbdadm_adjust.c	2006-04-11 16:18:17 UTC (rev 2144)
@@ -28,6 +28,7 @@
 #include <sys/wait.h>
 #include <unistd.h>
 
+#include <ctype.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
@@ -36,312 +37,176 @@
 #include "drbdadm.h"
 #include "drbdtool_common.h"
 
-/******
- This is a bit uggly.
- If you think you are clever, then consider to contribute a nicer
- implementation of adm_adjust()
+extern FILE* yyin;
+extern struct d_resource* parse_resource(char*);
 
-*/
-
-FILE *m_popen(int *pid,char** argv)
+static FILE *m_popen(int *pid,char** argv)
 {
-  int mpid;
-  int pipes[2];
+	int mpid;
+	int pipes[2];
 
-  if(pipe(pipes)) {
-    perror("Creation of pipes failed");
-    exit(E_exec_error);
-  }
+	if(pipe(pipes)) {
+		perror("Creation of pipes failed");
+		exit(E_exec_error);
+	}
 
-  mpid = fork();
-  if(mpid == -1) {
-    fprintf(stderr,"Can not fork");
-    exit(E_exec_error);
-  }
-  if(mpid == 0) {
-    close(pipes[0]); // close reading end
-    dup2(pipes[1],1); // 1 = stdout
-    close(pipes[1]);
-    execvp(argv[0],argv);
-    fprintf(stderr,"Can not exec");
-    exit(E_exec_error);
-  }
+	mpid = fork();
+	if(mpid == -1) {
+		fprintf(stderr,"Can not fork");
+		exit(E_exec_error);
+	}
+	if(mpid == 0) {
+		close(pipes[0]); // close reading end
+		dup2(pipes[1],1); // 1 = stdout
+		close(pipes[1]);
+		execvp(argv[0],argv);
+		fprintf(stderr,"Can not exec");
+		exit(E_exec_error);
+	}
 
-  close(pipes[1]); // close writing end
-  *pid=mpid;
-  return fdopen(pipes[0],"r");
+	close(pipes[1]); // close writing end
+	*pid=mpid;
+	return fdopen(pipes[0],"r");
 }
 
-int check_opt_b(FILE *in,char* name,struct d_option* base)
+/* option value equal? */
+static int ov_eq(char* val1, char* val2)
 {
-  struct d_option* o;
-  char uu[2],scs[200],sn[50];
-  int l,rv=0;
+	unsigned long long v1,v2;
 
-  strcpy(sn,name);
-  l=strlen(sn)-1;
-  sn[l]=0;
-  sprintf(scs," %*s%%[%c]\n",l,sn,name[l]);
+	if(val1 == NULL && val2 == NULL) return 1;
+	if(val1 == NULL || val2 == NULL) return 0;
 
-  if(fscanf(in,scs,uu)>0) {
-    o=find_opt(base,name);
-    if(o) o->mentioned=1;
-    else rv=1;
-  } // else { unexpected input... }
+	if(isdigit(val1[0])) {
+		v1 = m_strtoll(val1,0);
+		v2 = m_strtoll(val2,0);
 
-  //printf("check_opt_b(%s)=%d\n",name,rv);
-  return rv;
+		return v1 == v2;
+	}
+
+	return !strcmp(val1,val2);
 }
 
-int check_opt_d(FILE *in,char* name,char du, char* unit,struct d_option* base)
+static int opts_equal(struct d_option* conf, struct d_option* running)
 {
-  unsigned long  ul;
-  struct d_option* o;
-  char uu[2];
-  char scs[200];
-  int rv=0;
+	struct d_option* opt;
 
-  sprintf(scs," %s = %%lu %s (%%[d]efault)\n",name,unit);
-  if(fscanf(in,scs,&ul,uu)>0) {
-    o=find_opt(base,name);
-    if(o) {
-      o->mentioned=1;
-      if(m_strtoll(o->value,du) != ul) rv=1;
-    } else {
-      if( uu[0] != 'd' ) rv=1;
-    }
-  }
-  //printf("check_opt_d(%s)=%d\n",name,rv);
+	while(running) {
+		if((opt=find_opt(conf,running->name))) {
+			if(!ov_eq(running->value,opt->value)) {
+				/*printf("Value of '%s' differs: r=%s c=%s\n",
+				  opt->name,running->value,opt->value);*/
+				return 0;
+			}
+			opt->mentioned=1;
+		} else {
+			if(!running->is_default) {
+				/*printf("Only in running config %s: %s\n",
+				  running->name,running->value);*/
+				return 0;
+			}
+		}
+		running=running->next;
+	}
 
-  return rv;
+	while(conf) {
+		if(conf->mentioned==0) {
+			/*printf("Only in config file %s: %s\n",
+			  conf->name,conf->value);*/
+			return 0;
+		}
+		conf=conf->next;
+	}
+	return 1;
 }
 
-int check_opt_s(FILE *in,char* name,struct d_option* base)
+static int addr_equal(struct d_resource* conf, struct d_resource* running)
 {
-  struct d_option* o;
-  char scs[200];
-  char value[200];
-  int rv=0;
+	if (conf->peer == NULL && running->peer == NULL) return 1;
+	if (conf->peer == NULL || running->peer == NULL) return 0;
 
-  sprintf(scs," %s = %%s\n",name);
-  if(fscanf(in,scs,value)>0) {
-    o=find_opt(base,name);
-    if(o) {
-      o->mentioned=1;
-      if(strcmp(o->value,value)) rv=1;
-    } else {
-      rv=1;
-    }
-  }
+	return !strcmp(conf->me->address,  running->me->address) &&
+		!strcmp(conf->me->port,     running->me->port) &&
+		!strcmp(conf->peer->address,running->peer->address) &&
+		!strcmp(conf->peer->port,   running->peer->port) ;
+}
 
-  //printf("check_opt_s(%s)=%d [value=%s]\n",name,rv,value);
+static int proto_equal(struct d_resource* conf, struct d_resource* running)
+{
+	if (conf->protocol == NULL && running->protocol == NULL) return 1;
+	if (conf->protocol == NULL || running->protocol == NULL) return 0;
 
-  return rv;
+	return !strcmp(conf->protocol, running->protocol);
 }
 
-int complete(struct d_option* base)
+static int dev_eq(char* device_name, int g_major, int g_minor)
 {
-  int rv=0;
+	struct stat sb;
+	
+	if(stat(device_name,&sb)) return 0;
 
-  while(base) {
-    if(base->mentioned == 0) {
-      //printf("complete(): '%s'\n",base->name);
-      rv=1;
-      break;
-    }
-    base=base->next;
-  }
+	return major(sb.st_rdev) == g_major && minor(sb.st_rdev) == g_minor;
+}
 
-  //printf("complete()=%d\n",rv);
-
-  return rv;
+/* Are both internal, or are both not internal. */
+static int int_eq(char* m_conf, char* m_running)
+{
+	return !strcmp(m_conf,"internal") == !strcmp(m_running,"internal");
 }
 
-int m_fscanf(FILE *stream,const char *fmt, ...)
+static int disk_equal(struct d_host_info* conf, struct d_host_info* running)
 {
-  va_list ap;
-  int rv;
+	int eq = 1;
 
-  va_start(ap, fmt);
-  rv=vfscanf(stream,fmt,ap);
-  va_end(ap);
+	eq &= dev_eq(conf->disk,running->disk_major,running->disk_minor);
+	eq &= int_eq(conf->meta_disk,running->meta_disk);
+	if(!strcmp(conf->meta_disk,"internal")) return eq;
+	eq &= dev_eq(conf->meta_disk,running->meta_major,running->meta_minor);
 
-  if(rv==0) {
-    fprintf(stderr,"fscanf() faild for fmt string: %s\n",fmt);
-  }
-
-  return rv;
+	return eq;
 }
 
-
-/* NOTE
- * return before waitpit is a BUG. "goto out;" instead!
- *
+/*
  * calling drbdsetup again before waitpid("drbdsetup show") has a race with
  * the next ioctl failing because of the zombie still holding an open_cnt on
  * the drbd device. so don't do that.
  */
 int adm_adjust(struct d_resource* res,char* unused __attribute((unused)))
 {
-  char* argv[20];
-  int rv,pid,argc=0;
-  FILE *in;
-  char str1[255],str2[255];
-  unsigned long  ul1,ul2;
-  struct d_option* o;
-  char uu[2];
-  int do_attach=0;
-  int do_resize=0;
-  int do_connect=0;
-  int do_syncer=0;
+	char* argv[20];
+	int pid,argc=0;
+	struct d_resource* running;
+	int do_attach=0;
+	int do_connect=0;
+	int do_syncer=0;
 
-  struct stat sb;
-  int c_major, c_minor;
-  int err = 10;
+	argv[argc++]=drbdsetup;
+	argv[argc++]=res->me->device;
+	argv[argc++]="show";
+	argv[argc++]=0;
 
-  argv[argc++]=drbdsetup;
-  argv[argc++]=res->me->device;
-  argv[argc++]="show";
-  argv[argc++]=0;
+	yyin = m_popen(&pid,argv);
+	line = 1;
+	running = parse_resource("drbdsetup/show");
+	fclose(yyin);
+	waitpid(pid,0,0);
 
-  in=m_popen(&pid,argv);
+	convert_discard_opt(res);
+	convert_after_option(res);
 
-  rv=fscanf(in,"%[Not] configured",str1);
-  if(rv==1 && !strcmp("Not",str1) ) {
-    do_attach=1;
-    do_connect=1;
-    do_syncer=1;
-    goto do_up;
-  }
+	do_attach  = !opts_equal(res->disk_options, running->disk_options);
+	do_attach |= strcmp(res->me->device, running->me->device);
+	do_attach |= !disk_equal(res->me, running->me);
 
-  if (stat(res->me->disk, &sb)) {
-    PERROR("stat '%s' failed:", res->me->device);
-    goto out;
-  }
-  if (!S_ISBLK(sb.st_mode)) {
-    fprintf(stderr, "'%s' not a block device!\n", res->me->disk);
-    goto out;
-  }
-  rv=m_fscanf(in,"Lower device: %d:%d (%*[^)])\n",&c_major,&c_minor);
-  if( (rv!=2) || makedev(c_major,c_minor) != sb.st_rdev) do_attach=1;
+	do_connect  = !opts_equal(res->net_options, running->net_options);
+	do_connect |= !addr_equal(res,running);
+	do_connect |= !proto_equal(res,running);
 
-  if (strcmp("internal", res->me->meta_disk)) {
-    if (stat(res->me->meta_disk, &sb)) {
-      PERROR("stat '%s' failed:", res->me->meta_disk);
-      goto out;
-    }
-    if (!S_ISBLK(sb.st_mode)) {
-      fprintf(stderr, "'%s' not a block device!\n", res->me->disk);
-      goto out;
-    }
-  } else {
-    sb.st_rdev = 0;
-  }
+	do_syncer = !opts_equal(res->sync_options, running->sync_options);
 
-  rv = m_fscanf(in, "Meta device: %s (%[^)])\n", str1, str2);
-  if (rv == 1) {
-    if (!strcmp("internal", str1)) {
-      if (strcmp("internal", res->me->meta_disk))
-	do_attach = 1;
-    } else {
-      fprintf(stderr, "parse error, '%s' read, 'internal' expected\n", str1);
-      goto out;
-    }
-  }
-  if (rv == 2) {
-    sscanf(str1, "%d:%d", &c_major, &c_minor);
-    if ((rv != 2) || makedev(c_major,c_minor) != sb.st_rdev)
-      do_attach = 1;
-    rv = m_fscanf(in, "Meta index: %[0-9]\n", str1);
-    if (rv == 1) {
-      if (strcmp(str1, res->me->meta_index))
-	do_attach = 1;
-    } else {
-      fprintf(stderr, "parse error\n");
-      goto out;
-    }
-  }
+	if(do_attach)  schedule_dcmd(adm_attach,res,0);
+	if(do_syncer)  schedule_dcmd(adm_syncer,res,1);
+	if(do_connect) schedule_dcmd(adm_connect,res,2);
 
-  rv=m_fscanf(in,"Disk options%[:]\n",uu);
-  if(rv==1) {
-    do_resize |= check_opt_d(in,"size",'K',"KB",res->disk_options);
-    do_attach |= check_opt_s(in,"on-io-error",res->disk_options);
-
-    // Check if every options is also present in drbdsetup show's output.
-    o=res->disk_options;
-    while(o) {
-      if(o->mentioned == 0) {
-	if(!strcmp(o->name,"size")) do_resize=1;
-	   else do_attach=1;
-      }
-      o=o->next;
-    }
-  }
-
-  rv=m_fscanf(in,"Local address: %[0-9.]:%s\n",str1,str2);
-  if(rv!=2 || strcmp(str1,res->me->address) || strcmp(str2,res->me->port) ) {
-    do_connect=1;
-  }
-
-  rv=m_fscanf(in,"Remote address: %[0-9.]:%s\n",str1,str2);
-  if(rv!=2 || strcmp(str1,res->peer->address) ||
-     strcmp(str2,res->peer->port) ) {
-    do_connect=1;
-  }
-
-  rv=m_fscanf(in,"Wire protocol: %1[ABC]\n",str1);
-  if(rv!=1 || strcmp(str1,res->protocol) ) {
-    do_connect=1;
-  }
-
-  rv=m_fscanf(in,"Net options%[:]\n",uu);
-  if(rv==1) {
-    rv=m_fscanf(in," timeout = %lu.%lu sec (%[d]efault)\n",&ul1,&ul2,uu);
-    o=find_opt(res->net_options,"timeout");
-    if(o) {
-      o->mentioned=1;
-      if(m_strtoll(o->value,1) != ul1*10 + ul2) do_connect=1;
-    } else {
-      if( uu[0] != 'd' ) do_connect=1;
-    }
-
-    do_connect |= check_opt_d(in,"connect-int",1,"sec",res->net_options);
-    do_connect |= check_opt_d(in,"ping-int",1,"sec",res->net_options);
-    do_connect |= check_opt_d(in,"max-epoch-size",1,"",res->net_options);
-    do_connect |= check_opt_d(in,"max-buffers",1,"",res->net_options);
-    do_connect |= check_opt_d(in,"sndbuf-size",1,"",res->net_options);
-    do_connect |= check_opt_d(in,"ko-count",1,"",res->net_options);
-    do_connect |= check_opt_s(in,"on-disconnect",res->net_options);
-    do_connect |= check_opt_b(in,"allow-two-primaries",res->net_options);
-    do_connect |= complete(res->net_options);
-  }
-
-  rv=m_fscanf(in,"Syncer options%[:]\n",uu);
-  if(rv==1) {
-    do_syncer |= check_opt_d(in,"rate",'K',"KB/sec",res->sync_options);
-    do_syncer |= check_opt_d(in,"group",1,"",res->sync_options);
-    do_syncer |= check_opt_d(in,"al-extents",1,"",res->sync_options);
-    do_syncer |= check_opt_b(in,"skip-sync",res->sync_options);
-    do_syncer |= check_opt_b(in,"use-csums",res->sync_options);
-    do_syncer |= complete(res->sync_options);
-  } else do_syncer=1;
-
- do_up:
-  err = 0;
- out:
-  // drain, close, wait for drbdsetup to "officially die".
-  { static char drain[1024]; while (fgets(drain,1024,in)); }
-  fclose(in);
-  waitpid(pid,0,0);
-  if (err) return err;
-
-  if(do_attach) {
-    schedule_dcmd(adm_attach,res,0);
-    do_resize=0;
-  }
-  if(do_resize)  schedule_dcmd(adm_resize,res,0);
-  if(do_syncer)  schedule_dcmd(adm_syncer,res,1);
-  if(do_connect) schedule_dcmd(adm_connect,res,2);
-
-  return 0;
+	return 0;
 }

Modified: trunk/user/drbdadm_main.c
===================================================================
--- trunk/user/drbdadm_main.c	2006-04-07 16:21:02 UTC (rev 2143)
+++ trunk/user/drbdadm_main.c	2006-04-11 16:18:17 UTC (rev 2144)
@@ -728,6 +728,24 @@
   return rv;
 }
 
+// need to convert discard-node-nodename to discard-local or discard-remote.
+void convert_discard_opt(struct d_resource* res)
+{
+  struct d_option* opt;
+
+  if ( (opt = find_opt(res->net_options, "after-sb-0pri")) ) {
+    if(!strncmp(opt->value,"discard-node-",13)) {
+      if(!strcmp(nodeinfo.nodename,opt->value+13)) {
+	free(opt->value);
+	opt->value=strdup("discard-local");
+      } else {
+	free(opt->value);
+	opt->value=strdup("discard-remote");
+      }
+    }
+  }
+}
+
 int adm_connect(struct d_resource* res,const char* unused __attribute((unused)))
 {
   char* argv[20];
@@ -742,16 +760,7 @@
   ssprintf(argv[argc++],"%s:%s",res->peer->address,res->peer->port);
   argv[argc++]=res->protocol;
 
-  // need to convert discard-node-nodename to discard-local or discard-remote.
-  if ( (opt = find_opt(res->net_options, "after-sb-0pri")) ) {
-    if(!strncmp(opt->value,"discard-node-",13)) {
-      if(!strcmp(nodeinfo.nodename,opt->value+13)) {
-	opt->value=strdup("discard-local");
-      } else {
-	opt->value=strdup("discard-remote");
-      }
-    }
-  }
+  convert_discard_opt(res);
 
   opt=res->net_options;
   make_options(opt);
@@ -767,6 +776,19 @@
 
 struct d_resource* res_by_name(const char *name);
 
+// Need to convert after from resourcename to minor_number.
+void convert_after_option(struct d_resource* res)
+{
+  struct d_option* opt;
+
+  if ( (opt = find_opt(res->sync_options, "after")) ) {
+    char *ptr;
+    ssprintf(ptr,"%d",dt_minor_of_dev(res_by_name(opt->value)->me->device));
+    free(opt->value);
+    opt->value=strdup(ptr);
+  }
+}
+
 int adm_syncer(struct d_resource* res,const char* unused __attribute((unused)))
 {
   char* argv[20];
@@ -777,13 +799,7 @@
   argv[argc++]=res->me->device;
   argv[argc++]="syncer";
 
-  // Need to convert after from resourcename to minor_number.
-  if ( (opt = find_opt(res->sync_options, "after")) ) {
-    char *ptr;
-    ssprintf(ptr,"%d",dt_minor_of_dev(res_by_name(opt->value)->me->device));
-    free(opt->value);
-    opt->value=strdup(ptr);
-  }
+  convert_after_option(res);
 
   opt=res->sync_options;
   make_options(opt);

Modified: trunk/user/drbdadm_parser.c
===================================================================
--- trunk/user/drbdadm_parser.c	2006-04-07 16:21:02 UTC (rev 2143)
+++ trunk/user/drbdadm_parser.c	2006-04-11 16:18:17 UTC (rev 2144)
@@ -157,6 +157,7 @@
 	cn->name=name;
 	cn->value=value;
 	cn->mentioned=0;
+	cn->is_default=0;
 
 	return cn;
 }
@@ -271,7 +272,7 @@
 	int token;
 	enum range_checks rc;
 
-	struct d_option* options = NULL;
+	struct d_option* options = NULL, *ro = NULL;
 
 	EXP('{');
 	while(1) {
@@ -283,40 +284,30 @@
 			rc = yylval.rc;
 			EXP2(TK_STRING,TK_INTEGER);
 			range_check(rc,opt_name,yylval.txt);
-			options = APPEND(options,new_opt(opt_name,yylval.txt));
+			ro = new_opt(opt_name,yylval.txt);
+			options = APPEND(options,ro);
 		} else if ( token == '}' ) {
 			return options;
 		} else {
 			pe_expected("An option keyword");
 		}
-		EXP(';');
+		switch(yylex()) {
+		case TK__IS_DEFAULT:
+			ro->is_default=1;
+			EXP(';');
+			break;
+		case ';':
+			break;
+		default:
+			pe_expected("_is_default | ;");
+		}
 	}
 }
 
-static void parse_host_section(struct d_resource* res)
+static void parse_host_body(struct d_host_info *host, 
+			    struct d_resource* res,
+			    int require_all) 
 {
-	struct d_host_info *host;
-
-	c_section_start = line;
-
-	host=calloc(1,sizeof(struct d_host_info));
-	EXP(TK_STRING);
-	host->name = yylval.txt;
-	if(strcmp(host->name, nodeinfo.nodename) == 0) {
-		res->me = host;
-	} else {
-		if (res->peer) {
-			config_valid = 0;
-			fprintf(stderr,
-		"%s:%d: in resource %s, on %s { ... } ... on %s { ... }:\n"
-		"\tThere are multiple host sections for the peer.\n"
-		"\tMaybe misspelled local host name '%s'?\n",
-				config_file, c_section_start, res->name,
-				res->peer->name, host->name, nodeinfo.nodename);
-		}
-		res->peer = host;
-	}
-
 	EXP('{');
 	while(1) {
 		switch(yylex()) {
@@ -325,12 +316,26 @@
 			host->disk = yylval.txt;
 			check_uniq("disk", "%s:%s:%s","disk",
 				   host->name,yylval.txt);
+			switch(yylex()) {
+			case TK__MAJOR:
+				EXP(TK_INTEGER);
+				host->disk_major = atoi(yylval.txt);
+				EXP(TK__MINOR);
+				EXP(TK_INTEGER);
+				host->disk_minor = atoi(yylval.txt);
+				EXP(';');
+			case ';':
+				break;
+			default:
+				pe_expected("_major | ;");
+			}
 			break;
 		case TK_DEVICE:
 			EXP(TK_STRING);
 			host->device = yylval.txt;
 			check_uniq("device", "%s:%s:%s","device",
 				   host->name,yylval.txt);
+			EXP(';');
 			break;
 		case TK_ADDRESS:
 			EXP(TK_IPADDR);
@@ -339,6 +344,7 @@
 			EXP(TK_INTEGER);
 			host->port = yylval.txt;
 			range_check(R_PORT, "port", yylval.txt);
+			EXP(';');
 			break;
 		case TK_META_DISK:
 			EXP(TK_STRING);
@@ -348,6 +354,21 @@
 				EXP(TK_INTEGER);
 				host->meta_index = yylval.txt;
 				EXP(']');
+				EXP(';');
+			} else {
+				switch(yylex()) {
+				case TK__MAJOR:
+					EXP(TK_INTEGER);
+					host->meta_major = atoi(yylval.txt);
+					EXP(TK__MINOR);
+					EXP(TK_INTEGER);
+					host->meta_minor = atoi(yylval.txt);
+					EXP(';');
+				case ';':
+					break;
+				default:
+					pe_expected("_major | ;");
+				}
 			}
 			check_meta_disk(host);
 			break;
@@ -356,6 +377,7 @@
 			host->meta_disk = yylval.txt;
 			host->meta_index = strdup("flexible");
 			check_meta_disk(host);
+			EXP(';');
 			break;
 		case '}':
 			goto break_loop;
@@ -363,26 +385,69 @@
 			pe_expected("disk | device | address | meta-disk "
 				    "| flex-meta-disk");
 		}
-		EXP(';');
 	}
  break_loop:
+	if (!require_all) return;
 	if (!host->device)	derror(host,res,"device");
 	if (!host->disk)	derror(host,res,"disk");
 	if (!host->address)	derror(host,res,"address");
 	if (!host->meta_disk)	derror(host,res,"meta-disk");
 }
 
+static void parse_host_section(struct d_resource* res)
+{
+	struct d_host_info *host;
+
+	c_section_start = line;
+
+	host=calloc(1,sizeof(struct d_host_info));
+	EXP(TK_STRING);
+	host->name = yylval.txt;
+	if(strcmp(host->name, nodeinfo.nodename) == 0) {
+		res->me = host;
+	} else {
+		if (res->peer) {
+			config_valid = 0;
+			fprintf(stderr,
+		"%s:%d: in resource %s, on %s { ... } ... on %s { ... }:\n"
+		"\tThere are multiple host sections for the peer.\n"
+		"\tMaybe misspelled local host name '%s'?\n",
+				config_file, c_section_start, res->name,
+				res->peer->name, host->name, nodeinfo.nodename);
+		}
+		res->peer = host;
+	}
+	parse_host_body(host,res,1);
+}
+
+static void parse_drbdsetup_host_dump(struct d_resource* res, int local)
+{
+	struct d_host_info *host;
+
+	c_section_start = line;
+
+	host=calloc(1,sizeof(struct d_host_info));
+
+	if(local) {
+		res->me = host;
+	} else {
+		res->peer = host;
+	}
+
+	parse_host_body(host,res,0);
+}
+
 struct d_resource* parse_resource(char* res_name)
 {
 	struct d_resource* res;
+	int token;
 
 	res=calloc(1,sizeof(struct d_resource));
 	res->name = res_name;
 	res->next = NULL;
 
-	EXP('{');
 	while(1) {
-		switch(yylex()) {
+		switch((token=yylex())) {
 		case TK_PROTOCOL:
 			EXP(TK_STRING);
 			res->protocol=yylval.txt;
@@ -391,6 +456,12 @@
 		case TK_ON:
 			parse_host_section(res);
 			break;
+		case TK__THIS_HOST:
+			parse_drbdsetup_host_dump(res, 1);
+			break;
+		case TK__REMOTE_HOST:
+			parse_drbdsetup_host_dump(res, 0);
+			break;
 		case TK_DISK:
 			res->disk_options = parse_options(TK_DISK_SWITCH,
 							  TK_DISK_OPTION);
@@ -411,10 +482,12 @@
 			res->handlers =  parse_options(0,
 						       TK_HANDLER_OPTION);
 			break;
-		case '}': return res;
+		case '}': 
+		case 0:	
+			return res;
 		default:
-			pe_expected("protocol | on | disk | net | syncer |"
-				    " startup | handler");
+			pe_expected_got("protocol | on | disk | net | syncer |"
+					" startup | handler",token);
 		}
 	}
 }
@@ -442,9 +515,13 @@
 	while(1) {
 		switch(yylex()) {
 		case TK_GLOBAL: parse_global(); break;
-		case TK_COMMON: common = parse_resource("common"); break;
+		case TK_COMMON: 
+			EXP('{');
+			common = parse_resource("common"); 
+			break;
 		case TK_RESOURCE: 
 			EXP(TK_STRING);
+			EXP('{');
 			config = APPEND( config , parse_resource(yylval.txt) );
 			break;
 		case TK_SKIP: parse_skip(); break;

Modified: trunk/user/drbdadm_parser.h
===================================================================
--- trunk/user/drbdadm_parser.h	2006-04-07 16:21:02 UTC (rev 2143)
+++ trunk/user/drbdadm_parser.h	2006-04-11 16:18:17 UTC (rev 2144)
@@ -83,7 +83,12 @@
 	TK_USAGE_COUNT,
 	TK_ASK,
 	TK_YES,
-	TK_NO
+	TK_NO,
+	TK__IS_DEFAULT,
+	TK__MAJOR,
+	TK__MINOR,
+	TK__THIS_HOST,
+	TK__REMOTE_HOST
 };
 
 typedef struct YYSTYPE {

Modified: trunk/user/drbdadm_scanner.fl
===================================================================
--- trunk/user/drbdadm_scanner.fl	2006-04-07 16:21:02 UTC (rev 2143)
+++ trunk/user/drbdadm_scanner.fl	2006-04-11 16:18:17 UTC (rev 2144)
@@ -31,7 +31,7 @@
 IPV4ADDR	({SNUMB}"."){3}{SNUMB}
 WS		[ \t]
 OPCHAR		[{};\[\]:]
-DQSTRING	\"[^\"\\\n]{1,255}\"
+DQSTRING	\"[^\"\\\n]{0,255}\"
 STRING		[a-zA-Z0-9/._-]{1,80}
 LONG_STRING	[a-zA-Z0-9/._-]{81}
 
@@ -66,6 +66,11 @@
 meta-disk		{ DP; return TK_META_DISK;		}
 flexible-meta-disk	{ DP; return TK_FLEX_META_DISK;		}
 usage-count 		{ DP; return TK_USAGE_COUNT;		}
+_is_default 		{ DP; return TK__IS_DEFAULT;		}
+_major	 		{ DP; return TK__MAJOR;			}
+_minor	 		{ DP; return TK__MINOR;			}
+_this_host 		{ DP; return TK__THIS_HOST;		}
+_remote_host 		{ DP; return TK__REMOTE_HOST;		}
 size			{ DP; CP; RC(DISK_SIZE); return TK_DISK_OPTION;	}
 on-io-error		{ DP; CP; return TK_DISK_OPTION;	}
 fencing			{ DP; CP; return TK_DISK_OPTION;	}

Modified: trunk/user/drbdsetup.c
===================================================================
--- trunk/user/drbdsetup.c	2006-04-07 16:21:02 UTC (rev 2143)
+++ trunk/user/drbdsetup.c	2006-04-11 16:18:17 UTC (rev 2144)
@@ -1322,13 +1322,28 @@
 #define SHOW_I(T,U,M,D) \
 printf("\t" T "\t%d",M); \
 if(M==D) printf(" _is_default"); \
-printf(";   # " U "\n")
+printf(";  \t# " U "\n")
 
+#define SHOW_IU(T,U1,U2,M,D) \
+printf("\t" T "\t%d",M); \
+if(M==D) printf(" _is_default"); \
+printf(U1";  \t# " U2 "\n")
+
 #define SHOW_H(T,M,D,H) \
 printf("\t" T "\t%s",H[M]); \
 if(M==D) printf(" _is_default"); \
 printf(";\n")
 
+#define SHOW_S(T,M,D) \
+printf("\t" T "\t\"%s\"",M); \
+if(!strcmp(M,D)) printf(" _is_default"); \
+printf(";\n")
+
+  if( cn.state.disk == Diskless && cn.state.conn == StandAlone)
+    {
+      printf("# not configured.\n");
+    }
+
   if( cn.state.disk > Diskless)
     {
       printf("disk {\n");
@@ -1350,10 +1365,12 @@
       SHOW_I("max-buffers","pages", cn.nconf.max_buffers, DEF_MAX_BUFFERS);
       SHOW_I("sndbuf-size","byte", cn.nconf.sndbuf_size, DEF_SNDBUF_SIZE);
       SHOW_I("ko-count","1", cn.nconf.ko_count, DEF_KO_COUNT);
-      SHOW_H("on-disconnect",cn.nconf.on_disconnect,DEF_ON_DISCONNECT,dh_names);
+      // SHOW_H("on-disconnect",cn.nconf.on_disconnect,DEF_ON_DISCONNECT,dh_names);
       SHOW_H("after-sb-0pri",cn.nconf.after_sb_0p,DEF_AFTER_SB_0P,asb0p_names);
       SHOW_H("after-sb-1pri",cn.nconf.after_sb_1p,DEF_AFTER_SB_0P,asb1p_names);
       SHOW_H("after-sb-2pri",cn.nconf.after_sb_2p,DEF_AFTER_SB_0P,asb2p_names);
+      SHOW_S("cram-hmac-alg",cn.nconf.cram_hmac_alg,"");
+      SHOW_S("shared-secret",cn.nconf.shared_secret,"");
       if( cn.nconf.two_primaries ) printf("\tallow-two-primaries;\n");
       if( cn.nconf.want_lose ) printf("\tdiscard-my-data;\n");
       printf("}\n");
@@ -1362,7 +1379,7 @@
   if( cn.state.conn > StandAlone)
     {
       printf("syncer {\n");
-      SHOW_I("rate\t","KByte/second", cn.sconf.rate, DEF_SYNC_RATE);
+      SHOW_IU("rate\t","K","(K)Byte/second", cn.sconf.rate, DEF_SYNC_RATE);
       SHOW_I("after\t","minor", cn.sconf.after, DEF_SYNC_AFTER);
       SHOW_I("al-extents","4MByte", cn.sconf.al_extents, DEF_SYNC_AL_EXTENTS);
       if( cn.sconf.skip ) printf("\tskip-sync;\n");

From drbd-cvs at lists.linbit.com  Thu Apr 13 18:01:02 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Thu Apr 13 18:01:04 2006
Subject: [DRBD-cvs] svn commit by phil - r2145 - in trunk: documentation
	drbd scripts user - * renamed --do-what-I-say to
	--overwrite-data-of-peer
Message-ID: <20060413160102.BB42316BF4@mail.linbit.com>

*
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Author: phil
Date: 2006-04-13 18:01:00 +0200 (Thu, 13 Apr 2006)
New Revision: 2145

Modified:
   trunk/documentation/drbdsetup.sgml
   trunk/drbd/drbd_bitmap.c
   trunk/scripts/drbd
   trunk/user/drbdadm_main.c
   trunk/user/drbdsetup.c
Log:
* renamed --do-what-I-say to --overwrite-data-of-peer
* made sure that config errors or the register as usage.drbd.org
  dialog are displayed when drbd is stared via the /etc/init.d/drbd
  script.
* ko_count was not initialized in drbdsetup. fixed that.


Modified: trunk/documentation/drbdsetup.sgml
===================================================================
--- trunk/documentation/drbdsetup.sgml	2006-04-11 16:18:17 UTC (rev 2144)
+++ trunk/documentation/drbdsetup.sgml	2006-04-13 16:01:00 UTC (rev 2145)
@@ -79,7 +79,7 @@
       <command>drbdsetup</command>
       <arg choice="req"><replaceable>device</replaceable></arg>
       <arg choice="req">primary</arg>
-      <arg>-d</arg>
+      <arg>-o</arg>
     </cmdsynopsis>
     <cmdsynopsis>
       <command>drbdsetup</command>
@@ -628,8 +628,8 @@
       </para>
       <variablelist>
 	<varlistentry>
-	  <term><option>-d</option>,
-	  <option>--do-what-I-say</option></term>
+	  <term><option>-o</option>,
+	  <option>--overwrite-data-of-peer</option></term>
 	  <listitem>
 	    <para>
 	      Becoming primary fails if the local replica is

Modified: trunk/drbd/drbd_bitmap.c
===================================================================
--- trunk/drbd/drbd_bitmap.c	2006-04-11 16:18:17 UTC (rev 2144)
+++ trunk/drbd/drbd_bitmap.c	2006-04-13 16:01:00 UTC (rev 2145)
@@ -366,7 +366,6 @@
 		goto free_obm;
 	} else {
 		bits = BM_SECT_TO_BIT(ALIGN(capacity,BM_SECTORS_PER_BIT));
-		DUMPI(bits);
 
 		/* if we would use
 		   words = ALIGN(bits,BITS_PER_LONG) >> LN2_BPL;

Modified: trunk/scripts/drbd
===================================================================
--- trunk/scripts/drbd	2006-04-11 16:18:17 UTC (rev 2144)
+++ trunk/scripts/drbd	2006-04-13 16:01:00 UTC (rev 2145)
@@ -81,6 +81,12 @@
     IFS=$IFS_O
 }
 
+# Just in case drbdadm want to display any errors in the configuration
+# file, or we need to ask the user about registering this installation
+# at http://usage.drbd.org, we call drbdadm here without any IO 
+# redirection.
+$DRBDADM sh-nop
+
 case "$1" in
     start)
 	echo -n "Starting DRBD resources:    "

Modified: trunk/user/drbdadm_main.c
===================================================================
--- trunk/user/drbdadm_main.c	2006-04-11 16:18:17 UTC (rev 2144)
+++ trunk/user/drbdadm_main.c	2006-04-13 16:01:00 UTC (rev 2145)
@@ -91,6 +91,7 @@
 static int adm_dump(struct d_resource* ,const char* );
 static int adm_wait_c(struct d_resource* ,const char* );
 static int adm_wait_ci(struct d_resource* ,const char* );
+static int sh_nop(struct d_resource* ,const char* );
 static int sh_resources(struct d_resource* ,const char* );
 static int sh_mod_parms(struct d_resource* ,const char* );
 static int sh_dev(struct d_resource* ,const char* );
@@ -205,6 +206,7 @@
   { "dump-md",           admm_generic,  1,1,0 },
   { "wait_con_int",      adm_wait_ci,   1,0,1 },
   { "hidden-commands",   hidden_cmds,   1,0,0 },
+  { "sh-nop",            sh_nop,        2,0,0 },
   { "sh-resources",      sh_resources,  2,0,0 },
   { "sh-mod-parms",      sh_mod_parms,  2,0,0 },
   { "sh-dev",            sh_dev,        2,1,0 },
@@ -323,6 +325,12 @@
   return 0;
 }
 
+static int sh_nop(struct d_resource* ignored __attribute((unused)),
+		  const char* unused __attribute((unused)))
+{
+  return 0;
+}
+
 static int sh_resources(struct d_resource* ignored __attribute((unused)),const char* unused __attribute((unused)))
 {
   struct d_resource *res,*t;

Modified: trunk/user/drbdsetup.c
===================================================================
--- trunk/user/drbdsetup.c	2006-04-11 16:18:17 UTC (rev 2144)
+++ trunk/user/drbdsetup.c	2006-04-13 16:01:00 UTC (rev 2145)
@@ -134,6 +134,7 @@
   {"primary", cmd_primary,           0,
    (struct option[]) {
      { "do-what-I-say",no_argument,     0, 'd' },
+     { "overwrite-data-of-peer",no_argument, 0, 'o' },
      { 0,            0,                 0, 0   } } },
   {"secondary", cmd_secondary,       0, 0, },
   {"wait_sync", cmd_wait_sync,       0,
@@ -529,6 +530,7 @@
   cn->config.after_sb_1p = DEF_AFTER_SB_1P;
   cn->config.after_sb_2p = DEF_AFTER_SB_2P;
   cn->config.want_lose = 0;
+  cn->config.ko_count = DEF_KO_COUNT;
 
   if(argc==0) return 0;
 
@@ -838,14 +840,22 @@
 	  if(c == -1) break;
 	  switch(c)
 	    {
-	    case 'd':
-	      if (strcmp("--do-what-I-say",argv[optind-1])) {
-		      fprintf(stderr,"%s\nYou have to spell out --do-what-I-say, if you mean it\n",
+	    case 'o':
+	      if (strcmp("--overwrite-data-of-peer",argv[optind-1])) {
+		      fprintf(stderr,"%s\nYou have to spell out --overwrite-data-of-peer, if you mean it\n",
 				      argv[optind-1]);
 		      return 20;
 	      }
 	      newstate |= DontBlameDrbd;
 	      break;
+	    case 'd':
+	      fprintf(stderr,
+"--do-what-I-say was renamed to --overwrite-data-of-peer, since that is\n"
+"less ambiguous.\n"
+"Only do it if you really know what you are doing. DRBD is going to save\n"
+"this fact to its metadata, and it will really overwrite the peer's copy\n"
+"of data with the local copy.\n");
+	      return 20;
 	    case 1:	// non option argument. see getopt_long(3)
 	      fprintf(stderr,"%s: Unexpected nonoption argument '%s'\n",cmdname,optarg);
 	    case '?':

From drbd-cvs at lists.linbit.com  Thu Apr 13 18:14:08 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Thu Apr 13 18:14:10 2006
Subject: [DRBD-cvs] svn commit by phil - r2146 - trunk/drbd - Fix
	compilation for these 32/64 bit kernels.. 
Message-ID: <20060413161408.7E7F016BF4@mail.linbit.com>

Author: phil
Date: 2006-04-13 18:14:07 +0200 (Thu, 13 Apr 2006)
New Revision: 2146

Modified:
   trunk/drbd/drbd_main.c
Log:
Fix compilation for these 32/64 bit kernels..


Modified: trunk/drbd/drbd_main.c
===================================================================
--- trunk/drbd/drbd_main.c	2006-04-13 16:01:00 UTC (rev 2145)
+++ trunk/drbd/drbd_main.c	2006-04-13 16:14:07 UTC (rev 2146)
@@ -2201,7 +2201,8 @@
 		drbd_destroy_mempools();
 	}
 
-#if defined(CONFIG_COMPAT)
+#ifndef HAVE_COMPAT_IOCTL_MEMBER
+#if defined(CONFIG_PPC64) || defined(CONFIG_SPARC64) || defined(CONFIG_X86_64)
 	lock_kernel();
 	unregister_ioctl32_conversion(DRBD_IOCTL_GET_VERSION);
 	unregister_ioctl32_conversion(DRBD_IOCTL_SET_STATE);
@@ -2218,7 +2219,7 @@
 	unregister_ioctl32_conversion(DRBD_IOCTL_UNCONFIG_DISK);
 	unlock_kernel();
 #endif
-
+#endif
 	kfree(drbd_conf);
 
 	devfs_remove(drbd_devfs_name);
@@ -2399,7 +2400,8 @@
 # error "Currently drbd depends on the proc file system (CONFIG_PROC_FS)"
 #endif
 
-#if defined(CONFIG_COMPAT)
+#ifndef HAVE_COMPAT_IOCTL_MEMBER
+#if defined(CONFIG_PPC64) || defined(CONFIG_SPARC64) || defined(CONFIG_X86_64)
 	// tell the kernel that we think our ioctls are 64bit clean
 	lock_kernel();
 	register_ioctl32_conversion(DRBD_IOCTL_GET_VERSION,NULL);
@@ -2417,6 +2419,7 @@
 	register_ioctl32_conversion(DRBD_IOCTL_UNCONFIG_DISK,NULL);
 	unlock_kernel();
 #endif
+#endif
 
 	printk(KERN_INFO DEVICE_NAME ": initialised. "
 	       "Version: " REL_VERSION " (api:%d/proto:%d)\n",

From drbd-cvs at lists.linbit.com  Thu Apr 13 18:26:11 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Thu Apr 13 18:26:13 2006
Subject: [DRBD-cvs] svn commit by phil - r2147 - branches/drbd-0.7/scripts -
	Make sure udev creates all devices. 
Message-ID: <20060413162611.C6A4F16C02@mail.linbit.com>

Author: phil
Date: 2006-04-13 18:26:10 +0200 (Thu, 13 Apr 2006)
New Revision: 2147

Modified:
   branches/drbd-0.7/scripts/drbd
Log:
Make sure udev creates all devices.


Modified: branches/drbd-0.7/scripts/drbd
===================================================================
--- branches/drbd-0.7/scripts/drbd	2006-04-13 16:14:07 UTC (rev 2146)
+++ branches/drbd-0.7/scripts/drbd	2006-04-13 16:26:10 UTC (rev 2147)
@@ -41,13 +41,14 @@
     [ -e /var/run/klogd.pid ] && [ -x /sbin/klogd ] && /sbin/klogd -i
 
     # make sure udev has time to create the device files
-    RESOURCE=`$DRBDADM sh-resources` || exit 20
-    RESOURCE=${RESOURCE%%\ *}
-    DEVICE=`$DRBDADM sh-dev $RESOURCE` || exit 20
-
-    while [ ! -e $DEVICE ] && [ $UDEV_TIMEOUT -gt 0 ] ; do
-        sleep 1
-	UDEV_TIMEOUT=$(( $UDEV_TIMEOUT-1 ))
+    for RESOURCE in `$DRBDADM sh-resources`; do
+	for DEVICE in `$DRBDADM sh-dev $RESOURCE`; do
+	    UDEV_TIMEOUT_LOCAL=$UDEV_TIMEOUT
+	    while [ ! -e $DEVICE ] && [ $UDEV_TIMEOUT_LOCAL -gt 0 ] ; do
+		sleep 1
+		UDEV_TIMEOUT_LOCAL=$(( $UDEV_TIMEOUT_LOCAL-1 ))
+	    done
+	done
     done
 }
 

From drbd-cvs at lists.linbit.com  Thu Apr 13 18:28:56 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Thu Apr 13 18:28:57 2006
Subject: [DRBD-cvs] svn commit by phil - r2148 - in trunk: . scripts -
	Propagated a fix to the init script to the trunk 
Message-ID: <20060413162856.A3C2B16BF4@mail.linbit.com>

Author: phil
Date: 2006-04-13 18:28:56 +0200 (Thu, 13 Apr 2006)
New Revision: 2148

Modified:
   trunk/
   trunk/scripts/drbd
Log:
Propagated a fix to the init script to the trunk



Property changes on: trunk
___________________________________________________________________
Name: propagate:at
   - 2117
   + 2147

Modified: trunk/scripts/drbd
===================================================================
--- trunk/scripts/drbd	2006-04-13 16:26:10 UTC (rev 2147)
+++ trunk/scripts/drbd	2006-04-13 16:28:56 UTC (rev 2148)
@@ -41,13 +41,14 @@
     [ -e /var/run/klogd.pid ] && [ -x /sbin/klogd ] && /sbin/klogd -i
 
     # make sure udev has time to create the device files
-    RESOURCE=`$DRBDADM sh-resources` || exit 20
-    RESOURCE=${RESOURCE%%\ *}
-    DEVICE=`$DRBDADM sh-dev $RESOURCE` || exit 20
-
-    while [ ! -e $DEVICE ] && [ $UDEV_TIMEOUT -gt 0 ] ; do
-        sleep 1
-	UDEV_TIMEOUT=$(( $UDEV_TIMEOUT-1 ))
+    for RESOURCE in `$DRBDADM sh-resources`; do
+	for DEVICE in `$DRBDADM sh-dev $RESOURCE`; do
+	    UDEV_TIMEOUT_LOCAL=$UDEV_TIMEOUT
+	    while [ ! -e $DEVICE ] && [ $UDEV_TIMEOUT_LOCAL -gt 0 ] ; do
+		sleep 1
+		UDEV_TIMEOUT_LOCAL=$(( $UDEV_TIMEOUT_LOCAL-1 ))
+	    done
+	done
     done
 }
 

From drbd-cvs at lists.linbit.com  Fri Apr 14 04:04:59 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Fri Apr 14 04:05:00 2006
Subject: [DRBD-cvs] svn commit by phil - r2149 - trunk/benchmark - Now dm is
	able to open files larger than 2G on 32bit sy
Message-ID: <20060414020459.C155A15CE2@mail.linbit.com>

Author: phil
Date: 2006-04-14 04:04:59 +0200 (Fri, 14 Apr 2006)
New Revision: 2149

Modified:
   trunk/benchmark/dm.c
Log:
Now dm is able to open files larger than 2G on 32bit systems,
even on newer systems where one needs to pass O_LARGEFILE
to open(2)


Modified: trunk/benchmark/dm.c
===================================================================
--- trunk/benchmark/dm.c	2006-04-13 16:28:56 UTC (rev 2148)
+++ trunk/benchmark/dm.c	2006-04-14 02:04:59 UTC (rev 2149)
@@ -25,8 +25,8 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/mount.h>
+#define __USE_LARGEFILE64
 #include <fcntl.h>
-#define __USE_LARGEFILE64
 #include <unistd.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -155,7 +155,7 @@
       switch(c)
 	{
 	case 'i': 
-	  in_fd = open(optarg,O_RDONLY);
+	  in_fd = open(optarg,O_RDONLY|O_LARGEFILE);
 	  if(in_fd==-1)
 	    {
 	      fprintf(stderr,"Can not open input file/device\n");

From drbd-cvs at lists.linbit.com  Tue Apr 18 21:43:25 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Tue Apr 18 21:43:26 2006
Subject: [DRBD-cvs] svn commit by phil - r2151 - trunk/user - Two minor
	fixes. * la_size_sect might be 10 digits. * i
Message-ID: <20060418194325.EAD2A16BF5@mail.linbit.com>

Author: phil
Date: 2006-04-18 21:43:24 +0200 (Tue, 18 Apr 2006)
New Revision: 2151

Modified:
   trunk/user/drbdmeta.c
   trunk/user/drbdmeta_scanner.fl
Log:
Two minor fixes.
 * la_size_sect might be 10 digits.
 * in case la_size_sect is change by hand, we need to mmap() big enough.


Modified: trunk/user/drbdmeta.c
===================================================================
--- trunk/user/drbdmeta.c	2006-04-18 17:02:51 UTC (rev 2150)
+++ trunk/user/drbdmeta.c	2006-04-18 19:43:24 UTC (rev 2151)
@@ -799,12 +799,24 @@
 	return ok;
 }
 
-unsigned long bm_words(u64 sectors)
+int int_ln2(int v)
 {
+	int r=0;
+
+	while((v = v>>1)) r++;
+
+	return r;
+}
+
+unsigned long bm_words(u64 sectors, int bytes_per_bit)
+{
 	unsigned long long bits;
 	unsigned long long words;
+	int shift;
 
-	bits = ALIGN(sectors, 8) >> 3;
+	shift = 9 - int_ln2(bytes_per_bit);
+
+	bits = ALIGN(sectors, 8) >> shift;
 	words = ALIGN(bits, 64) >> LN2_BPL;
 
 	return words;
@@ -902,8 +914,13 @@
 
 	cfg->al_offset = cfg->md_offset + cfg->md.al_offset * 512;
 	cfg->bm_offset = cfg->md_offset + cfg->md.bm_offset * 512;
-	cfg->bm_mmaped_length = (u64)(cfg->md.md_size_sect - MD_BM_OFFSET_07)*512;
 
+#define max(x,y) ((x) > (y) ? (x) : (y))
+	// For the case that someone modified la_sect by hand..
+	cfg->bm_mmaped_length = 
+		max((u64)(cfg->md.md_size_sect - MD_BM_OFFSET_07)*512,
+		    (u64)bm_words(cfg->md.la_sect, cfg->md.bm_bytes_per_bit)<<(LN2_BPL-3));
+
 	//fprintf(stderr,"al_offset: "U64" (%d)\n", cfg->al_offset, cfg->md.al_offset);
 	//fprintf(stderr,"bm_offset: "U64" (%d)\n", cfg->bm_offset, cfg->md.bm_offset);
 	//fprintf(stderr,"bm_mmaped_length: %lu\n",(unsigned long)cfg->bm_mmaped_length);
@@ -916,7 +933,7 @@
 	cfg->on_disk.bm = MMAP(cfg->on_disk.bm, cfg->bm_mmaped_length, PROT_READ | PROT_WRITE,
 			       MAP_SHARED, cfg->md_fd, cfg->bm_offset);
 
-	words = bm_words(cfg->md.la_sect);
+	words = bm_words(cfg->md.la_sect, cfg->md.bm_bytes_per_bit);
 	cfg->bm_bytes = words * sizeof(long);
 	cfg->bits_set =
 	    count_bits((const unsigned long *)cfg->on_disk.bm, words);

Modified: trunk/user/drbdmeta_scanner.fl
===================================================================
--- trunk/user/drbdmeta_scanner.fl	2006-04-18 17:02:51 UTC (rev 2150)
+++ trunk/user/drbdmeta_scanner.fl	2006-04-18 19:43:24 UTC (rev 2151)
@@ -16,7 +16,7 @@
 
 WS		[ \t\n]
 COMMENT		\#[^\n]*
-NUM		[0-9]{1,9}
+NUM		[0-9]{1,10}
 U64		0x[0-9A-Fa-f]{16}
 U32		0x[0-9A-Fa-f]{8}
 OP		[{};]

From drbd-cvs at lists.linbit.com  Tue Apr 18 22:05:31 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Tue Apr 18 22:05:33 2006
Subject: [DRBD-cvs] svn commit by phil - r2152 - trunk/user - Fixing the fix
Message-ID: <20060418200531.8A65D16C4E@mail.linbit.com>

Author: phil
Date: 2006-04-18 22:05:31 +0200 (Tue, 18 Apr 2006)
New Revision: 2152

Modified:
   trunk/user/drbdmeta.c
Log:
Fixing the fix 


Modified: trunk/user/drbdmeta.c
===================================================================
--- trunk/user/drbdmeta.c	2006-04-18 19:43:24 UTC (rev 2151)
+++ trunk/user/drbdmeta.c	2006-04-18 20:05:31 UTC (rev 2152)
@@ -814,7 +814,7 @@
 	unsigned long long words;
 	int shift;
 
-	shift = 9 - int_ln2(bytes_per_bit);
+	shift = int_ln2(bytes_per_bit) - 9;
 
 	bits = ALIGN(sectors, 8) >> shift;
 	words = ALIGN(bits, 64) >> LN2_BPL;
@@ -915,11 +915,14 @@
 	cfg->al_offset = cfg->md_offset + cfg->md.al_offset * 512;
 	cfg->bm_offset = cfg->md_offset + cfg->md.bm_offset * 512;
 
+	words = bm_words(cfg->md.la_sect, cfg->md.bm_bytes_per_bit);
+	cfg->bm_bytes = words * sizeof(long);
+
 #define max(x,y) ((x) > (y) ? (x) : (y))
 	// For the case that someone modified la_sect by hand..
 	cfg->bm_mmaped_length = 
 		max((u64)(cfg->md.md_size_sect - MD_BM_OFFSET_07)*512,
-		    (u64)bm_words(cfg->md.la_sect, cfg->md.bm_bytes_per_bit)<<(LN2_BPL-3));
+		    (u64)cfg->bm_bytes);
 
 	//fprintf(stderr,"al_offset: "U64" (%d)\n", cfg->al_offset, cfg->md.al_offset);
 	//fprintf(stderr,"bm_offset: "U64" (%d)\n", cfg->bm_offset, cfg->md.bm_offset);
@@ -933,8 +936,6 @@
 	cfg->on_disk.bm = MMAP(cfg->on_disk.bm, cfg->bm_mmaped_length, PROT_READ | PROT_WRITE,
 			       MAP_SHARED, cfg->md_fd, cfg->bm_offset);
 
-	words = bm_words(cfg->md.la_sect, cfg->md.bm_bytes_per_bit);
-	cfg->bm_bytes = words * sizeof(long);
 	cfg->bits_set =
 	    count_bits((const unsigned long *)cfg->on_disk.bm, words);
 

From drbd-cvs at lists.linbit.com  Tue Apr 18 22:07:41 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Tue Apr 18 22:07:43 2006
Subject: [DRBD-cvs] svn commit by phil - r2153 - trunk/drbd - Fixed the
	bitmap code in case our backing device is a m
Message-ID: <20060418200741.C356C16C4E@mail.linbit.com>

Author: phil
Date: 2006-04-18 22:07:40 +0200 (Tue, 18 Apr 2006)
New Revision: 2153

Modified:
   trunk/drbd/drbd_bitmap.c
Log:
Fixed the bitmap code in case our backing device is a mapping-style
block device, like LVM etc...


Modified: trunk/drbd/drbd_bitmap.c
===================================================================
--- trunk/drbd/drbd_bitmap.c	2006-04-18 20:05:31 UTC (rev 2152)
+++ trunk/drbd/drbd_bitmap.c	2006-04-18 20:07:40 UTC (rev 2153)
@@ -734,6 +734,7 @@
 	int bm_words, num_pages, i;
 	unsigned long now;
 	char ppb[10];
+	request_queue_t *q;
 
 	MUST_BE_LOCKED();
 
@@ -756,8 +757,8 @@
 		/* let the layers below us try to merge these bios... */
 		drbd_bm_page_io_async(mdev,b,i,rw);
 	}
-
-	blk_run_queue(bdev_get_queue(mdev->bc->md_bdev));
+	q=bdev_get_queue(mdev->bc->md_bdev);
+	if(q->request_fn) blk_run_queue(q);
 	wait_event(b->bm_io_wait, atomic_read(&b->bm_async_io) == 0);
 	INFO("%s of bitmap took %lu jiffies\n", 
 	     rw == READ ? "reading" : "writing", jiffies - now);

From drbd-cvs at lists.linbit.com  Wed Apr 19 10:25:48 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Wed Apr 19 10:25:50 2006
Subject: [DRBD-cvs] svn commit by lars - r2154 - trunk/drbd - generically
	resort to drbd_blk_run_queue where we need 
Message-ID: <20060419082548.961F416C04@mail.linbit.com>

Author: lars
Date: 2006-04-19 10:25:47 +0200 (Wed, 19 Apr 2006)
New Revision: 2154

Modified:
   trunk/drbd/drbd_bitmap.c
   trunk/drbd/drbd_compat_wrappers.h
   trunk/drbd/drbd_int.h
Log:
generically resort to drbd_blk_run_queue where we need to kick a lower level block device

Modified: trunk/drbd/drbd_bitmap.c
===================================================================
--- trunk/drbd/drbd_bitmap.c	2006-04-18 20:07:40 UTC (rev 2153)
+++ trunk/drbd/drbd_bitmap.c	2006-04-19 08:25:47 UTC (rev 2154)
@@ -757,8 +757,8 @@
 		/* let the layers below us try to merge these bios... */
 		drbd_bm_page_io_async(mdev,b,i,rw);
 	}
-	q=bdev_get_queue(mdev->bc->md_bdev);
-	if(q->request_fn) blk_run_queue(q);
+
+	drbd_blk_run_queue(bdev_get_queue(mdev->bc->md_bdev));
 	wait_event(b->bm_io_wait, atomic_read(&b->bm_async_io) == 0);
 	INFO("%s of bitmap took %lu jiffies\n", 
 	     rw == READ ? "reading" : "writing", jiffies - now);

Modified: trunk/drbd/drbd_compat_wrappers.h
===================================================================
--- trunk/drbd/drbd_compat_wrappers.h	2006-04-18 20:07:40 UTC (rev 2153)
+++ trunk/drbd/drbd_compat_wrappers.h	2006-04-19 08:25:47 UTC (rev 2154)
@@ -197,20 +197,7 @@
 			dump_stack();
 		}
 	} else {
-		request_queue_t *q;
-		q = bdev_get_queue(mdev->bc->backing_bdev);
-		/*
-		 * FIXME investigate what makes most sense:
-		 * struct backing_dev_info *bdi;
-		 * bdi = mdev->bc->backing_bdev->bd_inode->i_mapping->backing_dev_info;
-		 * bdi = &q->backing_dev_info;
-		 * blk_run_queue(q);
-		 *
-		 * bdi = &q->backing_dev_info;
-		 * blk_run_backing_dev(bdi,NULL);
-		 */
-		if (q && q->unplug_fn)
-			q->unplug_fn(q);
+		drbd_blk_run_queue(bdev_get_queue(mdev->bc->backing_bdev));
 	}
 }
 

Modified: trunk/drbd/drbd_int.h
===================================================================
--- trunk/drbd/drbd_int.h	2006-04-18 20:07:40 UTC (rev 2153)
+++ trunk/drbd/drbd_int.h	2006-04-19 08:25:47 UTC (rev 2154)
@@ -1671,3 +1671,23 @@
 #endif
 	return rv;
 }
+
+/*
+ * FIXME investigate what makes most sense:
+ * a) blk_run_queue(q);
+ *
+ * b) struct backing_dev_info *bdi;
+ *    b1) bdi = &q->backing_dev_info;
+ *    b2) bdi = mdev->bc->backing_bdev->bd_inode->i_mapping->backing_dev_info;
+ *    blk_run_backing_dev(bdi,NULL);
+ *
+ * c) generic_unplug(q) ? __generic_unplug(q) ?
+ *
+ * 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)
+{
+	if (q && q->unplug_fn)
+		q->unplug_fn(q);
+}

From drbd-cvs at lists.linbit.com  Wed Apr 19 10:26:09 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Wed Apr 19 10:26:10 2006
Subject: [DRBD-cvs] svn commit by phil - r2155 - trunk/user - A small
	simplification. 
Message-ID: <20060419082609.E7F5A16C4F@mail.linbit.com>

Author: phil
Date: 2006-04-19 10:26:09 +0200 (Wed, 19 Apr 2006)
New Revision: 2155

Modified:
   trunk/user/drbdmeta.c
Log:
A small simplification.


Modified: trunk/user/drbdmeta.c
===================================================================
--- trunk/user/drbdmeta.c	2006-04-19 08:25:47 UTC (rev 2154)
+++ trunk/user/drbdmeta.c	2006-04-19 08:26:09 UTC (rev 2155)
@@ -799,24 +799,12 @@
 	return ok;
 }
 
-int int_ln2(int v)
-{
-	int r=0;
-
-	while((v = v>>1)) r++;
-
-	return r;
-}
-
 unsigned long bm_words(u64 sectors, int bytes_per_bit)
 {
 	unsigned long long bits;
 	unsigned long long words;
-	int shift;
 
-	shift = int_ln2(bytes_per_bit) - 9;
-
-	bits = ALIGN(sectors, 8) >> shift;
+	bits = ALIGN(sectors, 8) / (bytes_per_bit / 512);
 	words = ALIGN(bits, 64) >> LN2_BPL;
 
 	return words;

From drbd-cvs at lists.linbit.com  Wed Apr 19 10:28:59 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Wed Apr 19 10:28:59 2006
Subject: [DRBD-cvs] svn commit by lars - r2156 - trunk/drbd - moved
	drbd_kick_lo into drbd_int.h
Message-ID: <20060419082859.3D64F16C4B@mail.linbit.com>

Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Author: lars
Date: 2006-04-19 10:28:58 +0200 (Wed, 19 Apr 2006)
New Revision: 2156

Modified:
   trunk/drbd/drbd_bitmap.c
   trunk/drbd/drbd_compat_wrappers.h
   trunk/drbd/drbd_int.h
Log:
moved drbd_kick_lo into drbd_int.h

Modified: trunk/drbd/drbd_bitmap.c
===================================================================
--- trunk/drbd/drbd_bitmap.c	2006-04-19 08:26:09 UTC (rev 2155)
+++ trunk/drbd/drbd_bitmap.c	2006-04-19 08:28:58 UTC (rev 2156)
@@ -734,7 +734,6 @@
 	int bm_words, num_pages, i;
 	unsigned long now;
 	char ppb[10];
-	request_queue_t *q;
 
 	MUST_BE_LOCKED();
 

Modified: trunk/drbd/drbd_compat_wrappers.h
===================================================================
--- trunk/drbd/drbd_compat_wrappers.h	2006-04-19 08:26:09 UTC (rev 2155)
+++ trunk/drbd/drbd_compat_wrappers.h	2006-04-19 08:28:58 UTC (rev 2156)
@@ -189,18 +189,6 @@
 	generic_make_request(bio);
 }
 
-static inline void drbd_kick_lo(drbd_dev *mdev)
-{
-	if (!mdev->bc->backing_bdev) {
-		if (DRBD_ratelimit(5*HZ,5)) {
-			ERR("backing_bdev==NULL in drbd_kick_lo! The following call trace is for debuggin purposes only. Don't worry.\n");
-			dump_stack();
-		}
-	} else {
-		drbd_blk_run_queue(bdev_get_queue(mdev->bc->backing_bdev));
-	}
-}
-
 static inline void drbd_plug_device(drbd_dev *mdev)
 {
 	request_queue_t *q;

Modified: trunk/drbd/drbd_int.h
===================================================================
--- trunk/drbd/drbd_int.h	2006-04-19 08:26:09 UTC (rev 2155)
+++ trunk/drbd/drbd_int.h	2006-04-19 08:28:58 UTC (rev 2156)
@@ -1691,3 +1691,15 @@
 	if (q && q->unplug_fn)
 		q->unplug_fn(q);
 }
+
+static inline void drbd_kick_lo(drbd_dev *mdev)
+{
+	if (!mdev->bc->backing_bdev) {
+		if (DRBD_ratelimit(5*HZ,5)) {
+			ERR("backing_bdev==NULL in drbd_kick_lo! The following call trace is for debuggin purposes only. Don't worry.\n");
+			dump_stack();
+		}
+	} else {
+		drbd_blk_run_queue(bdev_get_queue(mdev->bc->backing_bdev));
+	}
+}

From drbd-cvs at lists.linbit.com  Wed Apr 19 12:38:51 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Wed Apr 19 12:38:53 2006
Subject: [DRBD-cvs] svn commit by phil - r2157 - trunk/user - Still patching
	around this: Can drbdadm resize meta dat
Message-ID: <20060419103851.75CFC16C4B@mail.linbit.com>

Author: phil
Date: 2006-04-19 12:38:50 +0200 (Wed, 19 Apr 2006)
New Revision: 2157

Modified:
   trunk/user/drbdmeta.c
Log:
Still patching around this: Can drbdadm resize meta data,
or can it not resize meta data issue.


Modified: trunk/user/drbdmeta.c
===================================================================
--- trunk/user/drbdmeta.c	2006-04-19 08:28:58 UTC (rev 2156)
+++ trunk/user/drbdmeta.c	2006-04-19 10:38:50 UTC (rev 2157)
@@ -903,14 +903,15 @@
 	cfg->al_offset = cfg->md_offset + cfg->md.al_offset * 512;
 	cfg->bm_offset = cfg->md_offset + cfg->md.bm_offset * 512;
 
+	// For the case that someone modified la_sect by hand..
+	if(cfg->md.la_sect*512 > cfg->md_offset) {
+		printf("la-size-sect was too big, fixed.\n");
+		cfg->md.la_sect = cfg->md_offset/512;
+	}
 	words = bm_words(cfg->md.la_sect, cfg->md.bm_bytes_per_bit);
 	cfg->bm_bytes = words * sizeof(long);
 
-#define max(x,y) ((x) > (y) ? (x) : (y))
-	// For the case that someone modified la_sect by hand..
-	cfg->bm_mmaped_length = 
-		max((u64)(cfg->md.md_size_sect - MD_BM_OFFSET_07)*512,
-		    (u64)cfg->bm_bytes);
+	cfg->bm_mmaped_length=(u64)(cfg->md.md_size_sect-MD_BM_OFFSET_07)*512;
 
 	//fprintf(stderr,"al_offset: "U64" (%d)\n", cfg->al_offset, cfg->md.al_offset);
 	//fprintf(stderr,"bm_offset: "U64" (%d)\n", cfg->bm_offset, cfg->md.bm_offset);

From drbd-cvs at lists.linbit.com  Wed Apr 19 14:16:48 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Wed Apr 19 14:16:50 2006
Subject: [DRBD-cvs] svn commit by phil - r2160 - trunk - Fixed the
	propagation properties 
Message-ID: <20060419121648.ED38716C65@mail.linbit.com>

Author: phil
Date: 2006-04-19 14:16:48 +0200 (Wed, 19 Apr 2006)
New Revision: 2160

Modified:
   trunk/
Log:
Fixed the propagation properties



Property changes on: trunk
___________________________________________________________________
Name: propagate:to
   - /drbd/plus-branches/01-wait-sync-target
   + /drbd/plus-branches/08-10-csums
Name: propagate:at
   - 2147
   + 2158
Name: propagate:lo
   - ../drbd08-p-01
   + ../drbd08-p-10

From drbd-cvs at lists.linbit.com  Thu Apr 20 10:45:38 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Thu Apr 20 10:45:45 2006
Subject: [DRBD-cvs] svn commit by lars - r2168 - trunk/drbd - vmalloced
	space may not be virt_to_pag()ed, but must be
Message-ID: <20060420084544.0A56216C9F@mail.linbit.com>

Author: lars
Date: 2006-04-20 10:45:37 +0200 (Thu, 20 Apr 2006)
New Revision: 2168

Modified:
   trunk/drbd/drbd_bitmap.c
Log:
vmalloced space may not be virt_to_pag()ed, but must be vmalloc_to_page()ed,
thanks to Ard van Breemen

Modified: trunk/drbd/drbd_bitmap.c
===================================================================
--- trunk/drbd/drbd_bitmap.c	2006-04-19 12:55:09 UTC (rev 2167)
+++ trunk/drbd/drbd_bitmap.c	2006-04-20 08:45:37 UTC (rev 2168)
@@ -633,7 +633,7 @@
 	/* we are process context. we always get a bio */
 	/* THINK: do we need GFP_NOIO here? */
 	struct bio *bio = bio_alloc(GFP_KERNEL, 1);
-	struct page *page = virt_to_page((char*)(b->bm) + (PAGE_SIZE*page_nr));
+	struct page *page = vmalloc_to_page((char*)(b->bm) + (PAGE_SIZE*page_nr));
 	unsigned int len;
 	sector_t on_disk_sector = mdev->bc->md.md_offset + mdev->bc->md.bm_offset;
 	on_disk_sector += ((sector_t)page_nr) << (PAGE_SHIFT-9);

From drbd-cvs at lists.linbit.com  Thu Apr 20 13:46:27 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Thu Apr 20 13:46:28 2006
Subject: [DRBD-cvs] svn commit by phil - r2169 - in trunk: . debian
	drbd/linux scripts - preparing 8.0pre3 
Message-ID: <20060420114628.0F45915EC2@mail.linbit.com>

Author: phil
Date: 2006-04-20 13:46:26 +0200 (Thu, 20 Apr 2006)
New Revision: 2169

Modified:
   trunk/ChangeLog
   trunk/debian/changelog
   trunk/drbd.spec.in
   trunk/drbd/linux/drbd_config.h
   trunk/scripts/drbd.conf
Log:
preparing 8.0pre3


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2006-04-20 08:45:37 UTC (rev 2168)
+++ trunk/ChangeLog	2006-04-20 11:46:26 UTC (rev 2169)
@@ -4,6 +4,16 @@
  Cumulative changes since last tarball.
  For even more detail, use "svn log" and "svn diff".
 
+8.0pre3 (api:82/proto:80)
+--------
+ * Now it works on device mapper (LVM) as well as on "real" block devices.
+ * Finally (after years) a sane "drbdadm adjust" imprementation, which is
+   really really robust.
+ * Fixes for 64bit kernel / 32 bit userland environments
+ * Fixes in the sys-v init script
+ * Renamed "--do-what-I-say" to "--overwrite-data-of-peer". Hopefully
+   people now understand what this option does. 
+
 8.0-pre2 (api:81/proto:80)
 --------
  * removed the "on-disconnect" and "split-brain-fix" config options and

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	2006-04-20 08:45:37 UTC (rev 2168)
+++ trunk/debian/changelog	2006-04-20 11:46:26 UTC (rev 2169)
@@ -1,3 +1,9 @@
+drbd (8.0pre3-0) unstable; urgency=low
+
+  * New major release.
+
+ -- Philipp Reisner <phil@linbit.com>  Thu, 20 Apr 2006 13:46:18 +0200
+
 drbd (8.0-pre2-0) unstable; urgency=low
 
   * New major release.

Modified: trunk/drbd/linux/drbd_config.h
===================================================================
--- trunk/drbd/linux/drbd_config.h	2006-04-20 08:45:37 UTC (rev 2168)
+++ trunk/drbd/linux/drbd_config.h	2006-04-20 11:46:26 UTC (rev 2169)
@@ -22,8 +22,8 @@
 
 extern const char * drbd_buildtag(void);
 
-#define REL_VERSION "8.0-pre2"
-#define API_VERSION 81
+#define REL_VERSION "8.0pre3"
+#define API_VERSION 82
 #define PRO_VERSION 80
 
 // undef if you need the workaround in drbd_receiver

Modified: trunk/drbd.spec.in
===================================================================
--- trunk/drbd.spec.in	2006-04-20 08:45:37 UTC (rev 2168)
+++ trunk/drbd.spec.in	2006-04-20 11:46:26 UTC (rev 2169)
@@ -194,6 +194,16 @@
 
 %changelog
 
+* Tue Apr 20 2006 13:46:18 +0200 Philipp Reisner <phil@linbit.com>
+- drbd (8.0pre3-1)
+ * Now it works on device mapper (LVM) as well as on "real" block devices.
+ * Finally (after years) a sane "drbdadm adjust" imprementation, which is
+   really really robust.
+ * Fixes for 64bit kernel / 32 bit userland environments
+ * Fixes in the sys-v init script
+ * Renamed "--do-what-I-say" to "--overwrite-data-of-peer". Hopefully
+   people now understand what this option does. 
+
 * Tue Apr  6 2006 17:53:56 +0200 Philipp Reisner <phil@linbit.com>
 - drbd (8.0-pre2-1)
  * removed the "on-disconnect" and "split-brain-fix" config options and

Modified: trunk/scripts/drbd.conf
===================================================================
--- trunk/scripts/drbd.conf	2006-04-20 08:45:37 UTC (rev 2168)
+++ trunk/scripts/drbd.conf	2006-04-20 11:46:26 UTC (rev 2169)
@@ -87,8 +87,8 @@
 
     # Participate in DRBD's online usage counter at http://usage.drbd.org
     # possilbe options: ask, yes, no. Default is ask. In case you do not
-    # know, leave it at ask, and follow the on screen instructions later.
-    # usage-count ask;
+    # know, set it to ask, and follow the on screen instructions later.
+    usage-count yes;
 # }
 
 

From drbd-cvs at lists.linbit.com  Thu Apr 20 13:48:43 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Thu Apr 20 13:48:45 2006
Subject: [DRBD-cvs] svn commit by phil - r2170 - tags - Tagging drbd-8.0pre3
Message-ID: <20060420114843.E25EA15EC2@mail.linbit.com>

Author: phil
Date: 2006-04-20 13:48:43 +0200 (Thu, 20 Apr 2006)
New Revision: 2170

Added:
   tags/drbd-8.0pre3/
Log:
Tagging drbd-8.0pre3


Copied: tags/drbd-8.0pre3 (from rev 2169, trunk)

From drbd-cvs at lists.linbit.com  Mon Apr 24 13:55:12 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Mon Apr 24 13:55:14 2006
Subject: [DRBD-cvs] svn commit by phil - r2171 - branches/drbd-0.7/drbd -
	This patch finally fixes the connect/disconnect loop we
Message-ID: <20060424115512.DC78B16BF5@mail.linbit.com>

Author: phil
Date: 2006-04-24 13:55:12 +0200 (Mon, 24 Apr 2006)
New Revision: 2171

Modified:
   branches/drbd-0.7/drbd/drbd_receiver.c
Log:
This patch finally fixes the connect/disconnect loop we had.

  In case the connection set-up of the msock takes longer
  than connect-int we came into a stable connect/disconnect
  loop. 
  Now the code recognises this and wait on one side long
  enough to break out of this loop.




Modified: branches/drbd-0.7/drbd/drbd_receiver.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_receiver.c	2006-04-20 11:48:43 UTC (rev 2170)
+++ branches/drbd-0.7/drbd/drbd_receiver.c	2006-04-24 11:55:12 UTC (rev 2171)
@@ -707,6 +707,10 @@
 
 	set_cstate(mdev,WFConnection);
 
+	/* Break out of unknown connect loops by random wait here. */
+	set_current_state(TASK_INTERRUPTIBLE);
+	schedule_timeout(net_random() % ((mdev->conf.try_connect_int*HZ)/4));
+
 	while(1) {
 		sock=drbd_try_connect(mdev);
 		if(sock) {
@@ -1988,10 +1992,10 @@
 	int rv;
 
 	rv = drbd_send_handshake(mdev);
-	if (!rv) return 0;
+	if (!rv) goto break_c_loop;
 
 	rv = drbd_recv_header(mdev,&p->head);
-	if (!rv) return 0;
+	if (!rv) goto break_c_loop;
 
 	if (p->head.command == ReportParams) {
 		ERR("expected HandShake packet, received ReportParams...\n");
@@ -2042,6 +2046,23 @@
 	}
 
 	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->conf.try_connect_int*HZ)/2);
+	
+	return 0;
 }
 
 int drbdd_init(struct Drbd_thread *thi)

From drbd-cvs at lists.linbit.com  Mon Apr 24 14:40:31 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Mon Apr 24 14:40:33 2006
Subject: [DRBD-cvs] svn commit by lars - r2172 - branches/drbd-0.7/drbd -
	GFP_KERNEL -> GFP_NOIO at two more places
Message-ID: <20060424124031.77A2B16BF5@mail.linbit.com>

Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Author: lars
Date: 2006-04-24 14:40:29 +0200 (Mon, 24 Apr 2006)
New Revision: 2172

Modified:
   branches/drbd-0.7/drbd/drbd_actlog.c
   branches/drbd-0.7/drbd/drbd_main.c
Log:
GFP_KERNEL -> GFP_NOIO at two more places

Modified: branches/drbd-0.7/drbd/drbd_actlog.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_actlog.c	2006-04-24 11:55:12 UTC (rev 2171)
+++ branches/drbd-0.7/drbd/drbd_actlog.c	2006-04-24 12:40:29 UTC (rev 2172)
@@ -112,7 +112,7 @@
 	// in case hardsect != 512 [ s390 only? ]
 	if( hardsect != MD_HARDSECT ) {
 		if(!mdev->md_io_tmpp) {
-			struct page *page = alloc_page(GFP_KERNEL);
+			struct page *page = alloc_page(GFP_NOIO);
 			if(!page) return 0;
 
 			WARN("Meta data's bdev hardsect_size != %d\n",

Modified: branches/drbd-0.7/drbd/drbd_main.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_main.c	2006-04-24 11:55:12 UTC (rev 2171)
+++ branches/drbd-0.7/drbd/drbd_main.c	2006-04-24 12:40:29 UTC (rev 2172)
@@ -322,7 +322,7 @@
 	sector_t sector;
 	unsigned int size;
 
-	new_first=kmalloc(sizeof(struct drbd_barrier),GFP_KERNEL);
+	new_first=kmalloc(sizeof(struct drbd_barrier),GFP_NOIO);
 	if(!new_first) {
 		ERR("could not kmalloc() barrier\n");
 	}

From drbd-cvs at lists.linbit.com  Tue Apr 25 11:45:04 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Tue Apr 25 11:45:06 2006
Subject: [DRBD-cvs] svn commit by phil - r2173 - in branches/drbd-0.7/drbd:
	. linux - Better handling of IO errors while reading the activity
Message-ID: <20060425094504.B859A14CC6@mail.linbit.com>

Author: phil
Date: 2006-04-25 11:45:03 +0200 (Tue, 25 Apr 2006)
New Revision: 2173

Modified:
   branches/drbd-0.7/drbd/drbd_actlog.c
   branches/drbd-0.7/drbd/drbd_fs.c
   branches/drbd-0.7/drbd/drbd_int.h
   branches/drbd-0.7/drbd/linux/drbd.h
   branches/drbd-0.7/drbd/linux/drbd_config.h
Log:
Better handling of IO errors while reading the activity log. (attach)


Modified: branches/drbd-0.7/drbd/drbd_actlog.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_actlog.c	2006-04-24 12:40:29 UTC (rev 2172)
+++ branches/drbd-0.7/drbd/drbd_actlog.c	2006-04-25 09:45:03 UTC (rev 2173)
@@ -368,6 +368,12 @@
 	return 1;
 }
 
+/**
+ * drbd_al_read_tr: Reads a single transaction record form the 
+ * on disk activity log.
+ * Returns -1 on IO error, 0 on checksum error and 1 if it is a valid
+ * record.
+ */
 STATIC int drbd_al_read_tr(struct Drbd_Conf *mdev,
 			   struct al_transaction* b,
 			   int index)
@@ -381,7 +387,7 @@
 	if(!drbd_md_sync_page_io(mdev,sector,READ)) {
 		drbd_chk_io_error(mdev, 1);
 		drbd_io_error(mdev);
-		return 0;
+		return -1;
 	}
 
 	rv = ( be32_to_cpu(b->magic) == DRBD_MAGIC );
@@ -394,7 +400,12 @@
 	return rv;
 }
 
-void drbd_al_read_log(struct Drbd_Conf *mdev)
+/**
+ * drbd_al_read_log: Restores the activity log from its on disk
+ * representation. Returns 1 on success, returns 0 when 
+ * reading the log failed due to IO errors.
+ */
+int drbd_al_read_log(struct Drbd_Conf *mdev)
 {
 	struct al_transaction* buffer;
 	int from=-1,to=-1,i,cnr, overflow=0,rv;
@@ -413,7 +424,12 @@
 
 	// Find the valid transaction in the log
 	for(i=0;i<=mx;i++) {
-		if(!drbd_al_read_tr(mdev,buffer,i)) continue;
+		rv = drbd_al_read_tr(mdev,buffer,i);
+		if(rv == 0) continue;
+		if(rv == -1) {
+			up(&mdev->md_io_mutex);
+			return 0;
+		}
 		cnr = be32_to_cpu(buffer->tr_number);
 		// INFO("index %d valid tnr=%d\n",i,cnr);
 
@@ -433,7 +449,7 @@
 		WARN("No usable activity log found.\n");
 
 		up(&mdev->md_io_mutex);
-		return;
+		return 1;
 	}
 
 	// Read the valid transactions.
@@ -448,7 +464,11 @@
 		unsigned int trn;
 
 		rv = drbd_al_read_tr(mdev,buffer,i);
-		ERR_IF(!rv) goto cancel;
+		ERR_IF(rv == 0) goto cancel;
+		if(rv == -1) {
+			up(&mdev->md_io_mutex);
+			return 0;
+		}
 
 		trn=be32_to_cpu(buffer->tr_number);
 
@@ -489,6 +509,8 @@
 
 	INFO("Found %d transactions (%d active extents) in activity log.\n",
 	     transactions,active_extents);
+
+	return 1;
 }
 
 /**

Modified: branches/drbd-0.7/drbd/drbd_fs.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_fs.c	2006-04-24 12:40:29 UTC (rev 2172)
+++ branches/drbd-0.7/drbd/drbd_fs.c	2006-04-25 09:45:03 UTC (rev 2173)
@@ -567,11 +567,20 @@
 	}
 
 	if (md_gc_valid > 0) {
-		drbd_al_read_log(mdev);
-		if (apply_al) {
+		i = drbd_al_read_log(mdev);
+		if (apply_al && i) {
 			drbd_al_apply_to_bm(mdev);
 			drbd_al_to_on_disk_bm(mdev);
 		}
+		if(!i) {
+			ERR("IO error on meta device while reading AL\n");
+			drbd_free_ll_dev(mdev);
+			set_cstate(mdev,Unconfigured);
+			retcode = MDIOError;
+			module_put(THIS_MODULE);
+			if (put_user(retcode, &arg->ret_code)) return -EFAULT;
+			return -EINVAL;
+		}
 	} /* else {
 	     FIXME wipe out on disk al!
 	} */

Modified: branches/drbd-0.7/drbd/drbd_int.h
===================================================================
--- branches/drbd-0.7/drbd/drbd_int.h	2006-04-24 12:40:29 UTC (rev 2172)
+++ branches/drbd-0.7/drbd/drbd_int.h	2006-04-25 09:45:03 UTC (rev 2173)
@@ -1090,7 +1090,7 @@
 extern void drbd_rs_complete_io(struct Drbd_Conf *mdev, sector_t sector);
 extern int drbd_rs_begin_io(struct Drbd_Conf *mdev, sector_t sector);
 extern void drbd_rs_cancel_all(drbd_dev* mdev);
-extern void drbd_al_read_log(struct Drbd_Conf *mdev);
+extern int drbd_al_read_log(struct Drbd_Conf *mdev);
 extern void __drbd_set_in_sync(drbd_dev* mdev, sector_t sector, int size, const char* file, const unsigned int line);
 #define drbd_set_in_sync(mdev,sector,size) \
 	__drbd_set_in_sync(mdev,sector,size, __FILE__, __LINE__ )

Modified: branches/drbd-0.7/drbd/linux/drbd.h
===================================================================
--- branches/drbd-0.7/drbd/linux/drbd.h	2006-04-24 12:40:29 UTC (rev 2172)
+++ branches/drbd-0.7/drbd/linux/drbd.h	2006-04-25 09:45:03 UTC (rev 2173)
@@ -128,6 +128,7 @@
 	MDMounted,
 	LDMDInvalid,
 	LDDeviceTooLarge,
+	MDIOError
 };
 
 struct ioctl_disk_config {

Modified: branches/drbd-0.7/drbd/linux/drbd_config.h
===================================================================
--- branches/drbd-0.7/drbd/linux/drbd_config.h	2006-04-24 12:40:29 UTC (rev 2172)
+++ branches/drbd-0.7/drbd/linux/drbd_config.h	2006-04-25 09:45:03 UTC (rev 2173)
@@ -23,7 +23,7 @@
 extern const char * drbd_buildtag(void);
 
 #define REL_VERSION "0.7.17"
-#define API_VERSION 77
+#define API_VERSION 78
 #define PRO_VERSION 74
 
 //#define DBG_ALL_SYMBOLS // no static functs, improves quality of OOPS traces

From drbd-cvs at lists.linbit.com  Wed Apr 26 13:39:30 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Wed Apr 26 13:39:32 2006
Subject: [DRBD-cvs] svn commit by lars - r2174 - branches/drbd-0.7/drbd -
	dead code removal
Message-ID: <20060426113930.6D03816CEC@mail.linbit.com>

Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Author: lars
Date: 2006-04-26 13:39:29 +0200 (Wed, 26 Apr 2006)
New Revision: 2174

Modified:
   branches/drbd-0.7/drbd/drbd_main.c
   branches/drbd-0.7/drbd/drbd_req.c
Log:
dead code removal

Modified: branches/drbd-0.7/drbd/drbd_main.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_main.c	2006-04-25 09:45:03 UTC (rev 2173)
+++ branches/drbd-0.7/drbd/drbd_main.c	2006-04-26 11:39:29 UTC (rev 2174)
@@ -327,6 +327,9 @@
 		ERR("could not kmalloc() barrier\n");
 	}
 
+	/* FIXME if indeed we could not kmalloc, this will Oops!
+	 * can we somehow just recycle one of the existing barriers?
+	 */
 	INIT_LIST_HEAD(&new_first->requests);
 	new_first->next=0;
 	new_first->br_number=4711;

Modified: branches/drbd-0.7/drbd/drbd_req.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_req.c	2006-04-25 09:45:03 UTC (rev 2173)
+++ branches/drbd-0.7/drbd/drbd_req.c	2006-04-26 11:39:29 UTC (rev 2174)
@@ -172,7 +172,6 @@
 {
 	drbd_request_t *req;
 	int local, remote;
-	int target_area_out_of_sync = FALSE; // only relevant for reads
 
 	if (unlikely(drbd_did_panic == DRBD_MAGIC)) {
 		drbd_bio_IO_error(bio);
@@ -340,8 +339,6 @@
 				dec_ap_pending(mdev);
 				drbd_end_req(req, RQ_DRBD_SENT, 1, sector);
 			}
-		} else if (target_area_out_of_sync) {
-			drbd_read_remote(mdev,req);
 		} else {
 			// this node is diskless ...
 			drbd_read_remote(mdev,req);

From drbd-cvs at lists.linbit.com  Wed Apr 26 13:56:38 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Wed Apr 26 13:56:41 2006
Subject: [DRBD-cvs] svn commit by lars - r2175 - branches/drbd-0.7/drbd -
	added missing (un)register_ioctl32_conversion
Message-ID: <20060426115638.27B2516CEC@mail.linbit.com>

for those
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Author: lars
Date: 2006-04-26 13:56:38 +0200 (Wed, 26 Apr 2006)
New Revision: 2175

Modified:
   branches/drbd-0.7/drbd/drbd_main.c
Log:
added missing (un)register_ioctl32_conversion
for those poor guys with 32bit userland and 64bit kernel
where the kernel is too old to have the compat_ioctl member

Modified: branches/drbd-0.7/drbd/drbd_main.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_main.c	2006-04-26 11:39:29 UTC (rev 2174)
+++ branches/drbd-0.7/drbd/drbd_main.c	2006-04-26 11:56:38 UTC (rev 2175)
@@ -1674,6 +1674,7 @@
 	unregister_ioctl32_conversion(DRBD_IOCTL_WAIT_CONNECT);
 	unregister_ioctl32_conversion(DRBD_IOCTL_WAIT_SYNC);
 	unregister_ioctl32_conversion(DRBD_IOCTL_UNCONFIG_DISK);
+	unregister_ioctl32_conversion(DRBD_IOCTL_SET_STATE_FLAGS);
 	unlock_kernel();
 #endif
 #endif
@@ -1912,6 +1913,7 @@
 	register_ioctl32_conversion(DRBD_IOCTL_WAIT_CONNECT,NULL);
 	register_ioctl32_conversion(DRBD_IOCTL_WAIT_SYNC,NULL);
 	register_ioctl32_conversion(DRBD_IOCTL_UNCONFIG_DISK,NULL);
+	register_ioctl32_conversion(DRBD_IOCTL_SET_STATE_FLAGS,NULL);
 	unlock_kernel();
 #endif
 #endif

From drbd-cvs at lists.linbit.com  Wed Apr 26 14:14:37 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Wed Apr 26 14:14:38 2006
Subject: [DRBD-cvs] svn commit by phil - r2176 - in branches/drbd-0.7: .
	debian drbd/linux user - preparing the 0.7.18 release. 
Message-ID: <20060426121437.4D7CA16CEC@mail.linbit.com>

Author: phil
Date: 2006-04-26 14:14:35 +0200 (Wed, 26 Apr 2006)
New Revision: 2176

Modified:
   branches/drbd-0.7/ChangeLog
   branches/drbd-0.7/debian/changelog
   branches/drbd-0.7/drbd.spec.in
   branches/drbd-0.7/drbd/linux/drbd_config.h
   branches/drbd-0.7/user/drbdsetup.c
Log:
preparing the 0.7.18 release.


Modified: branches/drbd-0.7/ChangeLog
===================================================================
--- branches/drbd-0.7/ChangeLog	2006-04-26 11:56:38 UTC (rev 2175)
+++ branches/drbd-0.7/ChangeLog	2006-04-26 12:14:35 UTC (rev 2176)
@@ -4,6 +4,22 @@
  Cumulative changes since last tarball.
  For even more detail, use "svn log" and "svn diff".
 
+0.7.18 (api:78/proto:74)
+-----
+ * Under high memory pressure it was possible to hit a deadlock 
+   on a kmalloc(). Changed the GFP mask, it is no longer possible to
+   deadlock it with memory pressure.
+ * With very unlucky network timing during connect DRBD falls into 
+   a connect / drop-connection loop, that as soon as DRBD is in this 
+   loop is very stable. This is fixed now, DRBD detects this situation
+   an breaks out of it.
+ * Fix to the init-script. Now it waits until udev has created
+   the device nodes of _all_ resources.
+ * A small fix for the 32bit userland 64bit kernel people, running
+   older kernels.
+ * Improved handling of IO errors during initial read in of the
+   activity log.
+
 0.7.17 (api:77/proto:74)
 -----
  * There was a bug that could cause the activity log to be not applied 

Modified: branches/drbd-0.7/debian/changelog
===================================================================
--- branches/drbd-0.7/debian/changelog	2006-04-26 11:56:38 UTC (rev 2175)
+++ branches/drbd-0.7/debian/changelog	2006-04-26 12:14:35 UTC (rev 2176)
@@ -1,3 +1,9 @@
+drbd (0.7.18-0) unstable; urgency=low
+
+  * New upstream release
+
+ -- Philipp Reisner <phil@linbit.com>  Mon, 26 Apr 2006 14:10:07 +0200
+
 drbd (0.7.17-0) unstable; urgency=low
 
   * New upstream release

Modified: branches/drbd-0.7/drbd/linux/drbd_config.h
===================================================================
--- branches/drbd-0.7/drbd/linux/drbd_config.h	2006-04-26 11:56:38 UTC (rev 2175)
+++ branches/drbd-0.7/drbd/linux/drbd_config.h	2006-04-26 12:14:35 UTC (rev 2176)
@@ -22,7 +22,7 @@
 
 extern const char * drbd_buildtag(void);
 
-#define REL_VERSION "0.7.17"
+#define REL_VERSION "0.7.18"
 #define API_VERSION 78
 #define PRO_VERSION 74
 

Modified: branches/drbd-0.7/drbd.spec.in
===================================================================
--- branches/drbd-0.7/drbd.spec.in	2006-04-26 11:56:38 UTC (rev 2175)
+++ branches/drbd-0.7/drbd.spec.in	2006-04-26 12:14:35 UTC (rev 2176)
@@ -190,6 +190,22 @@
 /sbin/depmod -a -F /boot/System.map-%{kernelversion} %{kernelversion} >/dev/null 2>&1 || true
 
 %changelog
+* Mon Apr 26 2006 14:10:07 +0200 Philipp Reisner <phil@linbit.com>
+- drbd (0.7.18-1)
+ * Under high memory pressure it was possible to hit a deadlock 
+   on a kmalloc(). Changed the GFP mask, it is no longer possible to
+   deadlock it with memory pressure.
+ * With very unlucky network timing during connect DRBD falls into 
+   a connect / drop-connection loop, that as soon as DRBD is in this 
+   loop is very stable. This is fixed now, DRBD detects this situation
+   an breaks out of it.
+ * Fix to the init-script. Now it waits until udev has created
+   the device nodes of _all_ resources.
+ * A small fix for the 32bit userland 64bit kernel people, running
+   older kernels.
+ * Improved handling of IO errors during initial read in of the
+   activity log.
+
 * Mon Mar  6 2006 14:43:41 +0200 Philipp Reisner <phil@linbit.com>
 - drbd (0.7.17-1)
  * There was a bug that could cause the activity log to be not applied 

Modified: branches/drbd-0.7/user/drbdsetup.c
===================================================================
--- branches/drbd-0.7/user/drbdsetup.c	2006-04-26 11:56:38 UTC (rev 2175)
+++ branches/drbd-0.7/user/drbdsetup.c	2006-04-26 12:14:35 UTC (rev 2176)
@@ -651,6 +651,7 @@
     [LDNoConfig]="You have to use the disk command first.",
     [LDMounted]="Lower device is already mounted.",
     [MDMounted]="Meta device is already mounted.",
+    [MDIOError]="IO error on meta device",
     [LDMDInvalid]="Lower device / meta device / index combination invalid.",
     [LDDeviceTooLarge]="Currently we only support devices up to 3.998TB.\n"
                        "(up to 2TB in case you do not have CONFIG_LBD set)",

From drbd-cvs at lists.linbit.com  Wed Apr 26 14:24:31 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Wed Apr 26 14:24:37 2006
Subject: [DRBD-cvs] svn commit by phil - r2177 - tags - tagging drbd-0.7.18 
Message-ID: <20060426122431.60E6516CEC@mail.linbit.com>

Author: phil
Date: 2006-04-26 14:24:29 +0200 (Wed, 26 Apr 2006)
New Revision: 2177

Added:
   tags/drbd-0.7.18/
Log:
tagging drbd-0.7.18


Copied: tags/drbd-0.7.18 (from rev 2176, branches/drbd-0.7)

From drbd-cvs at lists.linbit.com  Fri Apr 28 15:57:05 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Fri Apr 28 15:57:07 2006
Subject: [DRBD-cvs] svn commit by phil - r2182 - branches/drbd-0.7/drbd -
	Fixes an OOPS in lc_set() / drbd_al_read_log() How to r
Message-ID: <20060428135705.B550116D12@mail.linbit.com>

Author: phil
Date: 2006-04-28 15:57:04 +0200 (Fri, 28 Apr 2006)
New Revision: 2182

Modified:
   branches/drbd-0.7/drbd/lru_cache.c
Log:
Fixes an OOPS in lc_set() / drbd_al_read_log()

How to reproduce:

drbdadm up r0         # on both nodes
drbdadm primary r0    # on the node to crash
mkfs /dev/drbd0
drbdsetup /dev/drbd0 resize -d 200M
drbdadm down r0
drbdadm up r0         # crash happens here

The bug was due to the fact that lc_del() left some list
poison in the hlist structures of the activity log LRU cache.

When reading in the AL ( via drbdadm up ) we OOPSed on that
list poison.

Fixed that.


Modified: branches/drbd-0.7/drbd/lru_cache.c
===================================================================
--- branches/drbd-0.7/drbd/lru_cache.c	2006-04-26 13:59:26 UTC (rev 2181)
+++ branches/drbd-0.7/drbd/lru_cache.c	2006-04-28 13:57:04 UTC (rev 2182)
@@ -137,7 +137,7 @@
 	PARANOIA_ENTRY();
 	BUG_ON(e->refcnt);
 	list_del(&e->list);
-	hlist_del(&e->colision);
+	hlist_del_init(&e->colision);
 	e->lc_number = LC_FREE;
 	e->refcnt = 0;
 	list_add(&e->list,&lc->free);

From drbd-cvs at lists.linbit.com  Fri Apr 28 17:58:51 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Fri Apr 28 17:58:52 2006
Subject: [DRBD-cvs] svn commit by lars - r2184 - branches/drbd-0.7/drbd -
	get rid of GFP_DRBD, explicitly use GFP_NOIO at those p
Message-ID: <20060428155852.0F85016D12@mail.linbit.com>

Author: lars
Date: 2006-04-28 17:58:50 +0200 (Fri, 28 Apr 2006)
New Revision: 2184

Modified:
   branches/drbd-0.7/drbd/drbd_int.h
   branches/drbd-0.7/drbd/drbd_main.c
   branches/drbd-0.7/drbd/drbd_receiver.c
   branches/drbd-0.7/drbd/drbd_req.c
Log:
get rid of GFP_DRBD, explicitly use GFP_NOIO at those places

Modified: branches/drbd-0.7/drbd/drbd_int.h
===================================================================
--- branches/drbd-0.7/drbd/drbd_int.h	2006-04-28 14:28:03 UTC (rev 2183)
+++ branches/drbd-0.7/drbd/drbd_int.h	2006-04-28 15:58:50 UTC (rev 2184)
@@ -289,21 +289,6 @@
 	( typecheck(struct Drbd_Conf*,x) && \
 	  ((x) ? (((x)->magic ^ DRBD_MAGIC) == (long)(x)):0))
 
-
-/*
- * GFP_DRBD is used for allocations inside drbd_make_request,
- * and for the sk->allocation scheme.
- *
- * Try to get away with GFP_NOIO, which is
- * in 2.4.x:	(__GFP_HIGH | __GFP_WAIT) // HIGH == EMERGENCY, not HIGHMEM!
- * in 2.6.x:	             (__GFP_WAIT)
- *
- * As far as i can see we do not allocate from interrupt context...
- * if we do, we certainly should fix that.
- * - lge
- */
-#define GFP_DRBD GFP_NOIO
-
 /* these defines should go into blkdev.h
    (if it will be ever includet into linus' linux) */
 #define RQ_DRBD_NOTHING	  0x0001

Modified: branches/drbd-0.7/drbd/drbd_main.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_main.c	2006-04-28 14:28:03 UTC (rev 2183)
+++ branches/drbd-0.7/drbd/drbd_main.c	2006-04-28 15:58:50 UTC (rev 2184)
@@ -245,8 +245,6 @@
 
 	barrier_nr_issue++;
 
-	// THINK this is called in the IO path with the send_mutex held
-	// and GFP_KERNEL may itself start IO. set it to GFP_NOIO.
 	b=kmalloc(sizeof(struct drbd_barrier),GFP_NOIO);
 	if(!b) {
 		ERR("could not kmalloc() barrier\n");

Modified: branches/drbd-0.7/drbd/drbd_receiver.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_receiver.c	2006-04-28 14:28:03 UTC (rev 2183)
+++ branches/drbd-0.7/drbd/drbd_receiver.c	2006-04-28 15:58:50 UTC (rev 2184)
@@ -309,6 +309,11 @@
 			if( ( mdev->ee_vacant+mdev->ee_in_use) < 
 			      mdev->conf.max_buffers ) {
 				if(drbd_alloc_ee(mdev,GFP_TRY)) {
+	/* race race race
+	 * (currently harmless for drbd07, since drbd_get_ee is called by
+	 * receiver_thread only. solved with different implementation in
+	 * drbd-plus already.)
+	 */
 					spin_lock_irq(&mdev->ee_lock);
 					break;
 				}
@@ -328,6 +333,7 @@
 		finish_wait(&mdev->ee_wait, &wait); 
 	}
 
+	/* race race race */
 	le=mdev->free_ee.next;
 	list_del(le);
 	mdev->ee_vacant--;
@@ -747,10 +753,8 @@
 	msock->sk->SK_(reuse)=1; /* SO_REUSEADDR */
 	sock->sk->SK_(reuse)=1; /* SO_REUSEADDR */
 
-	/* to prevent oom deadlock... */
-	/* The default allocation priority was GFP_KERNEL */
-	sock->sk->SK_(allocation) = GFP_DRBD;
-	msock->sk->SK_(allocation) = GFP_DRBD;
+	sock->sk->SK_(allocation) = GFP_NOIO;
+	msock->sk->SK_(allocation) = GFP_NOIO;
 
 	sock->sk->SK_(priority)=TC_PRIO_BULK;
 	NOT_IN_26(sock->sk->tp_pinfo.af_tcp.nonagle=0;)

Modified: branches/drbd-0.7/drbd/drbd_req.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_req.c	2006-04-28 14:28:03 UTC (rev 2183)
+++ branches/drbd-0.7/drbd/drbd_req.c	2006-04-28 15:58:50 UTC (rev 2184)
@@ -225,7 +225,7 @@
 
 	/* allocate outside of all locks
 	 */
-	req = mempool_alloc(drbd_request_mempool, GFP_DRBD);
+	req = mempool_alloc(drbd_request_mempool, GFP_NOIO);
 	if (!req) {
 		/* only pass the error to the upper layers.
 		 * if user cannot handle io errors, thats not our business.

From drbd-cvs at lists.linbit.com  Fri Apr 28 18:16:21 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Fri Apr 28 18:16:23 2006
Subject: [DRBD-cvs] svn commit by lars - r2185 - branches/drbd-0.7/drbd -
	get rid of SLAB_NO_REAP flag, it has been removed from 
Message-ID: <20060428161621.EA81C16D12@mail.linbit.com>

Author: lars
Date: 2006-04-28 18:15:07 +0200 (Fri, 28 Apr 2006)
New Revision: 2185

Modified:
   branches/drbd-0.7/drbd/drbd_main.c
   branches/drbd-0.7/drbd/drbd_receiver.c
Log:
get rid of SLAB_NO_REAP flag, it has been removed from slab.h, see
http://www.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=ac2b898ca6fb06196a26869c23b66afe7944e52e

Modified: branches/drbd-0.7/drbd/drbd_main.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_main.c	2006-04-28 15:58:50 UTC (rev 2184)
+++ branches/drbd-0.7/drbd/drbd_main.c	2006-04-28 16:15:07 UTC (rev 2185)
@@ -1542,13 +1542,13 @@
 	// caches
 	drbd_request_cache = kmem_cache_create(
 		"drbd_req_cache", sizeof(drbd_request_t),
-		0, SLAB_NO_REAP, NULL, NULL);
+		0, 0, NULL, NULL);
 	if (drbd_request_cache == NULL)
 		goto Enomem;
 
 	drbd_ee_cache = kmem_cache_create(
 		"drbd_ee_cache", sizeof(struct Tl_epoch_entry),
-		0, SLAB_NO_REAP, NULL, NULL);
+		0, 0, NULL, NULL);
 	if (drbd_ee_cache == NULL)
 		goto Enomem;
 

Modified: branches/drbd-0.7/drbd/drbd_receiver.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_receiver.c	2006-04-28 15:58:50 UTC (rev 2184)
+++ branches/drbd-0.7/drbd/drbd_receiver.c	2006-04-28 16:15:07 UTC (rev 2185)
@@ -181,7 +181,7 @@
 	page=alloc_page(mask);
 	if(!page) return FALSE;
 
-	if(!_drbd_alloc_ee(mdev,page,GFP_KERNEL)) {
+	if(!_drbd_alloc_ee(mdev,page,mask)) {
 		__free_page(page);
 		return FALSE;
 	}

From drbd-cvs at lists.linbit.com  Fri Apr 28 21:24:11 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Fri Apr 28 21:24:14 2006
Subject: [DRBD-cvs] svn commit by lars - r2186 - branches/drbd-0.7/drbd -
	more GFP flag magic
Message-ID: <20060428192412.36FD916CCB@mail.linbit.com>

Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Author: lars
Date: 2006-04-28 21:24:10 +0200 (Fri, 28 Apr 2006)
New Revision: 2186

Modified:
   branches/drbd-0.7/drbd/drbd_receiver.c
Log:
more GFP flag magic

Modified: branches/drbd-0.7/drbd/drbd_receiver.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_receiver.c	2006-04-28 16:15:07 UTC (rev 2185)
+++ branches/drbd-0.7/drbd/drbd_receiver.c	2006-04-28 19:24:10 UTC (rev 2186)
@@ -161,7 +161,11 @@
 {
 	struct Tl_epoch_entry* e;
 
-	e = kmem_cache_alloc(drbd_ee_cache, mask);
+	/* kmem_cache does not like to mix different memory types.
+	 * so even if we alloc'ed the page from HIGHMEM,
+	 * the ee comes from normal memory.
+	 */
+	e = kmem_cache_alloc(drbd_ee_cache, mask & ~(__GFP_HIGHMEM));
 	if( e == NULL ) return FALSE;
 
 	drbd_ee_init(e,page);
@@ -181,7 +185,12 @@
 	page=alloc_page(mask);
 	if(!page) return FALSE;
 
-	if(!_drbd_alloc_ee(mdev,page,mask)) {
+	/* if we got the page, we really want the ee, too,
+	 * even for "GFP_TRY".
+	 * we may wait, but better not cause IO,
+	 * we might be in the IO path (of our peer).
+	 */
+	if(!_drbd_alloc_ee(mdev,page,mask | GFP_NOIO)) {
 		__free_page(page);
 		return FALSE;
 	}

From drbd-cvs at lists.linbit.com  Fri Apr 28 20:25:49 2006
From: drbd-cvs at lists.linbit.com (drbd-cvs@lists.linbit.com)
Date: Sat Apr 29 12:09:10 2006
Subject: [DRBD-cvs] svn commit by lars - r2185 - branches/drbd-0.7/drbd -
	get rid of SLAB_NO_REAP flag, it has been removed from
In-Reply-To: <20060428161621.EA81C16D12@mail.linbit.com>
References: <20060428161621.EA81C16D12@mail.linbit.com>
Message-ID: <20060428182549.GG4242@soda.linbit>


I meant to check-in this one as a commit in its own right,
since this is the only functional change of the last two commits.

alloc_ee is called in the receiver on Secondary,
as well as in the receiver on SyncSource which may be Primary.
The suspicion is that the memory subsystem may deadlock here,
even though this is not obviously in the io-path.

> Modified: branches/drbd-0.7/drbd/drbd_receiver.c
> ===================================================================
> --- branches/drbd-0.7/drbd/drbd_receiver.c	2006-04-28 15:58:50 UTC (rev 2184)
> +++ branches/drbd-0.7/drbd/drbd_receiver.c	2006-04-28 16:15:07 UTC (rev 2185)
> @@ -181,7 +181,7 @@
>  	page=alloc_page(mask);
>  	if(!page) return FALSE;
>  
> -	if(!_drbd_alloc_ee(mdev,page,GFP_KERNEL)) {
> +	if(!_drbd_alloc_ee(mdev,page,mask)) {
>  		__free_page(page);
>  		return FALSE;
>  	}
> 

-- 
: Lars Ellenberg                                  Tel +43-1-8178292-55 :
: LINBIT Information Technologies GmbH            Fax +43-1-8178292-82 :
: Schoenbrunner Str. 244, A-1120 Vienna/Europe   http://www.linbit.com :
