From www-data at linbit.com  Sat Jul  2 11:52:44 2005
From: www-data at linbit.com (www-data)
Date: Sat Jul  2 11:52:46 2005
Subject: [DRBD-cvs] r1835 - trunk
Message-ID: <20050702095244.B5F1114583@mail.linbit.com>

Author: phil
Date: 2005-07-02 11:52:44 +0200 (Sat, 02 Jul 2005)
New Revision: 1835

Modified:
   trunk/ROADMAP
Log:
A rainy saturday morning. Read a bit in the kernel code...



Modified: trunk/ROADMAP
===================================================================
--- trunk/ROADMAP	2005-07-01 19:20:31 UTC (rev 1834)
+++ trunk/ROADMAP	2005-07-02 09:52:44 UTC (rev 1835)
@@ -495,7 +495,70 @@
 
 20 Make the updates to the bitmap transactional. Esp for resizing.
   Make updates to the superblock transactional
-  
+
+21 Write barriers in the kernel
+  In Linux-2.6 write barriers in the block-io layer are represented as
+  REQ_SOFTBARRIER, REQ_HARDBARRIER and REQ_NOMERGE flags on requests.
+  In the BIO layer this is BIO_RW_BARRIER, which is usually set on
+  BIO_RW (=write) requests.
+
+  The REQ_HARDBARRIER bit is currently used to do a cache flush on 
+  IDE device, which some IDE devices are capable of.
+
+  Journaling file systems should use this barrier mechanism in their journal
+  writes (actually on the commit block, this is the last write in a
+  transactional updated to the jouernal).
+
+  As for DRBD we should probabely ship the REQ_HARDBARRIER flags with
+  our wire protocol (or should they be expressed by Barrier packets?)
+
+  We will only see such REQ_HARDBARRIER flags if state to the upper layers
+  that we are able to deal with them. We need to do this by announcing it:
+  blk_queue_ordered(q, QUEUE_ORDERED_FLUSH or QUEUE_ORDERED_TAG ) .
+  Default ist QUEUE_ORDERED_NODE. This is the reason why we never see
+  the REQ_HARDBARRIER flag currently.
+
+  An other consequence of this is, that IDE devices _not_ support cache
+  flushes and have write cache enabled are inherent buggy to use with
+  a journaled file system.
+
+  What QUEUE_ORDERED_ type should we expose ?
+
+    In order to support capable IDE devices right, we should ship the
+    BIO_RW_BARRIER bit with our data packets in case the peer's backing
+    storage is of the QUEUE_ORDERED_FLUSH type.
+
+    If both devices are of the QUEUE_ORDERED_TAG type should also claim
+    to be of that type, and ship the BIO_RW_BARRIER bit as well.
+
+    self   peer      DRBD
+    ---------------------
+    NONE , NONE  =>  NONE
+    NONE , FLUSH =>  FLUSH  ( for shipping. Strip local. Save ? )
+    NONE , TAG   =>  NONE
+    FLUSH, NONE  =>  FLUSH  ( for local flush. Strip remote. Save ? )
+    FLUSH, FLUSH =>  FLUSH
+    FLUSH, TAG   =>  FLUSH
+    TAG,   NONE  =>  NONE
+    TAG,   FLUSH =>  TAG
+    TAG,   TAG   =>  TAG
+
+  How should we deal with our self generated barrier packets ?
+
+    It looks like that if our backing device's queue properties are set to
+    QUEUE_ORDERED_TAG I guess we might use the RIO_RW_BARRIER flag on BIOs
+    instead of waiting untill all of our pending local write requests are
+    done upon receiving a write barrier packet. This could give us a
+    performance boost.
+
+    In case out backing device only supports QUEUE_ORDERED_FLUSH it is
+    probabely better to use the current code. That mesns, when we receive
+    a write barrier packet we wait until all of our pending local write
+    requests are done.
+
+    In case our backing device is of the QUEUE_ORDERED_NONE class, we
+    have to stay with the current code.
+
 plus-banches:
 ----------------------
 

From www-data at linbit.com  Mon Jul 11 10:57:42 2005
From: www-data at linbit.com (www-data)
Date: Mon Jul 11 10:57:42 2005
Subject: [DRBD-cvs] r1847 - trunk
Message-ID: <20050711085742.234071447C@mail.linbit.com>

Author: phil
Date: 2005-07-11 10:57:41 +0200 (Mon, 11 Jul 2005)
New Revision: 1847

Modified:
   trunk/ROADMAP
Log:
A bit more research on the toppic of write barriers in the kernel,
and capabilities if disk drives.


Modified: trunk/ROADMAP
===================================================================
--- trunk/ROADMAP	2005-07-09 16:35:46 UTC (rev 1846)
+++ trunk/ROADMAP	2005-07-11 08:57:41 UTC (rev 1847)
@@ -503,7 +503,9 @@
   BIO_RW (=write) requests.
 
   The REQ_HARDBARRIER bit is currently used to do a cache flush on 
-  IDE device, which some IDE devices are capable of.
+  IDE devices. Actually not all IDE devices can do cache flushes, there
+  are some older models out there that can do write-caching but can
+  not perform a cache flush!
 
   Journaling file systems should use this barrier mechanism in their journal
   writes (actually on the commit block, this is the last write in a
@@ -512,16 +514,48 @@
   As for DRBD we should probabely ship the REQ_HARDBARRIER flags with
   our wire protocol (or should they be expressed by Barrier packets?)
 
-  We will only see such REQ_HARDBARRIER flags if state to the upper layers
+  We will only see such REQ_HARDBARRIER flags if we state to the upper layers
   that we are able to deal with them. We need to do this by announcing it:
   blk_queue_ordered(q, QUEUE_ORDERED_FLUSH or QUEUE_ORDERED_TAG ) .
-  Default ist QUEUE_ORDERED_NODE. This is the reason why we never see
+  Default ist QUEUE_ORDERED_NONE. This is the reason why we never see
   the REQ_HARDBARRIER flag currently.
 
-  An other consequence of this is, that IDE devices _not_ support cache
-  flushes and have write cache enabled are inherent buggy to use with
+  An other consequence of this is, that IDE devices that do _not_ support 
+  cache flushes and have write cache enabled are inherent buggy to use with
   a journaled file system.
 
+  SCSI's Tagged queuing (seems to be presenet in SATA as well)
+    [excerpt from http://www.scsimechanic.com/scsi/SCSI2-07.html]
+
+    Tagged queuing allows a target to accept multiple I/O processes from 
+    the same or different initiators until the logical unit's command queue 
+    is full.
+
+    If only SIMPLE QUEUE TAG messages are used, the target may execute the
+    commands in any order that is deemed desirable within the constraints
+    of the queue management algorithm specified in the control mode page
+    (see 8.3.3.1).  
+
+    If ORDERED QUEUE TAG messages are used, the target shall execute the
+    commands in the order received with respect to other commands received
+    with ORDERED QUEUE TAG messages. All commands received with a SIMPLE
+    QUEUE TAG message prior to a command received with an ORDERED QUEUE
+    TAG message, regardless of initiator, shall be executed before that
+    command with the ORDERED QUEUE TAG message. All commands received with
+    a SIMPLE QUEUE TAG message after a command received with an ORDERED
+    QUEUE TAG message, regardless of initiator, shall be executed after
+    that command with the ORDERED QUEUE TAG message.  
+
+    A command received with a HEAD OF QUEUE TAG message is placed first in
+    the queue, to be executed next. A command received with a HEAD OF
+    QUEUE TAG message shall be executed prior to any queued I/O
+    process. Consecutive commands received with HEAD OF QUEUE TAG messages
+    are executed in a last- in-first-out order.
+
+  I think in the context of SCSI the kernel usually issues write requests
+  with the SIMPLE QUEUE TAG, and requests with the REQ_HARDBARRIER 
+  (i.e. bio's with the BIO_RW_BARRIER) with an ORDERED QUEUE TAG.
+
   What QUEUE_ORDERED_ type should we expose ?
 
     In order to support capable IDE devices right, we should ship the
@@ -534,13 +568,13 @@
     self   peer      DRBD
     ---------------------
     NONE , NONE  =>  NONE
-    NONE , FLUSH =>  FLUSH  ( for shipping. Strip local. Save ? )
+    NONE , FLUSH =>  NONE
     NONE , TAG   =>  NONE
-    FLUSH, NONE  =>  FLUSH  ( for local flush. Strip remote. Save ? )
+    FLUSH, NONE  =>  NONE
     FLUSH, FLUSH =>  FLUSH
     FLUSH, TAG   =>  FLUSH
     TAG,   NONE  =>  NONE
-    TAG,   FLUSH =>  TAG
+    TAG,   FLUSH =>  FLUSH
     TAG,   TAG   =>  TAG
 
   How should we deal with our self generated barrier packets ?
@@ -551,8 +585,8 @@
     done upon receiving a write barrier packet. This could give us a
     performance boost.
 
-    In case out backing device only supports QUEUE_ORDERED_FLUSH it is
-    probabely better to use the current code. That mesns, when we receive
+    In case our backing device only supports QUEUE_ORDERED_FLUSH it is
+    probabely better to use the current code. That means, when we receive
     a write barrier packet we wait until all of our pending local write
     requests are done.
 

From www-data at linbit.com  Mon Jul 11 15:56:47 2005
From: www-data at linbit.com (www-data)
Date: Mon Jul 11 15:56:48 2005
Subject: [DRBD-cvs] r1850 - branches/drbd-0.7/drbd
Message-ID: <20050711135647.106B714513@mail.linbit.com>

Author: lars
Date: 2005-07-11 15:56:46 +0200 (Mon, 11 Jul 2005)
New Revision: 1850

Modified:
   branches/drbd-0.7/drbd/drbd_actlog.c
Log:

sector_t in printk: %llu, not %ld



Modified: branches/drbd-0.7/drbd/drbd_actlog.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_actlog.c	2005-07-11 13:14:02 UTC (rev 1849)
+++ branches/drbd-0.7/drbd/drbd_actlog.c	2005-07-11 13:56:46 UTC (rev 1850)
@@ -149,15 +149,15 @@
 
 	if (sector < drbd_md_ss(mdev)  ||
 	    sector > drbd_md_ss(mdev)+MD_BM_OFFSET+BM_SECT_TO_EXT(capacity)) {
-		ALERT("%s [%d]:%s(,%ld,%s) out of range md access!\n",
+		ALERT("%s [%d]:%s(,%llu,%s) out of range md access!\n",
 		     current->comm, current->pid, __func__,
-		     (long)sector, rw ? "WRITE" : "READ");
+		     (unsigned long long)sector, rw ? "WRITE" : "READ");
 	}
 
 	ok = _drbd_md_sync_page_io(mdev,iop,sector,rw,hardsect);
 	if (unlikely(!ok)) {
-		ERR("drbd_md_sync_page_io(,%lu,%s) failed!\n",
-		    (unsigned long)sector,rw ? "WRITE" : "READ");
+		ERR("drbd_md_sync_page_io(,%llu,%s) failed!\n",
+		    (unsigned long long)sector,rw ? "WRITE" : "READ");
 	}
 
 	if( hardsect != MD_HARDSECT && rw == READ ) {

From www-data at linbit.com  Wed Jul 13 10:24:00 2005
From: www-data at linbit.com (www-data)
Date: Wed Jul 13 10:24:01 2005
Subject: [DRBD-cvs] r1859 - branches/drbd-0.7/drbd
Message-ID: <20050713082400.ABD61143D9@mail.linbit.com>

Author: phil
Date: 2005-07-13 10:23:59 +0200 (Wed, 13 Jul 2005)
New Revision: 1859

Modified:
   branches/drbd-0.7/drbd/drbd_actlog.c
Log:
Very very seldom the ERR in drbd_actlog.c:607 triggered. The reason
was that the rs_left member of one of the bm_extents got negative.

How could this happen:

Two parallel threads of exeution in __drbd_set_in_sync(). Both of them
already cleared some bits, therefore having a positive count [named
cleared in drbd_try_clear_on_disk_bm()].
  Before they can enter drbd_try_clear_on_disk_bm() they get serialized
  by the al_lock spin lock. In drbd_try_clear_on_disk_bm() it has to
  recount the bits worth a BM_EXT. While counting the bits, it sees
  of course that both bits where already cleared!
  Then thread 1 leaves drbd_try_clear_on_disk_bm() and releases the
  al_lock.
  Now the other thread finds the bm_ext in the cache and substracts
  its count [aka cleared] from rs_left.
  
  => So with this race condition, rs_left is one too low.
  
Fixed the race condition by serializing before clearing bits in
the bitmap...


Modified: branches/drbd-0.7/drbd/drbd_actlog.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_actlog.c	2005-07-13 08:07:02 UTC (rev 1858)
+++ branches/drbd-0.7/drbd/drbd_actlog.c	2005-07-13 08:23:59 UTC (rev 1859)
@@ -671,7 +671,7 @@
 	unsigned long sbnr,ebnr,lbnr,bnr;
 	unsigned long count = 0;
 	sector_t esector, nr_sectors;
-	int strange_state;
+	int strange_state,wake_up=0;
 
 	strange_state = (mdev->cstate <= Connected) ||
 	                test_bit(DISKLESS,&mdev->flags) ||
@@ -717,23 +717,24 @@
 	 * ok, (capacity & 7) != 0 sometimes, but who cares...
 	 * we count rs_{total,left} in bits, not sectors.
 	 */
+	spin_lock_irq(&mdev->al_lock);
 	for(bnr=sbnr; bnr <= ebnr; bnr++) {
 		if (drbd_bm_clear_bit(mdev,bnr)) count++;
 	}
 	if (count) {
 		// we need the lock for drbd_try_clear_on_disk_bm
-		spin_lock_irq(&mdev->al_lock);
 		if(jiffies - mdev->rs_mark_time > HZ*10) {
 			/* should be roling marks, but we estimate only anyways. */
 			mdev->rs_mark_time = jiffies;
 			mdev->rs_mark_left = drbd_bm_total_weight(mdev);
 		}
 		drbd_try_clear_on_disk_bm(mdev,sector,count);
-		spin_unlock_irq(&mdev->al_lock);
 		/* just wake_up unconditional now,
 		 * various lc_chaged(), lc_put() in drbd_try_clear_on_disk_bm(). */
-		wake_up(&mdev->al_wait);
+		wake_up=1;
 	}
+	spin_unlock_irq(&mdev->al_lock);
+	if(wake_up) wake_up(&mdev->al_wait);
 }
 
 /*

From www-data at linbit.com  Wed Jul 13 18:18:51 2005
From: www-data at linbit.com (www-data)
Date: Wed Jul 13 18:18:52 2005
Subject: [DRBD-cvs] r1861 - in branches/drbd-0.7: drbd testing
Message-ID: <20050713161851.7CC2E1458C@mail.linbit.com>

Author: lars
Date: 2005-07-13 18:18:50 +0200 (Wed, 13 Jul 2005)
New Revision: 1861

Modified:
   branches/drbd-0.7/drbd/drbd_receiver.c
   branches/drbd-0.7/testing/read_gc.pl
Log:

if I cannot set it, I may not clear it ...
 (the lockout flag in _drbd_process_ee)

read_gc.pl: the size is unsigned long....



Modified: branches/drbd-0.7/drbd/drbd_receiver.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_receiver.c	2005-07-13 15:57:51 UTC (rev 1860)
+++ branches/drbd-0.7/drbd/drbd_receiver.c	2005-07-13 16:18:50 UTC (rev 1861)
@@ -407,7 +407,6 @@
 
 	if( test_and_set_bit(PROCESS_EE_RUNNING,&mdev->flags) ) {
 		if(!be_sleepy) {
-			clear_bit(PROCESS_EE_RUNNING,&mdev->flags);
 			return 3;
 		}
 		spin_unlock_irq(&mdev->ee_lock);

Modified: branches/drbd-0.7/testing/read_gc.pl
===================================================================
--- branches/drbd-0.7/testing/read_gc.pl	2005-07-13 15:57:51 UTC (rev 1860)
+++ branches/drbd-0.7/testing/read_gc.pl	2005-07-13 16:18:50 UTC (rev 1861)
@@ -42,7 +42,7 @@
 
     die "state file corrupt" if($MagicNr != DRBD_MD_MAGIC);
 
-    printf(" %6s | %3s | %3d | %3d | %3d | %3d | %3s | %3s | %3s | %6d KB\n",
+    printf(" %8s | %3s | %3d | %3d | %3d | %3d | %3s | %3s | %3s | %6lu KB\n",
 	   $resource,
 	   $Flags & 0x01 ? "1/c" : "0/i", # is consistent
 	                                  # (may become sync source)
@@ -65,17 +65,17 @@
 
     @resources = sort(split(' ',`drbdadm sh-resources`));
 
-    print <<EOS;
-                                           WantFullSync |
-                                     ConnectedInd |     |
-                                  lastState |     |     |
-                         ArbitraryCnt |     |     |     |
-                   ConnectedCnt |     |     |     |     |
-               TimeoutCnt |     |     |     |     |     |
-           HumanCnt |     |     |     |     |     |     |
-   Consistent |     |     |     |     |     |     |     |
-resource|     |     |     |     |     |     |     |     |   Size
---------+-----+-----+-----+-----+-----+-----+-----+-----+----------+
+      print <<EOS;
+                                             WantFullSync |
+                                       ConnectedInd |     |
+                                    lastState |     |     |
+                           ArbitraryCnt |     |     |     |
+                     ConnectedCnt |     |     |     |     |
+                 TimeoutCnt |     |     |     |     |     |
+             HumanCnt |     |     |     |     |     |     |
+     Consistent |     |     |     |     |     |     |     |
+  resource|     |     |     |     |     |     |     |     |   Size
+----------+-----+-----+-----+-----+-----+-----+-----+-----+----------+
 EOS
 
     for $res (@resources) {

From www-data at linbit.com  Thu Jul 14 12:11:20 2005
From: www-data at linbit.com (www-data)
Date: Thu Jul 14 12:11:21 2005
Subject: [DRBD-cvs] r1869 - branches/drbd-0.7/drbd
Message-ID: <20050714101120.984E21447C@mail.linbit.com>

Author: phil
Date: 2005-07-14 12:11:19 +0200 (Thu, 14 Jul 2005)
New Revision: 1869

Modified:
   branches/drbd-0.7/drbd/drbd_fs.c
Log:
While resizing we need to empty the AL if we shrinked the size. 
  Otherwise we might will do stupid things in drbd_al_to_on_disk_bm()
  later.


Modified: branches/drbd-0.7/drbd/drbd_fs.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_fs.c	2005-07-14 09:30:04 UTC (rev 1868)
+++ branches/drbd-0.7/drbd/drbd_fs.c	2005-07-14 10:11:19 UTC (rev 1869)
@@ -88,9 +88,13 @@
 	if ( md_moved ) {
 		WARN("Moving meta-data.\n");
 		D_ASSERT(mdev->md_index == -1);
+	}
+
+	if( mdev->la_size < la_size || md_moved) {
 		drbd_al_shrink(mdev); // All extents inactive.
 		drbd_bm_write(mdev);  // write bitmap
 	}
+
 	if ( la_size_changed || md_moved ) {
 		// Write mdev->la_size to [possibly new position on] disk.
 		drbd_md_write(mdev);

From www-data at linbit.com  Thu Jul 14 16:40:28 2005
From: www-data at linbit.com (www-data)
Date: Thu Jul 14 16:40:29 2005
Subject: [DRBD-cvs] r1876 - in branches/drbd-0.7: drbd testing/CTH
Message-ID: <20050714144028.238011447C@mail.linbit.com>

Author: lars
Date: 2005-07-14 16:40:26 +0200 (Thu, 14 Jul 2005)
New Revision: 1876

Modified:
   branches/drbd-0.7/drbd/drbd_bitmap.c
   branches/drbd-0.7/drbd/drbd_fs.c
   branches/drbd-0.7/drbd/drbd_int.h
   branches/drbd-0.7/drbd/drbd_main.c
   branches/drbd-0.7/testing/CTH/CTH_bash.helpers
   branches/drbd-0.7/testing/CTH/functions.sh
Log:

* handle out of memory condition in do_determin_dev_size slightly more gracefully

* some adjustments to the CTH,
  on startup, it first attaches all devices,
  only then it connects
  on large/many devices it would otherwise trigger timeouts more likely,
  since we still read/write the bitmap synchronous.




Modified: branches/drbd-0.7/drbd/drbd_bitmap.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_bitmap.c	2005-07-14 13:29:24 UTC (rev 1875)
+++ branches/drbd-0.7/drbd/drbd_bitmap.c	2005-07-14 14:40:26 UTC (rev 1876)
@@ -273,6 +273,12 @@
 	return 0;
 }
 
+sector_t drbd_bm_capacity(drbd_dev *mdev)
+{
+	ERR_IF(!mdev->bitmap) return 0;
+	return mdev->bitmap->bm_dev_capacity;
+}
+
 /* called on driver unload. TODO: call when a device is destroyed.
  */
 void drbd_bm_cleanup(drbd_dev *mdev)

Modified: branches/drbd-0.7/drbd/drbd_fs.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_fs.c	2005-07-14 13:29:24 UTC (rev 1875)
+++ branches/drbd-0.7/drbd/drbd_fs.c	2005-07-14 14:40:26 UTC (rev 1876)
@@ -182,16 +182,23 @@
 		int err;
 		err = drbd_bm_resize(mdev,size<<1); // wants sectors
 		if (unlikely(err)) {
-			ERR("BM resizing failed. "
-			    "Leaving size unchanged at size = %lu KB\n", 
-			    (unsigned long)size);
-		} else {
-			// racy, see comments above.
-			drbd_set_my_capacity(mdev,size<<1);
-			mdev->la_size = size;
-			INFO("size = %s (%lu KB)\n",ppsize(ppb,size),
-			     (unsigned long)size);
+			/* currently there is only one error: ENOMEM! */
+			size = drbd_bm_capacity(mdev)>>1;
+			if (size == 0) {
+				ERR("Could not allocate bitmap! Set device size => 0\n");
+			} else {
+				/* FIXME this is problematic,
+				 * if we in fact are smaller now! */
+				ERR("BM resizing failed. "
+				    "Leaving size unchanged at size = %lu KB\n", 
+				    (unsigned long)size);
+			}
 		}
+		// racy, see comments above.
+		drbd_set_my_capacity(mdev,size<<1);
+		mdev->la_size = size;
+		INFO("size = %s (%lu KB)\n",ppsize(ppb,size),
+		     (unsigned long)size);
 	}
 
 	return rv;
@@ -474,6 +481,7 @@
 	drbd_determin_dev_size(mdev);
 	/* FIXME
 	 * what if we now have la_size == 0 ?? eh?
+	 * BOOM?
 	 */
 
 	if (md_gc_valid <= 0) {

Modified: branches/drbd-0.7/drbd/drbd_int.h
===================================================================
--- branches/drbd-0.7/drbd/drbd_int.h	2005-07-14 13:29:24 UTC (rev 1875)
+++ branches/drbd-0.7/drbd/drbd_int.h	2005-07-14 14:40:26 UTC (rev 1876)
@@ -1003,6 +1003,7 @@
 extern void drbd_bm_write     (drbd_dev *mdev);
 extern unsigned long drbd_bm_ALe_set_all (drbd_dev *mdev, unsigned long al_enr);
 extern size_t        drbd_bm_words       (drbd_dev *mdev);
+extern sector_t      drbd_bm_capacity    (drbd_dev *mdev);
 extern unsigned long drbd_bm_find_next   (drbd_dev *mdev);
 extern unsigned long drbd_bm_total_weight(drbd_dev *mdev);
 extern int drbd_bm_rs_done(drbd_dev *mdev);

Modified: branches/drbd-0.7/drbd/drbd_main.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_main.c	2005-07-14 13:29:24 UTC (rev 1875)
+++ branches/drbd-0.7/drbd/drbd_main.c	2005-07-14 14:40:26 UTC (rev 1876)
@@ -1692,6 +1692,7 @@
 	int i,err;
 
 #if 0
+#warning "DEBUGGING"
 /* I am too lazy to calculate this by hand	-lge
  */
 #define SZO(x) printk(KERN_ERR "sizeof(" #x ") = %d\n", sizeof(x))

Modified: branches/drbd-0.7/testing/CTH/CTH_bash.helpers
===================================================================
--- branches/drbd-0.7/testing/CTH/CTH_bash.helpers	2005-07-14 13:29:24 UTC (rev 1875)
+++ branches/drbd-0.7/testing/CTH/CTH_bash.helpers	2005-07-14 14:40:26 UTC (rev 1876)
@@ -321,7 +321,7 @@
 	# configure all dm disks
 	for d in ${!Disk_*} ; do Heal_Disk $d ; done
 
-	# reset and up all DRBDs
+	# reset and attach all DRBDs
 	for d in ${!Drbd_*} ; do
 		drbd_to_env $d
 		echo "$conf" | on ${!left}:  drbd_append_config USIZE=$USIZE \
@@ -332,6 +332,13 @@
 			START_CLEAN=$DRBD_SKIP_INITIAL_SYNC
 	done
 
+	# configure syncer and network
+	for d in ${!Drbd_*} ; do
+		drbd_to_env $d
+		on ${!left}:  drbdadm_adjust name=$name
+		on ${!right}:  drbdadm_adjust name=$name
+	done
+
 	# wait for connect and initial sync (which should be skipped automatically)
 	for d in ${!Drbd_*} ; do
 		drbd_to_env $d

Modified: branches/drbd-0.7/testing/CTH/functions.sh
===================================================================
--- branches/drbd-0.7/testing/CTH/functions.sh	2005-07-14 13:29:24 UTC (rev 1875)
+++ branches/drbd-0.7/testing/CTH/functions.sh	2005-07-14 14:40:26 UTC (rev 1876)
@@ -104,7 +104,7 @@
 	local cmd=`type $2|tail +2`
 	local env="\
 set -o errexit $DEBUG
-PATH=/root/bin:/usr/bin:/bin:/usr/sbin:/sbin
+PATH=/root/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/bin:/bin
 $(printf '%q\n' "${@:3}")
 "
 	local err
@@ -339,11 +339,19 @@
 	fi
 	sync
 	echo .
-	drbdadm up $RES
+	drbdadm attach $RES
 	# cat /proc/drbd
-	echo "up'ed drbd $RES on $HOSTNAME"
+	echo "attached drbd $RES on $HOSTNAME"
 }
 
+drbdadm_adjust()							# {{{3
+{
+	: ${name:?unknown resource name} 
+	drbdadm adjust $name
+	# cat /proc/drbd
+	echo "adjusted drbd $name on $HOSTNAME"
+}
+
 drbdadm_up()								# {{{3
 {
 	: ${name:?unknown resource name} 

From www-data at linbit.com  Mon Jul 18 11:48:45 2005
From: www-data at linbit.com (www-data)
Date: Mon Jul 18 11:48:46 2005
Subject: [DRBD-cvs] r1881 - branches/drbd-0.7/drbd
Message-ID: <20050718094845.736A6143F3@mail.linbit.com>

Author: lars
Date: 2005-07-18 11:48:44 +0200 (Mon, 18 Jul 2005)
New Revision: 1881

Modified:
   branches/drbd-0.7/drbd/drbd_main.c
Log:
just in case: struct meta_data_on_disk shoud be 'packed'

Modified: branches/drbd-0.7/drbd/drbd_main.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_main.c	2005-07-14 15:33:15 UTC (rev 1880)
+++ branches/drbd-0.7/drbd/drbd_main.c	2005-07-18 09:48:44 UTC (rev 1881)
@@ -1975,7 +1975,7 @@
 	u32 al_offset;         // offset to this block
 	u32 al_nr_extents;     // important for restoring the AL
 	u32 bm_offset;         // offset to the bitmap, from here
-};
+} __attribute((packed));
 
 /*
 

From www-data at linbit.com  Mon Jul 18 11:53:29 2005
From: www-data at linbit.com (www-data)
Date: Mon Jul 18 11:53:30 2005
Subject: [DRBD-cvs] r1882 - branches/drbd-0.7/drbd
Message-ID: <20050718095329.6DE91143F3@mail.linbit.com>

Author: lars
Date: 2005-07-18 11:53:28 +0200 (Mon, 18 Jul 2005)
New Revision: 1882

Modified:
   branches/drbd-0.7/drbd/drbd_receiver.c
Log:

 you could get a flip-flop connection established/connection loss,
 in case both peers have different, non-zero, usize uppon first connect!

 sort-of solved it:
  "expected" (first) param exchange: use the minimum.
  "unexpected" (resize) param exchange:
    just do what the peer tells us to do.
 



Modified: branches/drbd-0.7/drbd/drbd_receiver.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_receiver.c	2005-07-18 09:48:44 UTC (rev 1881)
+++ branches/drbd-0.7/drbd/drbd_receiver.c	2005-07-18 09:53:28 UTC (rev 1882)
@@ -1348,7 +1348,7 @@
 	Drbd_Parameter_Packet *p = (Drbd_Parameter_Packet*)h;
 	int consider_sync;
 	int oo_state;
-	sector_t p_size;
+	sector_t p_size, p_usize;
 
 	if (h->length != (sizeof(*p)-sizeof(*h))) {
 		ERR("Incompatible packet size of Parameter packet!\n");
@@ -1425,12 +1425,29 @@
 
 	set_bit(MD_DIRTY,&mdev->flags); // we are changing state!
 
-	if( mdev->lo_usize != be64_to_cpu(p->u_size) ) {
-		mdev->lo_usize = be64_to_cpu(p->u_size);
+	p_usize=be64_to_cpu(p->u_size);
+	/*
+	 * you may get a flip-flop connection established/connection loss, in
+	 * case both really have different usize uppon first connect!
+	 * try to solve it thus:
+	 ***/
+#define min_not_zero(l, r) (l == 0) ? r : ((r == 0) ? l : min(l, r))
+	if (mdev->cstate == WFReportParams) {
+		/* this is first connect, or an otherwise expected param
+		 * exchange.  choose the minimum */
+		p_usize = min_not_zero(mdev->lo_usize, p_usize);
+	} else {
+		/* this was an "unexpected" param packet,
+		 * just do what the peer suggests */
+	}
+#undef min_not_zero
+	if( mdev->lo_usize != p_usize ) {
+		mdev->lo_usize = p_usize;
 		INFO("Peer sets u_size to %lu KB\n",
 		     (unsigned long)mdev->lo_usize);
 	}
 
+
 /*lge:
  * FIXME
  * please get the order of tests (re)settings for consider_sync

From www-data at linbit.com  Mon Jul 18 12:19:47 2005
From: www-data at linbit.com (www-data)
Date: Mon Jul 18 12:19:48 2005
Subject: [DRBD-cvs] r1885 - branches/drbd-0.7/drbd
Message-ID: <20050718101947.2D081143F3@mail.linbit.com>

Author: lars
Date: 2005-07-18 12:19:46 +0200 (Mon, 18 Jul 2005)
New Revision: 1885

Modified:
   branches/drbd-0.7/drbd/drbd_fs.c
Log:

while resizing the bitmap, we have to write everything, if the meta data has moved.
we have to shrink the al, if we are smaller now,
and we have to write at least the bitmap, if we are bigger now.

just do all this if (la_size_changed || md_moved)



Modified: branches/drbd-0.7/drbd/drbd_fs.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_fs.c	2005-07-18 09:55:12 UTC (rev 1884)
+++ branches/drbd-0.7/drbd/drbd_fs.c	2005-07-18 10:19:46 UTC (rev 1885)
@@ -83,19 +83,16 @@
 	rv = do_determin_dev_size(mdev);
 
 	la_size_changed = (la_size != mdev->la_size);
-	md_moved = (pmdss != drbd_md_ss(mdev) /* && mdev->md_index == -1 */);
+	md_moved = pmdss != drbd_md_ss(mdev) /* && mdev->md_index == -1 */;
 
 	if ( md_moved ) {
 		WARN("Moving meta-data.\n");
 		D_ASSERT(mdev->md_index == -1);
 	}
 
-	if( mdev->la_size < la_size || md_moved) {
+	if ( la_size_changed || md_moved ) {
 		drbd_al_shrink(mdev); // All extents inactive.
 		drbd_bm_write(mdev);  // write bitmap
-	}
-
-	if ( la_size_changed || md_moved ) {
 		// Write mdev->la_size to [possibly new position on] disk.
 		drbd_md_write(mdev);
 	}

From www-data at linbit.com  Mon Jul 18 14:24:13 2005
From: www-data at linbit.com (www-data)
Date: Mon Jul 18 14:24:13 2005
Subject: [DRBD-cvs] r1889 - in branches/drbd-0.7: . drbd
Message-ID: <20050718122413.45DC114C36@mail.linbit.com>

Author: lars
Date: 2005-07-18 14:24:12 +0200 (Mon, 18 Jul 2005)
New Revision: 1889

Modified:
   branches/drbd-0.7/Makefile
   branches/drbd-0.7/drbd/Makefile
Log:

get rid of one Makefile warning
generate drbd_buildtag.c unconditionally again



Modified: branches/drbd-0.7/Makefile
===================================================================
--- branches/drbd-0.7/Makefile	2005-07-18 11:51:11 UTC (rev 1888)
+++ branches/drbd-0.7/Makefile	2005-07-18 12:24:12 UTC (rev 1889)
@@ -105,21 +105,7 @@
 # update of drbd_buildtag.c is forced:
 .PHONY: drbd/drbd_buildtag.c
 drbd/drbd_buildtag.c:
-	@is_tarball=`test -e .svn/. && echo false || echo true`;		\
-	set -e; exec > $@.new;							\
-	echo -e "/* automatically generated. DO NOT EDIT. */";			\
-	echo -e "const char * drbd_buildtag(void)\n{";			\
-	if $$is_tarball; then							\
-	  if ! test -e $@ ; then 						\
-	  	echo >&2 "your DRBD source tree is broken. unpack again.";	\
-		exit 1;								\
-	  fi;									\
-	  grep return $@ ;							\
-	else									\
-	  echo -ne "\treturn \"SVN Revision: "; svnversion -n .; echo \";	\
-	fi ;									\
-	echo -e "\t\t\" build by $$USER@$$HOSTNAME, `date "+%F %T"`\";\n}";	\
-       	mv $@{.new,}
+	$(MAKE) -C drbd drbd_buildtag.c
 
 # update of .filelist is forced:
 .PHONY: .filelist

Modified: branches/drbd-0.7/drbd/Makefile
===================================================================
--- branches/drbd-0.7/drbd/Makefile	2005-07-18 11:51:11 UTC (rev 1888)
+++ branches/drbd-0.7/drbd/Makefile	2005-07-18 12:24:12 UTC (rev 1889)
@@ -54,8 +54,6 @@
   CONFIG_BLK_DEV_DRBD := m
   export DRBDSRC CONFIG_BLK_DEV_DRBD
 
-  KDIR_Makefile_PATCHLEVEL = $(shell grep "^PATCHLEVEL = " $(KDIR)/Makefile | cut -d " " -f 3)
-
   # to be overridden on command line:
   PREFIX := /
   ifeq ($(wildcard ../build-for-uml),../build-for-uml)
@@ -66,13 +64,7 @@
     KDIR := /lib/modules/$(shell uname -r)/build
   endif
 
-  # shell ls, because some of them may be missing
-  # inside a patched kernel source tree
-  SRC_FILES := $(shell ls 2>/dev/null\
-	linux/drbd_config.h linux/drbd.h drbd_actlog.c drbd_bitmap.c drbd_fs.c \
-	drbd_main.c drbd_proc.c drbd_receiver.c drbd_req.c drbd_worker.c \
-	lru_cache.c drbd_compat_types.h drbd_compat_wrappers.h drbd_int.h \
-	lru_cache.h hlist.h mempool-2.4.c mempool.h)
+  KDIR_Makefile_PATCHLEVEL = $(shell test -e $(KDIR)/Makefile && grep "^PATCHLEVEL = " $(KDIR)/Makefile | cut -d " " -f 3)
 
   .PHONY: drbd.o default all greeting clean kbuild install dep
 
@@ -84,17 +76,31 @@
 	@echo "" ;\
 	echo "    Calling toplevel makefile of kernel source tree, which I believe is in" ;\
 	echo "    KDIR=$(KDIR)" ; \
-	echo ""
+	echo "";
+	@if ! test -e $(KDIR)/Makefile ; then \
+		echo -e "    SORRY, kernel makefile not found. You need to tell me a correct KDIR!\n" ;\
+		false;\
+	fi
 
-  drbd_buildtag.c: $(SRC_FILES)
-	@if grep ^drbd/drbd_buildtag.c: ../Makefile &>/dev/null; then \
-	  $(MAKE) -C .. drbd/drbd_buildtag.c ;\
-	 else \
-	  echo "drbd_buildtag.c outdated." ;\
-	  echo "you probably need to do a 'make' in DRBDs toplevel directory.";\
-	  false ;\
-	 fi
+.PHONY: drbd_buildtag.c
 
+  drbd_buildtag.c:
+	@is_tarball=`test -e .svn/. -a -e ../.svn/. && echo false || echo true`;\
+	set -e; exec > $@.new;							\
+	echo -e "/* automatically generated. DO NOT EDIT. */";			\
+	echo -e "const char * drbd_buildtag(void)\n{";				\
+	if $$is_tarball; then							\
+	  if ! test -e $@ ; then 						\
+	  	echo >&2 "your DRBD source tree is broken. unpack again.";	\
+		exit 1;								\
+	  fi;									\
+	  grep return $@ ;							\
+	else									\
+	  echo -ne "\treturn \"SVN Revision: "; svnversion -n ..; echo \";	\
+	fi ;									\
+	echo -e "\t\t\" build by $$USER@$$HOSTNAME, `date "+%F %T"`\";\n}";	\
+       	mv $@{.new,}
+
   kbuild: drbd_buildtag.c
 	@rm -f .kernelrelease*
 	-test -f ../scripts/adjust_drbd_config_h.sh && \

From www-data at linbit.com  Mon Jul 25 17:43:26 2005
From: www-data at linbit.com (www-data)
Date: Mon Jul 25 17:43:27 2005
Subject: [DRBD-cvs] r1895 - trunk
Message-ID: <20050725154326.A2C8B14C2C@mail.linbit.com>

Author: phil
Date: 2005-07-25 17:43:25 +0200 (Mon, 25 Jul 2005)
New Revision: 1895

Modified:
   trunk/ROADMAP
Log:
More thoughts on that toppic...


Modified: trunk/ROADMAP
===================================================================
--- trunk/ROADMAP	2005-07-21 08:41:14 UTC (rev 1894)
+++ trunk/ROADMAP	2005-07-25 15:43:25 UTC (rev 1895)
@@ -579,20 +579,39 @@
 
   How should we deal with our self generated barrier packets ?
 
-    It looks like that if our backing device's queue properties are set to
-    QUEUE_ORDERED_TAG I guess we might use the RIO_RW_BARRIER flag on BIOs
-    instead of waiting untill all of our pending local write requests are
-    done upon receiving a write barrier packet. This could give us a
-    performance boost.
-
-    In case our backing device only supports QUEUE_ORDERED_FLUSH it is
-    probabely better to use the current code. That means, when we receive
-    a write barrier packet we wait until all of our pending local write
-    requests are done.
-
     In case our backing device is of the QUEUE_ORDERED_NONE class, we
     have to stay with the current code.
 
+    In case our backing device only supports QUEUE_ORDERED_FLUSH we
+    will to use the current code. That means, when we receive a write 
+    barrier packet we wait until all of our pending local write
+    requests are done. (This potentially causes congestion on the TCP
+    socket...)
+
+    In cause our backing device's queue properties are set to 
+    QUEUE_ORDERED_TAG we offload the complete barrier logic to the
+    backing storage device:
+
+    * When we receive a barrier packet
+      - If we have no local pending requests, we send the barrier ACK 
+        immediately. (= current code)
+      - If the last_barrier_write member of mdev points to an epoch_entry
+        we set bit 31 of bnum.
+      - If we have local pending requests, we set a flag that the next
+        data packet has to be written with the BIO_RW_BARRIER flag.
+        (That flag should be called BARRIER_NEEDED)
+
+    * When receiving data packets we test_and_clear BARRIER_NEEDED,
+      and add set the BIO_RW_BARRIER on the write request. We also set
+      the last_barrier_write member of mdev.
+      [Normal writes clear the last_barrier_write member of mdev]
+
+    * When a write completes and it has the bnum set, send the barrier
+      ack before sending the ack for the write. In case the highest
+      bit of bnum is set as well, also send the barrier ack following
+      the write ack of the data packet.
+
+
 plus-banches:
 ----------------------
 

From www-data at linbit.com  Tue Jul 26 09:29:51 2005
From: www-data at linbit.com (www-data)
Date: Tue Jul 26 09:29:53 2005
Subject: [DRBD-cvs] r1898 - in branches/drbd-0.7: drbd user
Message-ID: <20050726072951.936A01435D@mail.linbit.com>

Author: lars
Date: 2005-07-26 09:29:49 +0200 (Tue, 26 Jul 2005)
New Revision: 1898

Modified:
   branches/drbd-0.7/drbd/drbd_fs.c
   branches/drbd-0.7/drbd/drbd_int.h
   branches/drbd-0.7/drbd/drbd_main.c
   branches/drbd-0.7/drbd/drbd_req.c
   branches/drbd-0.7/user/drbdadm.h
   branches/drbd-0.7/user/drbdadm_main.c
   branches/drbd-0.7/user/drbdadm_parser.y
   branches/drbd-0.7/user/drbdadm_scanner.fl
   branches/drbd-0.7/user/drbdsetup.c
Log:

on special demand of a paying customer...

 * make it possible to disable bd_claim on 2.6. kernels
   this allows for read-only (raw) access on the mirroring target (Secondary)
   your application needs to be able to cope with all distributed locking and 
   coherency issues

 * you can "disable-ip-verification" in the global section of drbd.conf,
   so the drbdadm does not bug you with warning messages if it does not find
   the configured ip on the host.

 * you may now specify a "size" parameter in the disk sections of resources
   in drbd.conf, in case you think you need it.
   I'd suggest to not use it, though.

 + still TODO: documentation update for these changes

 - took the opportunity to get rid of the useless "disable-io-hints" module
   parameter


Modified: branches/drbd-0.7/drbd/drbd_fs.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_fs.c	2005-07-25 16:10:59 UTC (rev 1897)
+++ branches/drbd-0.7/drbd/drbd_fs.c	2005-07-26 07:29:49 UTC (rev 1898)
@@ -731,6 +731,8 @@
 		 * become Secondary. */
 		if (bd_claim(mdev->this_bdev,drbd_sec_holder))
 			return -EBUSY;
+		if (disable_bd_claim)
+			bd_release(mdev->this_bdev);
 	}
 #endif
 

Modified: branches/drbd-0.7/drbd/drbd_int.h
===================================================================
--- branches/drbd-0.7/drbd/drbd_int.h	2005-07-25 16:10:59 UTC (rev 1897)
+++ branches/drbd-0.7/drbd/drbd_int.h	2005-07-26 07:29:49 UTC (rev 1898)
@@ -72,7 +72,7 @@
 
 // module parameter, defined in drbd_main.c
 extern int minor_count;
-extern int disable_io_hints;
+extern int disable_bd_claim;
 extern int major_nr;
 extern int use_nbd_major;
 

Modified: branches/drbd-0.7/drbd/drbd_main.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_main.c	2005-07-25 16:10:59 UTC (rev 1897)
+++ branches/drbd-0.7/drbd/drbd_main.c	2005-07-26 07:29:49 UTC (rev 1898)
@@ -103,13 +103,12 @@
 MODULE_PARM_DESC(use_nbd_major, "DEPRECATED! use nbd device major nr (43) "
 		                "instead of the default " __stringify(LANANA_DRBD_MAJOR) );
 MODULE_PARM_DESC(minor_count, "Maximum number of drbd devices (1-255)");
-MODULE_PARM_DESC(disable_io_hints, "Necessary if the loopback network device is used for DRBD" );
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
 MODULE_PARM(use_nbd_major,"i");
 MODULE_PARM(minor_count,"i");
-MODULE_PARM(disable_io_hints,"i");
 #else
 #include <linux/moduleparam.h>
+MODULE_PARM_DESC(disable_bd_claim, "DONT USE! disables block device claiming" );
 /*
  * please somebody explain to me what the "perm" of the module_param
  * macro is good for (yes, permission for it in the "driverfs", but what
@@ -126,7 +125,7 @@
  */
 module_param(use_nbd_major,   bool,0);
 module_param(minor_count,      int,0);
-module_param(disable_io_hints,bool,0);
+module_param(disable_bd_claim,bool,0);
 #endif
 
 // module parameter, defined
@@ -137,8 +136,7 @@
 #else
 int minor_count = 8;
 #endif
-// FIXME disable_io_hints shall die
-int disable_io_hints = 0;
+int disable_bd_claim = 0;
 
 // devfs name
 char* drbd_devfs_name = "drbd";
@@ -1325,10 +1323,6 @@
 {
 	mdev->flags = 1<<DISKLESS;
 
-	/* If the UNPLUG_QUEUED flag is set but it is not
-	   actually queued the functionality is completely disabled */
-	if (disable_io_hints) mdev->flags |= 1<<UNPLUG_QUEUED;
-
 	mdev->sync_conf.rate       = 250;
 	mdev->sync_conf.al_extents = 127; // 512 MB active set
 	mdev->state                = Secondary;
@@ -1809,6 +1803,8 @@
 		if (bd_claim(mdev->this_bdev,drbd_sec_holder)) {
 			// Initial we are Secondary -> should claim myself.
 			WARN("Could not bd_claim() myself.");
+		} else if (disable_bd_claim) {
+			bd_release(mdev->this_bdev);
 		}
 
 		blk_queue_make_request(q,drbd_make_request_26);

Modified: branches/drbd-0.7/drbd/drbd_req.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_req.c	2005-07-25 16:10:59 UTC (rev 1897)
+++ branches/drbd-0.7/drbd/drbd_req.c	2005-07-26 07:29:49 UTC (rev 1898)
@@ -193,9 +193,11 @@
 	 * [ ... until we implement some shared mode, and our users confirm by
 	 * configuration, that they handle cache coherency themselves ... ]
 	 */
-	if (mdev->state != Primary) {
+	if (mdev->state != Primary &&
+		( !disable_bd_claim || rw == WRITE ) ) {
 		if (DRBD_ratelimit(5*HZ,5)) {
-			ERR("Not in Primary state, no IO requests allowed\n");
+			ERR("Not in Primary state, no %s requests allowed\n",
+					disable_bd_claim ? "WRITE" : "IO");
 		}
 		drbd_bio_IO_error(bio);
 		return 0;

Modified: branches/drbd-0.7/user/drbdadm.h
===================================================================
--- branches/drbd-0.7/user/drbdadm.h	2005-07-25 16:10:59 UTC (rev 1897)
+++ branches/drbd-0.7/user/drbdadm.h	2005-07-26 07:29:49 UTC (rev 1898)
@@ -30,9 +30,11 @@
 /* for verify_ips(): make not verifyable ips fatal */
 //#define INVALID_IP_IS_INVALID_CONF
 
+
 struct d_globals
 {
   int disable_io_hints;
+  int disable_ip_verification;
   int minor_count;
   int dialog_refresh;
 };

Modified: branches/drbd-0.7/user/drbdadm_main.c
===================================================================
--- branches/drbd-0.7/user/drbdadm_main.c	2005-07-25 16:10:59 UTC (rev 1897)
+++ branches/drbd-0.7/user/drbdadm_main.c	2005-07-26 07:29:49 UTC (rev 1898)
@@ -104,7 +104,7 @@
 struct utsname nodeinfo;
 int line=1;
 int fline, c_resource_start;
-struct d_globals global_options = { 0, 0, 1 };
+struct d_globals global_options = { 0, 0, 0, 1 };
 char *config_file = NULL;
 struct d_resource* config = NULL;
 int nr_resources;
@@ -245,17 +245,17 @@
 
 static void dump_global_info()
 {
-  if (global_options.minor_count || global_options.disable_io_hints)
-    {
-      printI("global {\n"); ++indent;
-      if (global_options.disable_io_hints)
-	printI("disable-io-hints;\n");
-      if (global_options.minor_count)
-	printI("minor-count %i;\n", global_options.minor_count);
-      if (global_options.dialog_refresh != 1)
-	printI("dialog-refresh %i;\n", global_options.dialog_refresh);
-      --indent; printI("}\n\n");
-    }
+  if (  !global_options.minor_count
+     && !global_options.disable_ip_verification
+     &&  global_options.dialog_refresh == 1 ) return;
+  printI("global {\n"); ++indent;
+  if (global_options.disable_ip_verification)
+    printI("disable-ip-verification;\n");
+  if (global_options.minor_count)
+    printI("minor-count %i;\n", global_options.minor_count);
+  if (global_options.dialog_refresh != 1)
+    printI("dialog-refresh %i;\n", global_options.dialog_refresh);
+  --indent; printI("}\n\n");
 }
 
 static void dump_host_info(struct d_host_info* hi)
@@ -987,6 +987,7 @@
   char *argv[] = { "/bin/bash", "-c", NULL, "drbdadm:verify_ips", NULL };
   int ex;
 
+  if (global_options.disable_ip_verification) return;
   if (dry_run == 1 || do_verify_ips == 0) return;
 
   if (!(res && res->me   && res->me->address

Modified: branches/drbd-0.7/user/drbdadm_parser.y
===================================================================
--- branches/drbd-0.7/user/drbdadm_parser.y	2005-07-25 16:10:59 UTC (rev 1897)
+++ branches/drbd-0.7/user/drbdadm_parser.y	2005-07-26 07:29:49 UTC (rev 1898)
@@ -322,6 +322,7 @@
 %token TK_GLOBAL TK_RESOURCE
 %token TK_ON TK_NET TK_DISK_S TK_SYNCER TK_STARTUP
 %token TK_DISABLE_IO_HINTS
+%token TK_DISABLE_IP_VERIFICATION
 %token TK_PROTOCOL TK_INCON_DEGR_CMD
 %token TK_ADDRESS TK_DISK TK_DEVICE TK_META_DISK
 %token <txt> TK_MINOR_COUNT TK_INTEGER TK_STRING
@@ -352,7 +353,14 @@
 		;
 
 glob_stmt:	  TK_DISABLE_IO_HINTS
-			{ global_options.disable_io_hints=1;   }
+		{
+		    fprintf(stderr,
+			    "%s:%d: in global section, "
+			    "useless use of no longer available option \"disable_io_hints\".\n",
+			    config_file, line);
+		}
+		|  TK_DISABLE_IP_VERIFICATION
+		{ global_options.disable_ip_verification=1; }
 		| TK_MINOR_COUNT TK_INTEGER
 		{
 			range_check(R_MINOR_COUNT,$1,$2);

Modified: branches/drbd-0.7/user/drbdadm_scanner.fl
===================================================================
--- branches/drbd-0.7/user/drbdadm_scanner.fl	2005-07-25 16:10:59 UTC (rev 1897)
+++ branches/drbd-0.7/user/drbdadm_scanner.fl	2005-07-26 07:29:49 UTC (rev 1898)
@@ -206,6 +206,7 @@
   minor[-_]count	do_assign(NUM); CP; return TK_MINOR_COUNT;
   disable[-_]io[-_]hints yy_push_state(SEMICOLON); return TK_DISABLE_IO_HINTS;
   dialog-refresh        do_assign(NUM); CP; return TK_DIALOG_REFRESH;
+  disable-ip-verification  yy_push_state(SEMICOLON); return TK_DISABLE_IP_VERIFICATION;
   {NDELIM}		expect_error("'minor-count|disable-io-hints|dialog-refresh'");
 }
 
@@ -233,6 +234,7 @@
 
 <DISK>{
   on-io-error		do_assign(IO_ERROR); CP; return TK_ON_IO_ERROR;
+  size                  do_assign(NUM_U); CP; return TK_SIZE;
   {NDELIM}		expect_error("'on-io-error'");
 }
 

Modified: branches/drbd-0.7/user/drbdsetup.c
===================================================================
--- branches/drbd-0.7/user/drbdsetup.c	2005-07-25 16:10:59 UTC (rev 1897)
+++ branches/drbd-0.7/user/drbdsetup.c	2005-07-26 07:29:49 UTC (rev 1898)
@@ -526,7 +526,7 @@
       switch(c)
 	{
 	case 'd':
-	  cn->config.disk_size = m_strtoll_range(optarg,'K', "disk-size",
+	  cn->config.disk_size = m_strtoll_range(optarg,'K', "size",
 			      DRBD_DISK_SIZE_SECT_MIN>>1,
 			      DRBD_DISK_SIZE_SECT_MAX>>1 );
 	  break;
@@ -1179,7 +1179,7 @@
 	  switch(c)
 	    {
 	    case 'd':
-	      u_size=m_strtoll_range(optarg,'K', "disk-size",
+	      u_size=m_strtoll_range(optarg,'K', "size",
 			      DRBD_DISK_SIZE_SECT_MIN>>1,
 			      DRBD_DISK_SIZE_SECT_MAX>>1 );
 	      break;

From www-data at linbit.com  Tue Jul 26 13:37:13 2005
From: www-data at linbit.com (www-data)
Date: Tue Jul 26 13:37:20 2005
Subject: [DRBD-cvs] r1899 - branches/drbd-0.7
Message-ID: <20050726113718.9D0161435D@mail.linbit.com>

Author: lars
Date: 2005-07-26 13:37:12 +0200 (Tue, 26 Jul 2005)
New Revision: 1899

Modified:
   branches/drbd-0.7/Makefile
Log:

oops, traces of drbd-plus in the main branch...



Modified: branches/drbd-0.7/Makefile
===================================================================
--- branches/drbd-0.7/Makefile	2005-07-26 07:29:49 UTC (rev 1898)
+++ branches/drbd-0.7/Makefile	2005-07-26 11:37:12 UTC (rev 1899)
@@ -134,7 +134,7 @@
 	ln -s . drbd-$(FDIST_VERSION)
 	for f in $$(<.filelist) ; do [ -e $$f ] && continue ; echo missing: $$f ; exit 1; done
 	grep debian .filelist >/dev/null 2>&1 && _DEB=-debian || _DEB="" ; \
-	tar --owner=0 --group=0 -czf - -T .filelist > drbd-plus-$(FDIST_VERSION)$$_DEB.tar.gz
+	tar --owner=0 --group=0 -czf - -T .filelist > drbd-$(FDIST_VERSION)$$_DEB.tar.gz
 	rm drbd-$(FDIST_VERSION)
 
 ifeq ($(FORCE),)

From www-data at linbit.com  Tue Jul 26 14:05:30 2005
From: www-data at linbit.com (www-data)
Date: Tue Jul 26 14:05:33 2005
Subject: [DRBD-cvs] r1900 - in trunk: . debian drbd drbd/linux testing/CTH
	user
Message-ID: <20050726120530.45EC11435D@mail.linbit.com>

Author: lars
Date: 2005-07-26 14:05:27 +0200 (Tue, 26 Jul 2005)
New Revision: 1900

Modified:
   trunk/
   trunk/ChangeLog
   trunk/Makefile
   trunk/debian/changelog
   trunk/drbd.spec.in
   trunk/drbd/Makefile
   trunk/drbd/drbd_actlog.c
   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/testing/CTH/CTH_bash.helpers
   trunk/testing/CTH/functions.sh
   trunk/user/drbd_limits.h
   trunk/user/drbdadm.h
   trunk/user/drbdadm_main.c
   trunk/user/drbdadm_parser.y
   trunk/user/drbdadm_scanner.fl
   trunk/user/drbdsetup.c
Log:
monster merge of changes from the drbd-0.7 branch
supervised svnp run r1763 to r1899

  r1763 | phil | 2005-02-17 15:14:10 +0100 
     M /branches/drbd-0.7/drbd.spec.in

  To make building RPMs on RHAS4 work.

  r1766 | phil | 2005-03-08 09:29:24 +0100 
     M /branches/drbd-0.7/drbd/drbd_int.h
     M /branches/drbd-0.7/drbd/drbd_main.c

  The busy_blocks construct was replaces by the resync lru_cache,
  long before drbd-0.7 became stable. Removed that little leftover.

  r1773 | phil | 2005-04-01 11:38:50 +0200 
     M /branches/drbd-0.7/user/drbd_limits.h

  The limit on MAX_BUFFERS was ways too restrictive.

  r1794 | phil | 2005-05-12 09:08:49 +0200 
     M /branches/drbd-0.7/ChangeLog

  Preparing 0.7.11

  r1798 | lars | 2005-05-23 15:23:33 +0200 
     M /branches/drbd-0.7/ChangeLog
     M /branches/drbd-0.7/drbd/linux/drbd_config.h
     M /branches/drbd-0.7/drbd.spec.in

  prepare release 0.7.11

  r1800 | lars | 2005-05-23 21:46:50 +0200 
     M /branches/drbd-0.7/ChangeLog
     M /branches/drbd-0.7/debian/changelog
     M /branches/drbd-0.7/drbd.spec.in

  added missing changelog updates
  added mv /lib/modules/*/extra/drbd.ko -> *.orig rename
  to post install of drbd-km- 

  r1803 | phil | 2005-05-24 10:28:52 +0200 
     M /branches/drbd-0.7/drbd.spec.in

  Building on SuSE-9.3 needs the LOCALVERSION ...

  r1804 | lars | 2005-05-30 19:00:13 +0200 
     M /branches/drbd-0.7/Makefile
     M /branches/drbd-0.7/user/drbdadm_scanner.fl

  * makefile update for internal use
  * fixed flex input buffer overflow:
    drbdadm_scanner.fl produced tokens of arbitrary length due to excessive use
    of "+" and "*" modifiers. Now these are replaced with "{x,y}" modifiers, so
    it should no longer segfault.
    Though it may now produce parse errors where it suceeded before, if you
    happen to use 90 character long resource names or the like.

  r1805 | lars | 2005-05-30 19:07:34 +0200 
     M /branches/drbd-0.7/Makefile

  * missing parts of Makefile update

  r1806 | lars | 2005-06-07 19:19:05 +0200 
     M /branches/drbd-0.7/ChangeLog
     M /branches/drbd-0.7/drbd.spec.in

  changelog updates

  r1821 | lars | 2005-06-30 11:44:27 +0200 
     M /branches/drbd-0.7/Makefile
     M /branches/drbd-0.7/drbd/Makefile
     M /branches/drbd-0.7/drbd/drbd_fs.c
     M /branches/drbd-0.7/drbd/drbd_int.h
     M /branches/drbd-0.7/user/drbdadm.h
     M /branches/drbd-0.7/user/drbdadm_main.c
     M /branches/drbd-0.7/user/drbdadm_parser.y
     M /branches/drbd-0.7/user/drbdadm_scanner.fl
     M /branches/drbd-0.7/user/drbdsetup.c

   * make sure new la_size is written to meta data early
   * test on feature instead of version code (TASK_ZOMBIE)
   * add "verify_ips" flag to drbdadm commands, so it annoys us with warnings only part of the time.
   * don't report the "is ip present" bash magic as failed command
   * remove .tmp_versions on clean
   * minor cleanups and adjustments

  r1826 | lars | 2005-06-30 12:22:30 +0200 
     M /branches/drbd-0.7/Makefile

  minor makefile fix

  r1850 | lars | 2005-07-11 15:56:46 +0200 
     M /branches/drbd-0.7/drbd/drbd_actlog.c

  sector_t in printk: %llu, not %ld

  r1859 | phil | 2005-07-13 10:23:59 +0200 
     M /branches/drbd-0.7/drbd/drbd_actlog.c

  Very very seldom the ERR in drbd_actlog.c:607 triggered. The reason
  was that the rs_left member of one of the bm_extents got negative.

  How could this happen:

  Two parallel threads of exeution in __drbd_set_in_sync(). Both of them
  already cleared some bits, therefore having a positive count [named
  cleared in drbd_try_clear_on_disk_bm()].
    Before they can enter drbd_try_clear_on_disk_bm() they get serialized
    by the al_lock spin lock. In drbd_try_clear_on_disk_bm() it has to
    recount the bits worth a BM_EXT. While counting the bits, it sees
    of course that both bits where already cleared!
    Then thread 1 leaves drbd_try_clear_on_disk_bm() and releases the
    al_lock.
    Now the other thread finds the bm_ext in the cache and substracts
    its count [aka cleared] from rs_left.
    
    => So with this race condition, rs_left is one too low.
    
  Fixed the race condition by serializing before clearing bits in
  the bitmap...

  r1861 | lars | 2005-07-13 18:18:50 +0200 
     M /branches/drbd-0.7/drbd/drbd_receiver.c

  if I cannot set it, I may not clear it ...
   (the lockout flag in _drbd_process_ee)

  r1869 | phil | 2005-07-14 12:11:19 +0200 
     M /branches/drbd-0.7/drbd/drbd_fs.c

  While resizing, if we shrunk we need to empty the AL.
  Otherwise we do stupid things in drbd_al_to_on_disk_bm() later.
  (access beyond end of meta data and stuff)

  r1876 | lars | 2005-07-14 16:40:26 +0200 
     M /branches/drbd-0.7/drbd/drbd_bitmap.c
     M /branches/drbd-0.7/drbd/drbd_fs.c
     M /branches/drbd-0.7/drbd/drbd_int.h
     M /branches/drbd-0.7/drbd/drbd_main.c
     M /branches/drbd-0.7/testing/CTH/CTH_bash.helpers
     M /branches/drbd-0.7/testing/CTH/functions.sh

  * handle out of memory condition in do_determin_dev_size slightly more gracefully

  * some adjustments to the CTH,
    on startup, it first attaches all devices,
    only then it connects
    on large/many devices it would otherwise trigger timeouts more likely,
    since we still read/write the bitmap synchronous.

  r1881 | lars | 2005-07-18 11:48:44 +0200 
     M /branches/drbd-0.7/drbd/drbd_main.c

  just in case: struct meta_data_on_disk shoud be 'packed'
  r1882 | lars | 2005-07-18 11:53:28 +0200 
     M /branches/drbd-0.7/drbd/drbd_receiver.c

   you could get a flip-flop connection established/connection loss,
   in case both peers have different, non-zero, usize uppon first connect!

   sort-of solved it:
    "expected" (first) param exchange: use the minimum.
    "unexpected" (resize) param exchange:
      just do what the peer tells us to do.
   

  r1885 | lars | 2005-07-18 12:19:46 +0200 
     M /branches/drbd-0.7/drbd/drbd_fs.c

  while resizing the bitmap, we have to write everything, if the meta data has moved.
  we have to shrink the al, if we are smaller now,
  and we have to write at least the bitmap, if we are bigger now.

  just do all this if (la_size_changed || md_moved)

  r1889 | lars | 2005-07-18 14:24:12 +0200 
     M /branches/drbd-0.7/Makefile
     M /branches/drbd-0.7/drbd/Makefile

  get rid of one Makefile warning
  generate drbd_buildtag.c unconditionally again

  r1898 | lars | 2005-07-26 09:29:49 +0200 
     M /branches/drbd-0.7/drbd/drbd_fs.c
     M /branches/drbd-0.7/drbd/drbd_int.h
     M /branches/drbd-0.7/drbd/drbd_main.c
     M /branches/drbd-0.7/drbd/drbd_req.c
     M /branches/drbd-0.7/user/drbdadm.h
     M /branches/drbd-0.7/user/drbdadm_main.c
     M /branches/drbd-0.7/user/drbdadm_parser.y
     M /branches/drbd-0.7/user/drbdadm_scanner.fl
     M /branches/drbd-0.7/user/drbdsetup.c

  on special demand of a paying customer...

   * make it possible to disable bd_claim on 2.6. kernels
     this allows for read-only (raw) access on the mirroring target (Secondary)
     your application needs to be able to cope with all distributed locking and 
     coherency issues

   * you can "disable-ip-verification" in the global section of drbd.conf,
     so the drbdadm does not bug you with warning messages if it does not find
     the configured ip on the host.

   * you may now specify a "size" parameter in the disk sections of resources
     in drbd.conf, in case you think you need it.
     I'd suggest to not use it, though.

   + still TODO: documentation update for these changes

   - took the opportunity to get rid of the useless "disable-io-hints" module
     parameter

  r1899 | lars | 2005-07-26 13:37:12 +0200 
     M /branches/drbd-0.7/Makefile

  oops, traces of drbd-plus in the main branch...



Property changes on: trunk
___________________________________________________________________
Name: propagate:at
   - 1745
   + 1899

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2005-07-26 11:37:12 UTC (rev 1899)
+++ trunk/ChangeLog	2005-07-26 12:05:27 UTC (rev 1900)
@@ -1,29 +1,116 @@
 Latest:
 ------
- ChangeLog last updated: r1594 2004-10-15
+ ChangeLog last updated: r1806 2005-05-23
  Cumulative changes since last tarball.
  For even more detail, use "svn log" and "svn diff".
 
 0.8_pre1
 --------
  * remove all kernel 2.4.x compatibility crap
- * ioctl sanity checks about Unconfigured and CAP_SYS_ADMIN
- * drbddisk start retries several times,
-   in case drbd ping timeout is longer than heartbeat deadtime.
 
+ FIXME mention all those things we did so far
+
+
 0.7 branch
 ----------
+
+0.7.11 (api:77/proto:74)
+-----
+ * The upper limit of the runtime tuning parameter max_buffers 
+   was ways too low for today's IBM storage controllers. 
+   Was 32 - 10000 ; Now it is 32 - 131072 ( Now one could 
+   allow DRBD to allocate up to half a gigabyte of memory as 
+   receive buffers)
+ * A fix to the Makefiles to make building of RPMs work on RAHS4.
+ * A workaround to have DBRD running on PPC64 with Linux-2.4.x kernels,
+   on Linux-2.6.x everything was fine already.
+ * Removal of dead code (busy_blocks).
+ * LINBIT drbd rpms now conflict with km_drbd
+   (SuSE's kernel module source hook)
+ * possibly existing /lib/modules/*/extra/drbd.ko are renamed to .orig in the
+   post-install scripts to avoid conflicts with existing modules from
+   distribution kernel packages
+ * fixed flex input buffer overflow
+   drbdadm_scanner.fl produced tokens of arbitrary length due to excessive use
+   of "+" and "*" modifiers. Now these are replaced with "{x,y}" modifiers, so
+   it should no longer segfault, which was actually observed e.g. with long
+   continuous comment blocks (~5k). 
+
+0.7.10 (api:77/proto:74)
+-----
+ * 0.7.9 had a memory corruption bug and memory leakage (BIOs).
+   This time I did the clone_bio() fix myself, and this release is
+   supposed to work with SLES9 SP1, Linux-2.6.11 and Linux-2.6.12.
+
+0.7.9 (api:77/proto:74)
+-----
+ * A fix that makes DRBD work on SLES9 SP1 kernel, and 
+   probabely will be also necessary for Linux-2.6.11
+
+0.7.8 (api:77/proto:74)
+-----
+ * Fixed a bug that caused the syncer to starve on devices 
+   bigger than 2 TB on 32bit systems (=CONFIG_LBA).
+ * Made online resizing actually work. Now it makes a lot
+   more sense to put DRBD on top of LVM.
+ * Made the user dialog to work on RedHat based distributions.
+ * A small optimization that improves the performance of the 
+   syncer when woking with IBM's ServRaid Controllers (ips).
+   May have a positive effect with other Controllers as well.
+ * Made epoch_size atomic. This removes a SMP race condition that
+   could lead on some Xeon CPUs to an ASSERT printk, but did no other
+   harm than printing messages to the syslog
+ * Fixed write_gc.pl to work with the perl version delivered
+   with RHAS3.
+ * Made the initscript to abort if one of the setup commands fails.
+
+0.7.7 (api:77/proto:74)
+-----
+ * "drbdadm adjust [res...]" now does the calls to drbdsetup 
+   in an improved order, first the disk config of all devices,
+   then the syncer and net config last. With the old scheme
+   drbdadm run in a timeout when setting up more than about 
+   6 devices at once (startup script...).
+ * New progress indication in the startup script.
+ * Bugfix to a race that could cause a OOPS on a BUG() macro
+   in mod_timer while starting resync. The more devices you have 
+   the higher the probability to hit this race condition.
+ * Fixed a bug in the sync-groups conde, that only showed up
+   when you have more than 4 resources in your config. 
+   The resync process was continued too early on the node in
+   SyncTarget state.
+ * Fixed a stupid typo in the range-check code, that was intoduced
+   in 0.7.6. Drbdsetup allowed "max-buffers" to be in the range 
+   from 32 to 32.
+ * Makefiles are gcc-2.95 compatible again.
+	
+0.7.6 (api:77/proto:74)
+-----
+ * Fixed bug that could cause a lockup of the receiver and
+   asender threads, the visible outcome was that the syncer
+   starves.
+ * Fixed a bug that under specific circumstandes caused that the
+   SyncSource node did not recognised that a resync process was
+   finished.
+ * "drbdadm invalidate [res]" was not working correct, while
+   "drbdadm invalidate_remote [res]" works. Fixed the former.
+ * Make DRBD work on Linux-2.6.10-rc2 and newer: Replaced
+   sock_alloc() by sock_create(), replaced TASK_ZOMBIE by 
+   EXIT_ZOMBIE.
+ * Range checks in drbdadm for all numeric configure parameters.
  * A fix to make ioctl()s work on machines with 64bit kernel space 
    and 32bit user space. 
- * Ioctl()s are only alloes if the caller has CAP_SYS_ADMIN set.
+ * Ioctl()s are only allowed if the caller has CAP_SYS_ADMIN set.
  * Removal of warnings on 64bit architectures.
  * Backport of find_first_bit() for x86_64 aka AMD64 for use on 
    that architecture under Linux-2.4.x
+ * Changed drbdadm to do the syncer config before the net config.
  * Changed the way drbdadm determines the minor_count parameter for
    module loading.
  * Improvements to the drbddisk script, to do the right thing
    in case Heartbeat is configured with a small timeout than DRBD.
- * Lots of updates to the way Debian's DRBD packages works.
+ * On request of the debian package maintainers, the debian directory
+   from SVN is not longer included in the tar.gz releases.
 
 0.7.5 (api:76/proto:74)
 -----

Modified: trunk/Makefile
===================================================================
--- trunk/Makefile	2005-07-26 11:37:12 UTC (rev 1899)
+++ trunk/Makefile	2005-07-26 12:05:27 UTC (rev 1900)
@@ -32,11 +32,16 @@
 # or to forcefully include the svn-last-changed-date in the tgz name:
 #   make distclean doc tgz FORCE=1
 #
-REL_VERSION := $(REL_VERSION)-$(shell svn info| \
-		  sed -ne 's/^Last Changed Date: \([0-9]*\)-\([0-9]*\)-\([0-9]*\).*/\1\2\3/p')
+REL_VERSION := $(REL_VERSION)-$(shell LANG= svn info| \
+	sed -n -e 's/^Last Changed Date: \([0-9]*\)-\([0-9]*\)-\([0-9]*\).*/\1\2\3/p' \
+	)-$(shell svnversion .)
 endif
 
 DIST_VERSION := $(subst -,_,$(REL_VERSION))
+FDIST_VERSION := $(shell test -e .filelist && sed -ne 's,^drbd-\([^/]*\)/.*,\1,p;q' < .filelist)
+ifeq ($(FDIST_VERSION),)
+FDIST_VERSION := $(DIST_VERSION)
+endif
 
 LN_S = ln -s
 RPMBUILD=rpmbuild
@@ -100,21 +105,7 @@
 # update of drbd_buildtag.c is forced:
 .PHONY: drbd/drbd_buildtag.c
 drbd/drbd_buildtag.c:
-	@is_tarball=`test -e .svn/. && echo false || echo true`;		\
-	set -e; exec > $@.new;							\
-	echo -e "/* automatically generated. DO NOT EDIT. */";			\
-	echo -e "const char * drbd_buildtag(void)\n{";			\
-	if $$is_tarball; then							\
-	  if ! test -e $@ ; then 						\
-	  	echo >&2 "your DRBD source tree is broken. unpack again.";	\
-		exit 1;								\
-	  fi;									\
-	  grep return $@ ;							\
-	else									\
-	  echo -ne "\treturn \"SVN Revision: "; svnversion -n .; echo \";	\
-	fi ;									\
-	echo -e "\t\t\" build by $$USER@$$HOSTNAME, `date "+%F %T"`\";\n}";	\
-       	mv $@{.new,}
+	$(MAKE) -C drbd drbd_buildtag.c
 
 # update of .filelist is forced:
 .PHONY: .filelist
@@ -122,7 +113,7 @@
 	@ svn info >/dev/null || { echo "you need a svn checkout to do this." ; false ; }
 	@find $$(svn st -v | sed '/^?/d;s/^.\{8\} \+[0-9]\+ \+[0-9]\+ [a-z]\+ *//;$(if $(PRESERVE_DEBIAN),,/^debian/d)' ) \
 	\! -type d -maxdepth 0 |\
-	sed 's:^:drbd-$(DIST_VERSION)/:' > .filelist
+	sed 's#^#drbd-$(DIST_VERSION)/#' > .filelist
 	@[ -s .filelist ] # assert there is something in .filelist now
 	@find documentation -name "[^.]*.[58]" -o -name "*.html" | \
 	sed "s/^/drbd-$(DIST_VERSION)\//" >> .filelist           ;\
@@ -139,24 +130,31 @@
 tgz:
 	test -e .filelist
 	ln -sf drbd/linux/drbd_config.h drbd_config.h
-	rm -f drbd-$(DIST_VERSION)
-	ln -s . drbd-$(DIST_VERSION)
-	set -e ; for f in $$(<.filelist) ; do [ -e $$f ] ; done
-	tar --owner=0 --group=0 -czf drbd-$(DIST_VERSION).tar.gz -T .filelist
-	rm drbd-$(DIST_VERSION)
+	rm -f drbd-$(FDIST_VERSION)
+	ln -s . drbd-$(FDIST_VERSION)
+	for f in $$(<.filelist) ; do [ -e $$f ] && continue ; echo missing: $$f ; exit 1; done
+	grep debian .filelist >/dev/null 2>&1 && _DEB=-debian || _DEB="" ; \
+	tar --owner=0 --group=0 -czf - -T .filelist > drbd-$(FDIST_VERSION)$$_DEB.tar.gz
+	rm drbd-$(FDIST_VERSION)
 
 ifeq ($(FORCE),)
 tgz: check_changelogs_up2date doc
 endif
 
 check_all_committed:
-	@modified=`svn st -q`; 		\
+	@$(if $(FORCE),-,)modified=`svn st -q`; 		\
 	if test -n "$$modified" ; then	\
 		echo "$$modified";	\
 	       	false;			\
 	fi
 
-tarball: check_all_committed distclean doc .filelist tgz
+prepare_release:
+	$(MAKE) tarball
+	$(MAKE) tarball PRESERVE_DEBIAN=1
+
+tarball: check_all_committed distclean doc .filelist
+	$(MAKE) tgz
+
 all tools doc .filelist: drbd/drbd_buildtag.c
 
 KDIR := $(shell echo /lib/modules/`uname -r`/build)
@@ -181,11 +179,11 @@
 	         dist/TMP \
 	         dist/install \
 	         dist/SRPMS
-	[ -h dist/SOURCES/drbd-$(DIST_VERSION).tar.gz ] || \
-	  $(LN_S) $(PWD)/drbd-$(DIST_VERSION).tar.gz \
-	          $(PWD)/dist/SOURCES/drbd-$(DIST_VERSION).tar.gz
+	[ -h dist/SOURCES/drbd-$(FDIST_VERSION).tar.gz ] || \
+	  $(LN_S) $(PWD)/drbd-$(FDIST_VERSION).tar.gz \
+	          $(PWD)/dist/SOURCES/drbd-$(FDIST_VERSION).tar.gz
 	if test drbd.spec.in -nt dist/SPECS/drbd.spec ; then \
-	   sed -e "s/^\(Version:\).*/\1 $(DIST_VERSION)/;" \
+	   sed -e "s/^\(Version:\).*/\1 $(FDIST_VERSION)/;" \
 	       -e "s/^\(Packager:\).*/\1 $(USER)@$(HOSTNAME)/;" < drbd.spec.in \
 	   > dist/SPECS/drbd.spec ; \
 	fi

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	2005-07-26 11:37:12 UTC (rev 1899)
+++ trunk/debian/changelog	2005-07-26 12:05:27 UTC (rev 1900)
@@ -1,13 +1,67 @@
+drbd (0.7.11-0) unstable; urgency=low
+
+  * (Philipp Reisner)
+     - New upstream release
+
+ -- Philipp Reisner <phil@linbit.com>  Mon, 23 May 2005 15:29:21 +0200
+
+drbd (0.7.10-0) unstable; urgency=low
+
+  * (Philipp Reisner)
+     - New upstream release
+
+ -- Philipp Reisner <phil@linbit.com>  Mon, 31 Jan 2005 10:17:00 +0100
+
+drbd (0.7.9-0) unstable; urgency=low
+
+  * (Philipp Reisner)
+     - New upstream release
+
+ -- Philipp Reisner <phil@linbit.com>  Tue, 25 Jan 2005 11:31:00 +0100
+
+drbd (0.7.8-1) unstable; urgency=low
+
+  * (Cyril Bouthors)
+     - New upstream release
+
+ -- Cyril Bouthors <cyril@bouthors.org>  Mon, 17 Jan 2005 18:50:49 +0400
+
+drbd (0.7.7-1) unstable; urgency=low
+
+  * (Cyril Bouthors)
+     - New upstream release
+
+ -- Cyril Bouthors <cyril@bouthors.org>  Wed, 15 Dec 2004 17:15:35 +0300
+
+drbd (0.7.6-2) unstable; urgency=low
+
+  * (Cyril Bouthors)
+     - drbd0.7-module-source: Moved debhelper from Recommends to Depends
+
+ -- Cyril Bouthors <cyril@bouthors.org>  Thu,  9 Dec 2004 20:37:41 +0300
+
+drbd (0.7.6-1) unstable; urgency=low
+
+  * (Cyril Bouthors)
+     - New upstream release
+     - debian/control.modules.in: updated description
+     - debian/TODO: removed
+
+ -- Cyril Bouthors <cyril@bouthors.org>  Tue, 30 Nov 2004 19:43:27 +0300
+
 drbd (0.7.5-2) unstable; urgency=low
 
-  * debian/control: Added Conflict with drbd-util and drbd-module-source
-  * debian/control.in.modules: Fixed description for kernel module
-  * debian/control.in.modules: Added Conflict line in kernel module package
-  * debian/control.in.modules: Change depends to drbd0.7-util
-  * debian/rules: don't use top-level makefile
-  * call depmod in postinst of kernel module
-  * remove obsolete upstream ./debian/ in clean
-  * added module-assistant override file
+  * (Philipp Hug)
+    - debian/control: Added Conflict with drbd-util and drbd-module-source
+    - debian/control.in.modules: Fixed description for kernel module
+    - debian/control.in.modules: Added Conflict line in kernel module package
+    - debian/control.in.modules: Change depends to drbd0.7-util
+    - debian/rules: don't use top-level makefile, to prevent re-creation of
+      drbd_buildtag.c
+    - call depmod in postinst of kernel module
+    - debian/rules: remove obsolete upstream ./debian/ files in clean target
+    - added module-assistant override file
+    - this version is ready for sarge (Closes: #277669)
 
  -- Philipp Hug <debian@hug.cx>  Tue, 19 Oct 2004 20:50:49 +0200
 
@@ -18,7 +72,7 @@
     - debian/drbd0.7.dirs: removed usr/bin (closes: #276643).
     - debian/control: changed Section from misc to admin.
     - scripts/drbd: prevent the "stop" target from failing if drbd is not running
-    - debian/rules: call upstream Makefile targets instead of doing hardcoded stuff, clean.  
+    - debian/rules: call upstream Makefile targets instead of doing hardcoded stuff, clean.
     - debian/drbd0.7.docs: added upgrade_0.6.x_to_0.7.0.txt and upgrade_0.7.0_to_0.7.1.txt.
     - The package drbd as been renamed to drbd0.7-utils and drbd-source as
       been renamed to drbd0.7-module-source.  We'll introduce drbd0.6-*
@@ -41,11 +95,11 @@
 drbd (0.7.4-1) unstable; urgency=low
 
   * Fixed a critical bug with Linux-2.4.x and HIGHMEM!
-  * Fixed a bug that only showed up with the HIGHMEM problem on 
+  * Fixed a bug that only showed up with the HIGHMEM problem on
     Linux-2.4.x -> It caused the resync process to starve.
   * The drbd.spec file now creates /dev/drbd in the post-install stage.
   * Fixed support for more than 2TB storage. Now DRBD supports up to
-    3.99TB storage. It will also tell you, that it is not supported if 
+    3.99TB storage. It will also tell you, that it is not supported if
     you try to set up a bigger device.
   * Debian's build rules file now knows about the adjust_drbd_config_h.sh
     file.
@@ -75,7 +129,7 @@
 
 drbd (0.7.2-1) unstable; urgency=low
 
-  * Proper handling of backing storage devices that occasionally fail 
+  * Proper handling of backing storage devices that occasionally fail
     READA (=read ahead) requests. (E.g. LVM and MD)
   * DRBD now fails READA requests itself, if a resynchronisation is running
     and it would need to fetch the block from its peer.
@@ -94,7 +148,7 @@
   * Handle the human and the timeout count correctly in the new init script.
   * The implementation of the incon-degr-cmd was missing, added.
   * Fix for integer overflow in /proc/drbd syncer progress display
-  * Longer timeouts in drbdadm for drbdsetup commands witch operate on 
+  * Longer timeouts in drbdadm for drbdsetup commands witch operate on
     meta data.
   * New major number 147 (officially registered at lanana.org).
   * Added a missing w_resume_next_wg() in case we stop syncing because
@@ -116,7 +170,7 @@
     calling to __*, giving file and line information,
     to be able to easily track causes of "strange state"s there.
   * rs_total is now != 0 only if we actually ARE syncing.
-    it is reset 
+    it is reset
   * when sync is done
   * when connection is lost
   * when storage is lost on either node
@@ -152,54 +206,54 @@
  -- Lars Ellenberg <l.g.e@web.de>  Fri, 09 Jul 2004 20:00:19 +0200
 
 drbd (0.7_pre8-2) unstable; urgency=low
-  
+
   * fix up the modules source package
-  
- -- Bernd Schubert <bernd-schubert@web.de>  Mon,  05 Jul 2004 00:57:38 -0100  
 
+ -- Bernd Schubert <bernd-schubert@web.de>  Mon,  05 Jul 2004 00:57:38 -0100
+
 drbd (0.7_pre8-1) unstable; urgency=low
-  
+
   * initial 0.7 debian package
-  
- -- Bernd Schubert <bernd-schubert@web.de>  Mon,  21 Jun 2004 19:57:38 -0400  
 
+ -- Bernd Schubert <bernd-schubert@web.de>  Mon,  21 Jun 2004 19:57:38 -0400
+
 drbd (0.6.12-5) unstable; urgency=low
-  
+
   * Changed default drbd.conf file to set a negative inittimeout value and
-    updated the README.Debian file to reflect this change.  
+    updated the README.Debian file to reflect this change.
     (Closes Bug#221751)
-  
+
  -- David Krovich <dkrovich@csee.wvu.edu>  Tue, 25 May 2004 12:51:15 -0400
 
 drbd (0.6.12-4) unstable; urgency=low
-  
-  * Refactored rules file in an attempt to use binary-arch and binary-indep 
-    targets more wisely. This is an attempt to fix Bug#244392.  
+
+  * Refactored rules file in an attempt to use binary-arch and binary-indep
+    targets more wisely. This is an attempt to fix Bug#244392.
   * Listed /etc/ha.d/resource.d/drbd in debian/conffiles.  (Closes Bug#247606)
   * Moved drbdsetup from /usr/bin/ to /usr/sbin.  I think I introduced this
-    when I overhauled the debian directory in the 0.6.12-1 release.  
+    when I overhauled the debian directory in the 0.6.12-1 release.
     (Closes Bug#247607)
-  
- -- David Krovich <dkrovich@csee.wvu.edu>  Sun, 16 May 2004 15:20:59 -0400  
 
+ -- David Krovich <dkrovich@csee.wvu.edu>  Sun, 16 May 2004 15:20:59 -0400
+
 drbd (0.6.12-3) unstable; urgency=low
-  
+
   * After discussing with upstream, tweak /etc/init.d/drbd script so the
     stop target works if the module is not loaded.  (Closes: Bug#243417)
   * Put the drbd script in the /etc/ha.d/resource.d directory.  (Closes: Bug#245219)
-  
+
  -- David Krovich <dkrovich@csee.wvu.edu>  Thu, 22 Apr 2004 18:12:47 -0400
 
 drbd (0.6.12-2) unstable; urgency=low
-  
+
   * Create /dev/nb[0-7] devices in postinst script.  (Closes: Bug#221545)
-  
+
  -- David Krovich <dkrovich@csee.wvu.edu>  Sat, 17 Apr 2004 15:18:29 -0400
-  
+
 drbd (0.6.12-1) unstable; urgency=low
-  
+
   * new upstream release.  (Closes: Bug#239804)
-  * Completely overhauled the debian/ directory.  
+  * Completely overhauled the debian/ directory.
   * Changed sequence number in the runlevel to start at 70 and stop
     at 08.  drbd should start after things like ssh, but before
     heartbeat.
@@ -208,12 +262,12 @@
 
 drbd (0.6.10-3) unstable; urgency=low
   * Added back the drbd.postinst, drbd.postrm, and drbd.prerm scripts until
-    I figure out why they aren't being handled by dh_installinit.  
-  * As of drbd-0.6.9, The drbd module no longer builds against just the 
+    I figure out why they aren't being handled by dh_installinit.
+  * As of drbd-0.6.9, The drbd module no longer builds against just the
     kernel-headers package and now needs a full kernel-source tree.
 
- -- David Krovich <dkrovich@csee.wvu.edu>  Mon, 26 Jan 2004 00:32:49 -0500  
-  
+ -- David Krovich <dkrovich@csee.wvu.edu>  Mon, 26 Jan 2004 00:32:49 -0500
+
 drbd (0.6.10-2) unstable; urgency=low
 
   * noel: fixed lintian warning:
@@ -223,19 +277,19 @@
   * Lintian/Linda fixes.
 
   * Tweaked the drbd-0.6.10.orig.tar.gz to not have a debian/ directory in it.
-  * Stopped tweaking the copyright notice on drbd_fs.c and drbd_receiver.c. 
+  * Stopped tweaking the copyright notice on drbd_fs.c and drbd_receiver.c.
     I'm not sure how that got there in the first place.
-  * Removed mystery report_to_html.pl.debdiff file.  
+  * Removed mystery report_to_html.pl.debdiff file.
   * Put the datadisk in the correct location.  (Closes: Bug#221544)
-  
+
   * Removed drbd.postinst, drbd.postrm, and drbd.prerm as they are
     being generated by dh_installinit during the build process and do not
     need to part of the source package.
   * removed dependancy on automake and autoconf
   * Changed control.modules to require debhelper >= 4.
-  * Stop settting $KSRC in the rules file.  
+  * Stop settting $KSRC in the rules file.
 
-  * Removed conffiles, files, kernel-patch-wup.substvars as they are 
+  * Removed conffiles, files, kernel-patch-wup.substvars as they are
     unneccessary.
   * Tightened the build dependancy on debhelper. >=4
   * Updated Debian packages up to newest upstream version. (Closes: Bug#197906)
@@ -243,18 +297,18 @@
   * Verified support for devfs.  (Closes: Bug#203552)
   * I'd like to become a Debian Developer and take over maintenance for
     this package.  I'm working with Debian Devolpers on making this happen.
-  
+
  -- David Krovich <dkrovich@csee.wvu.edu>  Tue, 20 Jan 2004 01:36:58 -0500
 
 drbd (0.6.10-1) unstable; urgency=low
 
-  * With 0.6.9 there was a bug introduced which prevented the sending 
+  * With 0.6.9 there was a bug introduced which prevented the sending
     of ACK packets during resync. Fixed.
   * A fix to drbdsetup's wait_connect command.
-  * Replaced all invocations of the sleep_on() family functions with the 
-    invocations of the wait_event() macros. This removes lost wakup events 
+  * Replaced all invocations of the sleep_on() family functions with the
+    invocations of the wait_event() macros. This removes lost wakup events
     and race conditions.
-  * New implementation of drbd_wait_ee(). This makes the 
+  * New implementation of drbd_wait_ee(). This makes the
     "(BUG?) Moving bh=%p to done_ee" go away.
   * Handle the case if vmalloc() of the bitmap fails.
 
@@ -263,14 +317,14 @@
 drbd (0.6.9-1) unstable; urgency=low
 
   * New module build system (using kernel source tree build system)
-  * New net section option 'ko-count'. It allows you to kick out a 
-    secondary node which does no longer process data in acceptable time. 
+  * New net section option 'ko-count'. It allows you to kick out a
+    secondary node which does no longer process data in acceptable time.
     Its default value is 0 which disables this feature.
   * Changing syncgroups while resync runs has shows now the correct behaviour.
   * In case thread creations fails DRBD would deadlock on its own
     semaphore. Fixed now.
   * BKL is no longer used on Linux-2.4.x.
-  * Now you can stack mapping block devices like LVM2 (and maybe md) on 
+  * Now you can stack mapping block devices like LVM2 (and maybe md) on
     top of drbd (a one character fix).
   * drbdsetup wait_connect on a StandAlone node looked like a timeout and
     forced primary. fixed.
@@ -292,7 +346,7 @@
 
 drbd (0.6.7-1) unstable; urgency=low
 
-  * A fix to a bug that could cause data corruption if you use a 
+  * A fix to a bug that could cause data corruption if you use a
     other blocksize than 4k to access the DRBD device.
   * A fix to a SMP race in the syncer code. The problem was tirggered
     when using DRBD on QLogic fiber channel adapters.
@@ -307,7 +361,7 @@
   * In the 0.6.5 release the secondary_remote command was badly broken,
     it succeeded when it should fail silently. This is fixed now.
   * Probabely in all previous releases, the resyncer thread did not
-    exit properly if the secondary node goes away during resync. 
+    exit properly if the secondary node goes away during resync.
     This was not fatal sind the resyncher thread did exit at soon
     as it gets a network error. This is fixed now.
   * Some new switches to the drbd script.
@@ -383,7 +437,7 @@
     -pre versions sanely
   * uploading to unstable. (Closes: Bug#130031)
 
- -- Jan Niehusmann <jan@debian.org>  Wed, 11 Sep 2002 13:10:03 +0200 
+ -- Jan Niehusmann <jan@debian.org>  Wed, 11 Sep 2002 13:10:03 +0200
 
 drbd (cvs20010511-1) unstable; urgency=low
 

Modified: trunk/drbd/Makefile
===================================================================
--- trunk/drbd/Makefile	2005-07-26 11:37:12 UTC (rev 1899)
+++ trunk/drbd/Makefile	2005-07-26 12:05:27 UTC (rev 1900)
@@ -64,19 +64,11 @@
     KDIR := /lib/modules/$(shell uname -r)/build
   endif
 
-  KDIR_Makefile_PATCHLEVEL = $(shell grep "^PATCHLEVEL = " $(KDIR)/Makefile | cut -d " " -f 3 )
+  KDIR_Makefile_PATCHLEVEL = $(shell test -e $(KDIR)/Makefile && grep "^PATCHLEVEL = " $(KDIR)/Makefile | cut -d " " -f 3)
   ifneq ($(findstring $(KDIR_Makefile_PATCHLEVEL),12345),)
     $(error "won't compile with this kernel version")
   endif
 
-  # shell ls, because some of them may be missing
-  # inside a patched kernel source tree
-  SRC_FILES := $(shell ls 2>/dev/null\
-	linux/drbd_config.h linux/drbd.h drbd_actlog.c drbd_bitmap.c drbd_fs.c \
-	drbd_main.c drbd_proc.c drbd_receiver.c drbd_req.c drbd_worker.c \
-	drbd_strings.c lru_cache.c drbd_compat_wrappers.h drbd_int.h \
-	lru_cache.h )
-
   .PHONY: drbd.o default all greeting clean kbuild install dep
 
   drbd.o: greeting kbuild
@@ -87,17 +79,31 @@
 	@echo "" ;\
 	echo "    Calling toplevel makefile of kernel source tree, which I believe is in" ;\
 	echo "    KDIR=$(KDIR)" ; \
-	echo ""
+	echo "";
+	@if ! test -e $(KDIR)/Makefile ; then \
+		echo -e "    SORRY, kernel makefile not found. You need to tell me a correct KDIR!\n" ;\
+		false;\
+	fi
 
-  drbd_buildtag.c: $(SRC_FILES)
-	@if grep ^drbd/drbd_buildtag.c: ../Makefile &>/dev/null; then \
-	  $(MAKE) -C .. drbd/drbd_buildtag.c ;\
-	 else \
-	  echo "drbd_buildtag.c outdated." ;\
-	  echo "you probably need to do a 'make' in DRBDs toplevel directory.";\
-	  false ;\
-	 fi
+.PHONY: drbd_buildtag.c
 
+  drbd_buildtag.c:
+	@is_tarball=`test -e .svn/. -a -e ../.svn/. && echo false || echo true`;\
+	set -e; exec > $@.new;							\
+	echo -e "/* automatically generated. DO NOT EDIT. */";			\
+	echo -e "const char * drbd_buildtag(void)\n{";				\
+	if $$is_tarball; then							\
+	  if ! test -e $@ ; then 						\
+	  	echo >&2 "your DRBD source tree is broken. unpack again.";	\
+		exit 1;								\
+	  fi;									\
+	  grep return $@ ;							\
+	else									\
+	  echo -ne "\treturn \"SVN Revision: "; svnversion -n ..; echo \";	\
+	fi ;									\
+	echo -e "\t\t\" build by $$USER@$$HOSTNAME, `date "+%F %T"`\";\n}";	\
+       	mv $@{.new,}
+
   kbuild: drbd_buildtag.c
 	@rm -f .kernelrelease*
     # previous to 2.6.6 (suse: 2.6.5-dunno), this should be:
@@ -118,6 +124,7 @@
 	@echo "done."
 
   clean:
+	rm -rf .tmp_versions
 	rm -f *.[oas] *.ko .*.cmd .*.d .*.tmp *.mod.c .*.flags .depend .kernel*
 
   distclean: clean

Modified: trunk/drbd/drbd_actlog.c
===================================================================
--- trunk/drbd/drbd_actlog.c	2005-07-26 11:37:12 UTC (rev 1899)
+++ trunk/drbd/drbd_actlog.c	2005-07-26 12:05:27 UTC (rev 1900)
@@ -121,15 +121,15 @@
 
 	if (sector < drbd_md_ss(mdev)  ||
 	    sector > drbd_md_ss(mdev)+MD_BM_OFFSET+BM_SECT_TO_EXT(capacity)) {
-		ALERT("%s [%d]:%s(,%ld,%s) out of range md access!\n",
+		ALERT("%s [%d]:%s(,%llu,%s) out of range md access!\n",
 		     current->comm, current->pid, __func__,
-		     (long)sector, rw ? "WRITE" : "READ");
+		     (unsigned long long)sector, rw ? "WRITE" : "READ");
 	}
 
 	ok = _drbd_md_sync_page_io(mdev,iop,sector,rw,hardsect);
 	if (unlikely(!ok)) {
-		ERR("drbd_md_sync_page_io(,%lu,%s) failed!\n",
-		    (unsigned long)sector,rw ? "WRITE" : "READ");
+		ERR("drbd_md_sync_page_io(,%llu,%s) failed!\n",
+		    (unsigned long long)sector,rw ? "WRITE" : "READ");
 	}
 
 	if( hardsect != MD_HARDSECT && rw == READ ) {
@@ -643,6 +643,7 @@
 	unsigned long sbnr,ebnr,lbnr,bnr;
 	unsigned long count = 0;
 	sector_t esector, nr_sectors;
+	int wake_up=0;
 
 	if (size <= 0 || (size & 0x1ff) != 0 || size > PAGE_SIZE) {
 		ERR("drbd_set_in_sync: sector=%lu size=%d nonsense!\n",
@@ -680,23 +681,24 @@
 	 * ok, (capacity & 7) != 0 sometimes, but who cares...
 	 * we count rs_{total,left} in bits, not sectors.
 	 */
+	spin_lock_irq(&mdev->al_lock);
 	for(bnr=sbnr; bnr <= ebnr; bnr++) {
 		if (drbd_bm_clear_bit(mdev,bnr)) count++;
 	}
 	if (count) {
 		// we need the lock for drbd_try_clear_on_disk_bm
-		spin_lock_irq(&mdev->al_lock);
 		if(jiffies - mdev->rs_mark_time > HZ*10) {
 			/* should be roling marks, but we estimate only anyways. */
 			mdev->rs_mark_time = jiffies;
 			mdev->rs_mark_left = drbd_bm_total_weight(mdev);
 		}
 		drbd_try_clear_on_disk_bm(mdev,sector,count);
-		spin_unlock_irq(&mdev->al_lock);
 		/* just wake_up unconditional now,
 		 * various lc_chaged(), lc_put() in drbd_try_clear_on_disk_bm(). */
-		wake_up(&mdev->al_wait);
+		wake_up=1;
 	}
+	spin_unlock_irq(&mdev->al_lock);
+	if(wake_up) wake_up(&mdev->al_wait);
 }
 
 /*

Modified: trunk/drbd/drbd_fs.c
===================================================================
--- trunk/drbd/drbd_fs.c	2005-07-26 11:37:12 UTC (rev 1899)
+++ trunk/drbd/drbd_fs.c	2005-07-26 12:05:27 UTC (rev 1900)
@@ -52,16 +52,29 @@
 int drbd_determin_dev_size(struct Drbd_Conf* mdev)
 {
 	sector_t pmdss; // previous meta data start sector
+	sector_t la_size;
+	int md_moved, la_size_changed;
 	int rv;
 
 	wait_event(mdev->al_wait, lc_try_lock(mdev->act_log));
 	pmdss = drbd_md_ss(mdev);
+	la_size = mdev->la_size;
+
 	rv = do_determin_dev_size(mdev);
-	if ( pmdss != drbd_md_ss(mdev) && mdev->md_index == -1 ) {
+
+	la_size_changed = (la_size != mdev->la_size);
+	md_moved = pmdss != drbd_md_ss(mdev) /* && mdev->md_index == -1 */;
+
+	if ( md_moved ) {
 		WARN("Moving meta-data.\n");
+		D_ASSERT(mdev->md_index == -1);
+	}
+
+	if ( la_size_changed || md_moved ) {
 		drbd_al_shrink(mdev); // All extents inactive.
 		drbd_bm_write(mdev);  // write bitmap
-		drbd_md_write(mdev);  // Write mdev->la_size to disk.
+		// Write mdev->la_size to [possibly new position on] disk.
+		drbd_md_write(mdev);
 	}
 	lc_unlock(mdev->act_log);
 
@@ -421,6 +434,7 @@
 	drbd_determin_dev_size(mdev);
 	/* FIXME
 	 * what if we now have la_size == 0 ?? eh?
+	 * BOOM?
 	 */
 
 	if (drbd_md_test_flag(mdev,MDF_FullSync)) {
@@ -755,6 +769,8 @@
 		 * become Secondary. */
 		if (bd_claim(mdev->this_bdev,drbd_sec_holder))
 			return -EBUSY;
+		if (disable_bd_claim)
+			bd_release(mdev->this_bdev);
 	}
 
 	spin_lock_irq(&mdev->req_lock);

Modified: trunk/drbd/drbd_int.h
===================================================================
--- trunk/drbd/drbd_int.h	2005-07-26 11:37:12 UTC (rev 1899)
+++ trunk/drbd/drbd_int.h	2005-07-26 12:05:27 UTC (rev 1900)
@@ -38,6 +38,7 @@
 
 // module parameter, defined in drbd_main.c
 extern int minor_count;
+extern int disable_bd_claim;
 extern int major_nr;
 extern int use_nbd_major;
 
@@ -748,7 +749,6 @@
 	struct list_head resync_reads;
 	atomic_t pp_in_use;
 	wait_queue_head_t ee_wait;
-	struct list_head busy_blocks;
 	struct page *md_io_page;      // one page buffer for md_io
 	struct page *md_io_tmpp;     // in case hardsect != 512 [ s390 only? ]
 	struct semaphore md_io_mutex; // protects the md_io_buffer
@@ -931,11 +931,15 @@
 #define BM_EXT_PER_SECT	    ( 512 / BM_BYTES_PER_EXTENT )        //   4
  */
 
-#if ( !defined(CONFIG_LBD) ) && ( BITS_PER_LONG == 32 )
-# define DRBD_MAX_SECTORS (0xffffffffLU)
+#define DRBD_MAX_SECTORS_32 (0xffffffffLU)
+#define DRBD_MAX_SECTORS_BM \
+          ( (MD_RESERVED_SIZE*2LL - MD_BM_OFFSET) * (1LL<<(BM_EXT_SIZE_B-9)) )
+#if DRBD_MAX_SECTORS_BM < DRBD_MAX_SECTORS_32
+#define DRBD_MAX_SECTORS DRBD_MAX_SECTORS_BM
+#elif ( !defined(CONFIG_LBD) ) && ( BITS_PER_LONG == 32 )
+#define DRBD_MAX_SECTORS DRBD_MAX_SECTORS_32
 #else
-# define DRBD_MAX_SECTORS \
-          ( (MD_RESERVED_SIZE*2LL - MD_BM_OFFSET) * (1LL<<(BM_EXT_SIZE_B-9)) )
+#define DRBD_MAX_SECTORS DRBD_MAX_SECTORS_BM
 #endif
 
 /* Sector shift value for hash functions for tl_hash table and ee_hash

Modified: trunk/drbd/drbd_main.c
===================================================================
--- trunk/drbd/drbd_main.c	2005-07-26 11:37:12 UTC (rev 1899)
+++ trunk/drbd/drbd_main.c	2005-07-26 12:05:27 UTC (rev 1900)
@@ -82,6 +82,7 @@
 MODULE_ALIAS_BLOCKDEV_MAJOR(LANANA_DRBD_MAJOR);
 
 #include <linux/moduleparam.h>
+MODULE_PARM_DESC(disable_bd_claim, "DONT USE! disables block device claiming" );
 /*
  * please somebody explain to me what the "perm" of the module_param
  * macro is good for (yes, permission for it in the "driverfs", but what
@@ -96,6 +97,7 @@
  * this becomes the boot parameter drbd.minor_count
  */
 module_param(minor_count,      int,0);
+module_param(disable_bd_claim,bool,0);
 
 // module parameter, defined
 int major_nr = LANANA_DRBD_MAJOR;
@@ -104,6 +106,7 @@
 #else
 int minor_count = 8;
 #endif
+int disable_bd_claim = 0;
 
 // devfs name
 char* drbd_devfs_name = "drbd";
@@ -1671,7 +1674,6 @@
 	INIT_LIST_HEAD(&mdev->done_ee);
 	INIT_LIST_HEAD(&mdev->read_ee);
 	INIT_LIST_HEAD(&mdev->net_ee);
-	INIT_LIST_HEAD(&mdev->busy_blocks);
 	INIT_LIST_HEAD(&mdev->app_reads);
 	INIT_LIST_HEAD(&mdev->resync_reads);
 	INIT_LIST_HEAD(&mdev->data.work.q);
@@ -1784,7 +1786,6 @@
 	D_ASSERT(list_empty(&mdev->done_ee));
 	D_ASSERT(list_empty(&mdev->read_ee));
 	D_ASSERT(list_empty(&mdev->net_ee));
-	D_ASSERT(list_empty(&mdev->busy_blocks));
 	D_ASSERT(list_empty(&mdev->app_reads));
 	D_ASSERT(list_empty(&mdev->resync_reads));
 	D_ASSERT(list_empty(&mdev->data.work.q));
@@ -2003,6 +2004,7 @@
 	int i,err;
 
 #if 0
+#warning "DEBUGGING"
 /* I am too lazy to calculate this by hand	-lge
  */
 #define SZO(x) printk(KERN_ERR "sizeof(" #x ") = %d\n", sizeof(x))
@@ -2107,6 +2109,8 @@
 		if (bd_claim(mdev->this_bdev,drbd_sec_holder)) {
 			// Initial we are Secondary -> should claim myself.
 			WARN("Could not bd_claim() myself.");
+		} else if (disable_bd_claim) {
+			bd_release(mdev->this_bdev);
 		}
 
 		blk_queue_make_request(q, drbd_make_request_26);
@@ -2249,7 +2253,7 @@
 	u32 al_offset;         // offset to this block
 	u32 al_nr_extents;     // important for restoring the AL
 	u32 bm_offset;         // offset to the bitmap, from here
-};
+} __attribute((packed));
 
 /*
 

Modified: trunk/drbd/drbd_receiver.c
===================================================================
--- trunk/drbd/drbd_receiver.c	2005-07-26 11:37:12 UTC (rev 1899)
+++ trunk/drbd/drbd_receiver.c	2005-07-26 12:05:27 UTC (rev 1900)
@@ -357,7 +357,6 @@
 
 	if( test_and_set_bit(PROCESS_EE_RUNNING,&mdev->flags) ) {
 		if(!be_sleepy) {
-			clear_bit(PROCESS_EE_RUNNING,&mdev->flags);
 			return 3;
 		}
 		spin_unlock_irq(&mdev->ee_lock);
@@ -1436,7 +1435,7 @@
 {
 	Drbd_Sizes_Packet *p = (Drbd_Sizes_Packet*)h;
 	unsigned int max_seg_s;
-	sector_t p_size;
+	sector_t p_size, p_usize;
 	drbd_conns_t nconn;
 
 	ERR_IF(h->length != (sizeof(*p)-sizeof(*h))) return FALSE;
@@ -1454,14 +1453,30 @@
 
 	drbd_bm_lock(mdev); // {
 	mdev->p_size=p_size;
-	if( mdev->lo_usize != be64_to_cpu(p->u_size) ) {
-		mdev->lo_usize = be64_to_cpu(p->u_size);
+	p_usize=be64_to_cpu(p->u_size);
+	/*
+	 * you may get a flip-flop connection established/connection loss, in
+	 * case both really have different usize uppon first connect!
+	 * try to solve it thus:
+	 ***/
+#define min_not_zero(l, r) (l == 0) ? r : ((r == 0) ? l : min(l, r))
+	if (mdev->state.s.conn == WFReportParams) {
+		/* this is first connect, or an otherwise expected param
+		 * exchange.  choose the minimum */
+		p_usize = min_not_zero(mdev->lo_usize, p_usize);
+	} else {
+		/* this was an "unexpected" param packet,
+		 * just do what the peer suggests */
+	}
+#undef min_not_zero
+	if( mdev->lo_usize != p_usize ) {
+		mdev->lo_usize = p_usize;
 		INFO("Peer sets u_size to %lu KB\n",
 		     (unsigned long)mdev->lo_usize);
 	}
 	drbd_determin_dev_size(mdev);
 	drbd_bm_unlock(mdev); // }
-	
+
 	if (mdev->p_uuid) {
 		nconn=drbd_sync_handshake(mdev);
 		kfree(mdev->p_uuid);

Modified: trunk/drbd/drbd_req.c
===================================================================
--- trunk/drbd/drbd_req.c	2005-07-26 11:37:12 UTC (rev 1899)
+++ trunk/drbd/drbd_req.c	2005-07-26 12:05:27 UTC (rev 1900)
@@ -177,11 +177,15 @@
 		return 0;
 	}
 
-	/* FIXME
-	 * not always true, e.g. someone trying to mount on Secondary
-	 * maybe error out immediately here?
-	 */
-	D_ASSERT(mdev->state.s.role == Primary);
+	if (mdev->state.s.role != Primary &&
+		( !disable_bd_claim || rw == WRITE ) ) {
+		if (DRBD_ratelimit(5*HZ,5)) {
+			ERR("Not in Primary state, no %s requests allowed\n",
+					disable_bd_claim ? "WRITE" : "IO");
+		}
+		drbd_bio_IO_error(bio);
+		return 0;
+	}
 
 	/*
 	 * Paranoia: we might have been primary, but sync target, or

Modified: trunk/drbd/linux/drbd.h
===================================================================
--- trunk/drbd/linux/drbd.h	2005-07-26 11:37:12 UTC (rev 1899)
+++ trunk/drbd/linux/drbd.h	2005-07-26 12:05:27 UTC (rev 1900)
@@ -221,11 +221,11 @@
 
 typedef union {
 	struct {
-		unsigned role : 2 ;   // 3/3      primary/secondary/unknown
-		unsigned peer : 2 ;   // 3/3      primary/secondary/unknown
+		unsigned role : 2 ;   // 3/4      primary/secondary/unknown
+		unsigned peer : 2 ;   // 3/4      primary/secondary/unknown
 		unsigned conn : 5 ;   // 17/32    cstates
-		unsigned disk : 3 ;   // 7/7      from Diskless to UpToDate
-		unsigned pdsk : 3 ;   // 7/7      from Diskless to UpToDate
+		unsigned disk : 3 ;   // 7/8      from Diskless to UpToDate
+		unsigned pdsk : 3 ;   // 7/8      from Diskless to UpToDate
 		unsigned susp : 1 ;   // 2/2      IO suspended  no/yes
 		unsigned _pad : 16;   // 0        unused
 	} s;

Modified: trunk/drbd.spec.in
===================================================================
--- trunk/drbd.spec.in	2005-07-26 11:37:12 UTC (rev 1899)
+++ trunk/drbd.spec.in	2005-07-26 12:05:27 UTC (rev 1900)
@@ -51,6 +51,8 @@
 #Release: %{release}_%{krelver}
 Group: System Environment/Kernel
 Requires: %{name} = %{version}, /sbin/depmod
+# conflicts with the suse km_drbd package. use either theirs, or ours... 
+Conflicts: km_drbd
 #%{?ksmp:Provides: kernel-module-drbd = %{version}-%{release}_%{krelver}}
 
 #%description -n kernel%{?ksmp}-module-drbd
@@ -76,8 +78,13 @@
 make clean
 # note: MANDIR is not used anywhere in the makefiles
 #       maybe this should be changed
-make all doc PREFIX=%{buildroot}/ MANDIR=%{_mandir} KDIR=%{kdir}
-
+if [ -e /etc/redhat-release ]; then
+       # unset LOCALVERSION for building on RHEL AS 4
+       make all doc PREFIX=%{buildroot}/ MANDIR=%{_mandir} KDIR=%{kdir} LOCALVERSION=""
+else
+       # LOCALVERSION necessary for building on SuSE-9.3
+       make all doc PREFIX=%{buildroot}/ MANDIR=%{_mandir} KDIR=%{kdir}
+fi
 %install
 make install PREFIX=%{buildroot}/ MANDIR=%{_mandir}
 cd drbd
@@ -137,6 +144,12 @@
 %doc drbd/k-config-%{kernelversion}.gz
 
 %post
+# hack for distribution kernel packages,
+# which already contain some (probably outdated) drbd module
+EXTRA_DRBD_KO=/lib/modules/%{kernelversion}/extra/drbd.ko
+if test -e $EXTRA_DRBD_KO; then
+	mv $EXTRA_DRBD_KO $EXTRA_DRBD_KO.orig
+fi
 chkconfig --add drbd
 
 for i in `seq 0 15` ; do 
@@ -163,6 +176,12 @@
 
 #%post -n kernel%{?ksmp}-module-drbd
 %post km-%{krelver}
+# hack for distribution kernel packages,
+# which already contain some (probably outdated) drbd module
+EXTRA_DRBD_KO=/lib/modules/%{kernelversion}/extra/drbd.ko
+if test -e $EXTRA_DRBD_KO; then
+	mv $EXTRA_DRBD_KO $EXTRA_DRBD_KO.orig
+fi
 uname -r | grep BOOT ||
 /sbin/depmod -a -F /boot/System.map-%{kernelversion} %{kernelversion} >/dev/null 2>&1 || true
 
@@ -171,11 +190,110 @@
 /sbin/depmod -a -F /boot/System.map-%{kernelversion} %{kernelversion} >/dev/null 2>&1 || true
 
 %changelog
-* Fri Oct 15 2004 19:53:21 +0200 Lars Ellenberg <l.g.e@web.de>
-- drbd (0.8_pre1-1)
+* Tue Jul 26 2005 11:53:11 +0200 Lars Ellenberg <lars@linbit.com>
+- drbd (0.8_pre1-3)
   * remove all kernel 2.4.x compatibility crap
-  * ioctl sanity checks about Unconfigured and CAP_SYS_ADMIN
 
+  FIXME mention all the great things we did so far
+
+* Tue Jun  7 2005 19:13:00 +0200 Lars Ellenberg <lars@linbit.com>
+- drbd (0.7.11-1)
+ * The upper limit of the runtime tuning parameter max_buffers 
+   was ways too low for today's IBM storage controllers. 
+   Was 32 - 10000 ; Now it is 32 - 131072 ( Now one could 
+   allow DRBD to allocate up to half a gigabyte of memory as 
+   receive buffers)
+ * A fix to the Makefiles to make building of RPMs work on RAHS4.
+ * A workaround to have DBRD running on PPC64 with Linux-2.4.x kernels,
+   on Linux-2.6.x everything was fine already.
+ * Removal of dead code (busy_blocks).
+ * LINBIT drbd rpms now conflict with km_drbd
+   (SuSE's kernel module source hook)
+ * possibly existing /lib/modules/*/extra/drbd.ko are renamed to .orig in the
+   post-install scripts to avoid conflicts with existing modules from
+   distribution kernel packages
+ * fixed flex input buffer overflow
+   drbdadm_scanner.fl produced tokens of arbitrary length due to excessive use
+   of "+" and "*" modifiers. Now these are replaced with "{x,y}" modifiers, so
+   it should no longer segfault, which was actually observed e.g. with long
+   continuous comment blocks (~5k). 
+
+* Mon Jan 31 2005 10:17:00 +0200 Philipp Reisner <phil@linbit.com>
+- drbd (0.7.10-1)
+ * 0.7.9 had a memory corruption bug and memory leakage (BIOs).
+   This time I did the clone_bio() fix myself, and this release is
+   supposed to work with SLES9 SP1, Linux-2.6.11 and Linux-2.6.12.
+
+* Tue Jan 25 2005 11:31:00 +0200 Philipp Reisner <phil@linbit.com>
+- drbd (0.7.9-1)
+ * A fix that makes DRBD work on SLES9 SP1 kernel, and 
+   probabely will be also necessary for Linux-2.6.11
+
+* Mon Jan 17 2005 12:55:01 +0200 Philipp Reisner <phil@linbit.com>
+- drbd (0.7.8-1)
+  * Fixed a bug that caused the syncer to starve on devices 
+    bigger than 2 TB on 32bit systems (=CONFIG_LBA).
+  * Made online resizing actually work. Now it makes a lot
+    more sense to put DRBD on top of LVM.
+  * Made the user dialog to work on RedHat based distributions.
+  * A small optimization that improves the performance of the 
+    syncer when woking with IBM's ServRaid Controllers (ips).
+    May have a positive effect with other Controllers as well.
+  * Made epoch_size atomic. This removes a SMP race condition that
+    could lead on some Xeon CPUs to an ASSERT printk, but did no other
+    harm than printing messages to the syslog
+  * Fixed write_gc.pl to work with the perl version delivered
+    with RHAS3.
+  * Made the initscript to abort if one of the setup commands fails.
+
+* Tue Dec 15 2004 15:50:00 +0200 Philipp Reisner <phil@linbit.com>
+- drbd (0.7.7-1)
+  * "drbdadm adjust [res...]" now does the calls to drbdsetup 
+    in an improved order, first the disk config of all devices,
+    then the syncer and net config last. With the old scheme
+    drbdadm run in a timeout when setting up more than about 
+    6 devices at once (startup script...).
+  * New progress indication in the startup script.
+  * Bugfix to a race that could cause a OOPS on a BUG() macro
+    in mod_timer while starting resync. The more devices you have 
+    the higher the probability to hit this race condition.
+  * Fixed a bug in the sync-groups conde, that only showed up
+    when you have more than 4 resources in your config. 
+    The resync process was continued too early on the node in
+    SyncTarget state.
+  * Fixed a stupid typo in the range-check code, that was intoduced
+    in 0.7.6. Drbdsetup allowed "max-buffers" to be in the range 
+    from 32 to 32.
+  * Makefiles are gcc-2.95 compatible again.
+
+* Tue Nov 16 2004 14:59:00 +0200 Philipp Reisner <phil@linbit.com>
+- drbd (0.7.6-1)
+  * Fixed bug that could cause a lockup of the receiver and
+    asender threads, the visible outcome was that the syncer
+    starves.
+  * Fixed a bug that under specific circumstandes caused that the
+    SyncSource node did not recognised that a resync process was
+    finished.
+  * "drbdadm invalidate [res]" was not working correct, while
+    "drbdadm invalidate_remote [res]" works. Fixed the former.
+  * Make DRBD work on Linux-2.6.10-rc2 and newer: Replaced
+    sock_alloc() by sock_create(), replaced TASK_ZOMBIE by 
+    EXIT_ZOMBIE.
+  * Range checks in drbdadm for all numeric configure parameters.
+  * A fix to make ioctl()s work on machines with 64bit kernel space 
+    and 32bit user space. 
+  * Ioctl()s are only allowed if the caller has CAP_SYS_ADMIN set.
+  * Removal of warnings on 64bit architectures.
+  * Backport of find_first_bit() for x86_64 aka AMD64 for use on 
+    that architecture under Linux-2.4.x
+  * Changed drbdadm to do the syncer config before the net config.
+  * Changed the way drbdadm determines the minor_count parameter for
+    module loading.
+  * Improvements to the drbddisk script, to do the right thing
+    in case Heartbeat is configured with a small timeout than DRBD.
+  * On request of the debian package maintainers, the debian directory
+    from SVN is not longer included in the tar.gz releases.
+
 * Fri Oct 1 2004 11:33:00 +0200 Philipp Reisner <phil@linbit.com>
 - drbd (0.7.5-1)
   * Fix a bug that could case read requests to return wrong data

Modified: trunk/testing/CTH/CTH_bash.helpers
===================================================================
--- trunk/testing/CTH/CTH_bash.helpers	2005-07-26 11:37:12 UTC (rev 1899)
+++ trunk/testing/CTH/CTH_bash.helpers	2005-07-26 12:05:27 UTC (rev 1900)
@@ -321,7 +321,7 @@
 	# configure all dm disks
 	for d in ${!Disk_*} ; do Heal_Disk $d ; done
 
-	# reset and up all DRBDs
+	# reset and attach all DRBDs
 	for d in ${!Drbd_*} ; do
 		drbd_to_env $d
 		echo "$conf" | on ${!left}:  drbd_append_config USIZE=$USIZE \
@@ -332,6 +332,13 @@
 			START_CLEAN=$DRBD_SKIP_INITIAL_SYNC
 	done
 
+	# configure syncer and network
+	for d in ${!Drbd_*} ; do
+		drbd_to_env $d
+		on ${!left}:  drbdadm_adjust name=$name
+		on ${!right}:  drbdadm_adjust name=$name
+	done
+
 	# wait for connect and initial sync (which should be skipped automatically)
 	for d in ${!Drbd_*} ; do
 		drbd_to_env $d

Modified: trunk/testing/CTH/functions.sh
===================================================================
--- trunk/testing/CTH/functions.sh	2005-07-26 11:37:12 UTC (rev 1899)
+++ trunk/testing/CTH/functions.sh	2005-07-26 12:05:27 UTC (rev 1900)
@@ -104,7 +104,7 @@
 	local cmd=`type $2|tail +2`
 	local env="\
 set -o errexit $DEBUG
-PATH=/root/bin:/usr/bin:/bin:/usr/sbin:/sbin
+PATH=/root/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/bin:/bin
 $(printf '%q\n' "${@:3}")
 "
 	local err
@@ -339,11 +339,19 @@
 	fi
 	sync
 	echo .
-	drbdadm up $RES
+	drbdadm attach $RES
 	# cat /proc/drbd
-	echo "up'ed drbd $RES on $HOSTNAME"
+	echo "attached drbd $RES on $HOSTNAME"
 }
 
+drbdadm_adjust()							# {{{3
+{
+	: ${name:?unknown resource name} 
+	drbdadm adjust $name
+	# cat /proc/drbd
+	echo "adjusted drbd $name on $HOSTNAME"
+}
+
 drbdadm_up()								# {{{3
 {
 	: ${name:?unknown resource name} 

Modified: trunk/user/drbd_limits.h
===================================================================
--- trunk/user/drbd_limits.h	2005-07-26 11:37:12 UTC (rev 1899)
+++ trunk/user/drbd_limits.h	2005-07-26 12:05:27 UTC (rev 1900)
@@ -49,8 +49,8 @@
   /* I don't think that a tcp send buffer of more than 10M is usefull */
   RANGE(SNDBUF_SIZE, 1, 10000000);
 
-  /* arbitrary. */
-  RANGE(MAX_BUFFERS, 32, 10000);
+  /* @4k PageSize -> 128kB - 512MB */
+  RANGE(MAX_BUFFERS, 32, 131072);
 
   /* 0 is disabled.
    * 200 should be more than enough even for very short timeouts */

Modified: trunk/user/drbdadm.h
===================================================================
--- trunk/user/drbdadm.h	2005-07-26 11:37:12 UTC (rev 1899)
+++ trunk/user/drbdadm.h	2005-07-26 12:05:27 UTC (rev 1900)
@@ -22,6 +22,8 @@
   SLEEPS_FOREVER       = 4,
 
   SUPRESS_STDERR       = 16,
+
+  DONT_REPORT_FAILED   = 0x80,
 };
 
 /* for check_uniq(): Check for uniqueness of certain values...
@@ -31,9 +33,11 @@
 /* for verify_ips(): are not verifyable ips fatal? */
 #define INVALID_IP_IS_INVALID_CONF 0
 
+
 struct d_globals
 {
   int disable_io_hints;
+  int disable_ip_verification;
   int minor_count;
   int dialog_refresh;
 };

Modified: trunk/user/drbdadm_main.c
===================================================================
--- trunk/user/drbdadm_main.c	2005-07-26 11:37:12 UTC (rev 1899)
+++ trunk/user/drbdadm_main.c	2005-07-26 12:05:27 UTC (rev 1900)
@@ -63,8 +63,9 @@
 struct adm_cmd {
   const char* name;
   int (* function)(struct d_resource*,const char* );
-  int show_in_usage;
-  int res_name_required;
+  int show_in_usage     :1;
+  int res_name_required :1;
+  int verify_ips        :1;
 };
 
 struct deferred_cmd
@@ -75,6 +76,7 @@
 };
 
 extern int yyparse();
+extern int yydebug;
 extern FILE* yyin;
 
 int adm_attach(struct d_resource* ,const char* );
@@ -102,7 +104,7 @@
 struct utsname nodeinfo;
 int line=1;
 int fline, c_resource_start;
-struct d_globals global_options = { 0, 0, 1 };
+struct d_globals global_options = { 0, 0, 0, 1 };
 char *config_file = NULL;
 struct d_resource* config = NULL;
 struct d_resource* common = NULL;
@@ -110,6 +112,7 @@
 int highest_minor;
 int config_valid=1;
 int dry_run;
+int do_verify_ips;
 char* drbdsetup;
 char* drbdmeta;
 char* setup_opts[10];
@@ -172,39 +175,40 @@
 };
 
 struct adm_cmd cmds[] = {
-  { "attach",            adm_attach,            1, 1 },
-  { "detach",            adm_generic_s,         1, 1 },
-  { "connect",           adm_connect,           1, 1 },
-  { "disconnect",        adm_generic_s,         1, 1 },
-  { "up",                adm_up,                1, 1 },
-  { "down",              adm_generic_s,         1, 1 },
-  { "primary",           adm_generic_s,         1, 1 },
-  { "secondary",         adm_generic_s,         1, 1 },
-  { "invalidate",        adm_generic_l,         1, 1 },
-  { "invalidate_remote", adm_generic_l,         1, 1 },
-  { "outdate",           adm_generic_b,         1, 1 },
-  { "resize",            adm_resize,            1, 1 },
-  { "syncer",            adm_syncer,            1, 1 },
-  { "adjust",            adm_adjust,            1, 1 },
-  { "wait_connect",      adm_wait_c,            1, 1 },
-  { "state",             adm_generic_s,         1, 1 },
-  { "cstate",            adm_generic_s,         1, 1 },
-  { "dump",              adm_dump,              1, 1 },
-  { "create-md",         admm_generic,          1, 1 },
-  { "show-gi",           adm_generic_b,         1, 1 },
-  { "get-gi",            adm_generic_b,         1, 1 },
-  { "dump-md",           admm_generic,          1, 1 },
-  { "set-gi",            admm_generic,          0, 1 },
-  { "pri-on-incon-degr", adm_khelper,           0, 1 },
-  { "pri-sees-sec-with-higher-gc", adm_khelper, 0, 1 },
-  { "outdate-peer",      adm_khelper,           0, 1 },
-  { "wait_con_int",      adm_wait_ci,           1, 0 },
-  { "sh-resources",      sh_resources,          0, 0 },
-  { "sh-mod-parms",      sh_mod_parms,          0, 0 },
-  { "sh-dev",            sh_dev,                0, 1 },
-  { "sh-ll-dev",         sh_ll_dev,             0, 1 },
-  { "sh-md-dev",         sh_md_dev,             0, 1 },
-  { "sh-md-idx",         sh_md_idx,             0, 1 }
+/*   name, function,                  show, needs res, verify_ips */
+  { "attach",            adm_attach,    1,1,1 },
+  { "detach",            adm_generic_s, 1,1,1 },
+  { "connect",           adm_connect,   1,1,1 },
+  { "disconnect",        adm_generic_s, 1,1,0 },
+  { "up",                adm_up,        1,1,1 },
+  { "down",              adm_generic_s, 1,1,0 },
+  { "primary",           adm_generic_s, 1,1,1 },
+  { "secondary",         adm_generic_s, 1,1,1 },
+  { "invalidate",        adm_generic_l, 1,1,1 },
+  { "invalidate_remote", adm_generic_l, 1,1,1 },
+  { "outdate",           adm_generic_b, 1,1,0 },
+  { "resize",            adm_resize,    1,1,1 },
+  { "syncer",            adm_syncer,    1,1,1 },
+  { "adjust",            adm_adjust,    1,1,1 },
+  { "wait_connect",      adm_wait_c,    1,1,1 },
+  { "state",             adm_generic_s, 1,1,0 },
+  { "cstate",            adm_generic_s, 1,1,1 },
+  { "dump",              adm_dump,      1,1,1 },
+  { "create-md",         admm_generic,  1,1,0 },
+  { "show-gi",           adm_generic_b, 1,1,0 },
+  { "get-gi",            adm_generic_b, 1,1,0 },
+  { "dump-md",           admm_generic,  1,1,0 },
+  { "set-gi",            admm_generic,  0,1,0 },
+  { "pri-on-incon-degr", adm_khelper,   0,1,0 },
+  { "pri-sees-sec-with-higher-gc", adm_khelper, 0,1,0 },
+  { "outdate-peer",      adm_khelper,   0,1,0 },
+  { "wait_con_int",      adm_wait_ci,   1,0,1 },
+  { "sh-resources",      sh_resources,  0,0,0 },
+  { "sh-mod-parms",      sh_mod_parms,  0,0,0 },
+  { "sh-dev",            sh_dev,        0,1,0 },
+  { "sh-ll-dev",         sh_ll_dev,     0,1,0 },
+  { "sh-md-dev",         sh_md_dev,     0,1,0 },
+  { "sh-md-idx",         sh_md_idx,     0,1,0 },
 };
 
 /*** These functions are used to the print the config ***/
@@ -250,17 +254,17 @@
 
 static void dump_global_info()
 {
-  if (global_options.minor_count || global_options.disable_io_hints)
-    {
-      printI("global {\n"); ++indent;
-      if (global_options.disable_io_hints)
-	printI("disable-io-hints;\n");
-      if (global_options.minor_count)
-	printI("minor-count %i;\n", global_options.minor_count);
-      if (global_options.dialog_refresh != 1)
-	printI("dialog-refresh %i;\n", global_options.dialog_refresh);
-      --indent; printI("}\n\n");
-    }
+  if (  !global_options.minor_count
+     && !global_options.disable_ip_verification
+     &&  global_options.dialog_refresh == 1 ) return;
+  printI("global {\n"); ++indent;
+  if (global_options.disable_ip_verification)
+    printI("disable-ip-verification;\n");
+  if (global_options.minor_count)
+    printI("minor-count %i;\n", global_options.minor_count);
+  if (global_options.dialog_refresh != 1)
+    printI("dialog-refresh %i;\n", global_options.dialog_refresh);
+  --indent; printI("}\n\n");
 }
 
 static void dump_common_info()
@@ -540,7 +544,7 @@
   if( flags & SLEEPS_FINITE ) {
     alarm(0);
     sigaction(SIGALRM,&so,NULL);
-    if(rv >= 10 && !(flags & SUPRESS_STDERR) ) {
+    if(rv >= 10 && !(flags & (DONT_REPORT_FAILED|SUPRESS_STDERR))) {
       fprintf(stderr,"Command '");
       while(*argv) {
 	fprintf(stderr,"%s",*argv++);
@@ -937,15 +941,21 @@
     pids[i++]=m_system(argv,RETURN_PID);
   }
 
-  wtime = global_options.dialog_refresh ? 
+  wtime = global_options.dialog_refresh ?
     global_options.dialog_refresh : -1;
 
   start = time(0);
-  rr = gets_timeout(pids,0,0,3*1000); // no string, but timeout of 3 seconds.
-  check_exit_codes(pids);
+  for (i = 0; i < 10; i++) {
+    // no string, but timeout
+    rr = gets_timeout(pids,0,0,1*1000);
+    if (rr < 0) break;
+    putchar('.');
+    fflush(stdout);
+    check_exit_codes(pids);
+  }
 
   if(rr == 0) {
-    printf("***************************************************************\n"
+    printf("\n***************************************************************\n"
 	   " DRBD's startup script waits for the peer node(s) to appear.\n"
 	   " - In case this node was already a degraded cluster before the\n"
 	   "   reboot the timeout is %s seconds. [degr-wfc-timeout]\n"
@@ -973,7 +983,6 @@
 	  printf(" To abort waiting enter 'yes' [ -- ]:");
 	}
       }
-      
     } while( rr != -1 );
     printf("\n");
   }
@@ -986,7 +995,7 @@
   return 0;
 }
 
-void print_usage()
+void print_usage_and_exit(const char* addinfo)
 {
   int i;
   struct option *opt;
@@ -1018,6 +1027,9 @@
   printf("\nVersion: "REL_VERSION" (api:%d)\n%s\n",
 		  API_VERSION, drbd_buildtag());
 
+  if (addinfo)
+      printf("\n%s\n",addinfo);
+
   exit(E_usage);
 }
 
@@ -1031,7 +1043,8 @@
   char *argv[] = { "/bin/bash", "-c", NULL, "drbdadm:verify_ips", NULL };
   int ex;
 
-  if (dry_run == 1) return;
+  if (global_options.disable_ip_verification) return;
+  if (dry_run == 1 || do_verify_ips == 0) return;
 
   if (!(res && res->me   && res->me->address
 	    && res->peer && res->peer->address)) {
@@ -1053,7 +1066,7 @@
 	"fi >/dev/null",
 	my_ip);
   if (ex < 0) { perror("asprintf"); exit(E_thinko); }
-  ex = m_system(argv,SLEEPS_SHORT);
+  ex = m_system(argv,SLEEPS_SHORT|DONT_REPORT_FAILED);
   free(argv[2]); argv[2] = NULL;
 
   if (ex != 0) {
@@ -1191,6 +1204,7 @@
   int i,rv=0;
   struct adm_cmd *cmd;
   struct d_resource *res,*tmp;
+  char *env_drbd_nodename = NULL;
 
   drbdsetup=NULL;
   drbdmeta=NULL;
@@ -1198,11 +1212,20 @@
   yyin=NULL;
   uname(&nodeinfo); /* FIXME maybe fold to lower case ? */
 
+  env_drbd_nodename = getenv("__DRBD_NODE__");
+  if (env_drbd_nodename && *env_drbd_nodename) {
+    strncpy(nodeinfo.nodename,env_drbd_nodename,sizeof(nodeinfo.nodename)-1);
+    nodeinfo.nodename[sizeof(nodeinfo.nodename)] = 0;
+    fprintf(stderr, "\n"
+            "   found __DRBD_NODE__ in environment\n"
+            "   PRETENDING that I am >>%s<<\n\n",nodeinfo.nodename);
+  }
+
   if( (progname=strrchr(argv[0],'/')) )
     argv[0] = ++progname;
   else
     progname=argv[0];
-  if(argc == 1) print_usage(); // arguments missing.
+  if(argc == 1) print_usage_and_exit("missing arguments"); // arguments missing.
 
   opterr=1;
   optind=0;
@@ -1249,19 +1272,20 @@
 	case '?':
 	  // commented out, since opterr=1
 	  //fprintf(stderr,"Unknown option %s\n",argv[optind-1]);
+	  fprintf(stderr,"try '%s help'\n",progname);
 	  return 20;
 	  break;
 	}
     }
 
-  if ( optind == argc ) print_usage();
+  if ( optind == argc ) print_usage_and_exit(0);
 
   while(argv[optind][0]=='-' || argv[optind][0]==':' || 
 	isdigit(argv[optind][0]) ) {
     setup_opts[soi++]=argv[optind++];
-    if (optind == argc) print_usage();
+    if (optind == argc) print_usage_and_exit(0);
   }
-  if (optind == argc) print_usage();
+  if (optind == argc) print_usage_and_exit(0);
 
   cmd=NULL;
   for(i=0;i<ARRY_SIZE(cmds);i++) {
@@ -1272,10 +1296,12 @@
   }
 
   if(cmd==NULL) {
+    if (!strncmp("help",argv[optind],5)) print_usage_and_exit(0);
     fprintf(stderr,"Unknown command '%s'.\n",argv[optind]);
     exit(E_usage);
   }
   optind++;
+  do_verify_ips = cmd->verify_ips;
 
   if (!config_file) {
     i=0;
@@ -1315,11 +1341,17 @@
     exit(E_exec_error);
   };
 
+  //yydebug = 1;
   yyparse();
 
   if(!config_valid) exit(E_config_invalid);
 
-  {
+  if (config == NULL) {
+    fprintf(stderr, "no resources defined!\n");
+    exit(0); /* THINK exit here? what code? */
+  }
+
+  { /* block for mc to avoid compiler warnings */
     int mc=global_options.minor_count;
 
     highest_minor=0;
@@ -1349,11 +1381,12 @@
 
   if(cmd->res_name_required)
     {
-      if (optind + 1 > argc && cmd->function != adm_dump)
-        print_usage (argv[0]);	// arguments missing.
+      int is_dump = (cmd->function == adm_dump);
+      if (optind + 1 > argc && !is_dump)
+        print_usage_and_exit("missing arguments"); // arguments missing.
 
-      if(optind==argc || !strcmp(argv[optind],"all")) {
-        if (cmd->function == adm_dump) {
+      if ( optind==argc || !strcmp(argv[optind],"all") ) {
+        if (is_dump) {
 	  dump_global_info();
 	  dump_common_info();
 	} else {

Modified: trunk/user/drbdadm_parser.y
===================================================================
--- trunk/user/drbdadm_parser.y	2005-07-26 11:37:12 UTC (rev 1899)
+++ trunk/user/drbdadm_parser.y	2005-07-26 12:05:27 UTC (rev 1900)
@@ -1,5 +1,7 @@
 %{
 
+#define _GNU_SOURCE
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -11,6 +13,8 @@
 extern void yyerror(char* text);
 extern int  yylex(void);
 
+#define YYDEBUG 1
+
 #define APPEND(LIST,ITEM) ({		      \
   typeof((LIST)) _l = (LIST);		      \
   typeof((ITEM)) _i = (ITEM);		      \
@@ -25,6 +29,7 @@
 })
 
 static struct d_resource* c_res;
+static struct d_resource* c_config;
 static struct d_host_info* c_host;
 static char* c_hostname;
 static int   c_section_start, n_hosts;
@@ -223,7 +228,7 @@
 
 #define CHKU(what,val) \
 	c_host->what = val; \
-	check_uniq( #what, "%s:%s",c_hostname,val)
+	check_uniq( #what, "%s:%s:%s", #what, c_hostname,val)
 
 #define CHKS(sname) \
 	check_uniq(sname " section","%s:" sname, c_res->name)
@@ -238,6 +243,7 @@
 %token TK_GLOBAL TK_RESOURCE
 %token TK_ON TK_NET TK_DISK_S TK_SYNCER TK_STARTUP
 %token TK_DISABLE_IO_HINTS
+%token TK_DISABLE_IP_VERIFICATION
 %token TK_PROTOCOL TK_HANDLERS TK_COMMON
 %token TK_ADDRESS TK_DISK TK_DEVICE TK_META_DISK 
 %token <txt> TK_MINOR_COUNT TK_INTEGER TK_STRING
@@ -272,7 +278,14 @@
 		;
 
 glob_stmt:	  TK_DISABLE_IO_HINTS
-			{ global_options.disable_io_hints=1;   }
+		{
+		    fprintf(stderr,
+			    "%s:%d: in global section, "
+			    "useless use of no longer available option \"disable_io_hints\".\n",
+			    config_file, line);
+		}
+		|  TK_DISABLE_IP_VERIFICATION
+		{ global_options.disable_ip_verification=1; }
 		| TK_MINOR_COUNT TK_INTEGER
 		{
 			range_check(R_MINOR_COUNT,$1,$2);
@@ -290,8 +303,8 @@
 			res_stmts { common = c_res; }
 		;
 
-resources:	  /* empty */	     { $$ = NULL; }
-		| resources resource { $$=APPEND($1,$2); }
+resources:	  /* empty */	     { $$ = 0; c_config = 0; }
+		| resources resource { $$=APPEND($1,$2); c_config=$$; }
 		;
 
 resource:	TK_RESOURCE { n_hosts = 0; } resource_name res_stmts

Modified: trunk/user/drbdadm_scanner.fl
===================================================================
--- trunk/user/drbdadm_scanner.fl	2005-07-26 11:37:12 UTC (rev 1899)
+++ trunk/user/drbdadm_scanner.fl	2005-07-26 12:05:27 UTC (rev 1900)
@@ -31,16 +31,6 @@
  *		-- lge
  */ 
 
-/*
- * Philipp dislikes syntax diversity, and wants terminating semicolons.
- * So I drop what I thought would be nice to have: plain English and
- * punctuation...
-ASSIGN			  {LS}*[:=]{LS}*|{LS}(is{LS})?
-DISK			  disk|"on top of"
-IGNORE			  ({WSC}*(use|with)*)+
-NDELIM			  [^ \t\n#=:;{}]+
-*/
-
 %}
 
 %option noyywrap
@@ -51,29 +41,31 @@
 %x SEMICOLON ASSIGN NUM NUM_U NAME STRING PROTO IO_ERROR ON_DISCONNECT
 %x IP_AND_PORT PORT META_DISK META_IDX
 %x LS LBRACE IGNORE_SECTION
+%x COMMENT
 
-LS			  [ \t]+
-WS			  [ \t\n]+
-COMMENT			  \#[^\n]*
-WSC			  ({WS}|{COMMENT}\n)+
+LS			  [ \t]{1,80}
+WS			  ({LS}|\n)
+COMMENT_START		  \#
 ASSIGN			  {LS}
 OUT_OF_RANGE_NUM	  [0-9]{10,}[kmgKMG]? 
 NUM			  [0-9]{1,9}
 NUM_U			  [0-9]{1,9}[kmgKMG]? 
-NAME			  [/_.A-Za-z0-9-]+
-STRING			  ({NAME}|\"([^\"\\\n]*|\\.)*\")+
-USTRING			  \"([^\"\\\n]*|\\.)*
+NAME			  [/_.A-Za-z0-9-]{1,80}
+ENAME			  [/_.A-Za-z0-9-]{81}
+L_NO_DQUOTES		  [^\"\\\n]
+STRING			  ({NAME}|\"{L_NO_DQUOTES}{1,80}\")
+ESTRING			  (\"{L_NO_DQUOTES}{81}|\"\")
 DISK			  disk
 INTERN			  internal|\"internal\"
-META_IDX		  {LS}*\[{LS}*{NUM}{LS}*\]
-O_IDX			  {WSC}meta-index{ASSIGN}
-IGNORE			  {WSC}
-SKIP			  skip({LS}[^{\n]*)?
-NDELIM			  [^ \t\n#;{}]+
-_1_254			  [1-9][0-9]?|1[0-9][0-9]|2[0-4][0-9]|25[0-4]
-_0_255			  0|[1-9][0-9]?|1[0-9][0-9]|2[0-4][0-9]|25[0-5]
+META_IDX		  {LS}?\[{LS}?{NUM}{LS}?\]
+O_IDX			  {WS}meta-index{ASSIGN}
+IGNORE			  {WS}
+SKIP			  skip({LS}[^{\n]{0,80})?
+NDELIM			  [^ \t\n#;{}]{1,50}
+_1_254			  [1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-4]
+_0_255			  0|[1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5]
 IPV4ADDR		  {_1_254}\.{_0_255}\.{_0_255}\.{_1_254}
-PORT			  {WSC}port{ASSIGN}{NUM}
+PORT			  {WS}port{ASSIGN}{NUM}
 COMMON			  common
 
 %%
@@ -82,9 +74,16 @@
   {SKIP}		section(IGNORE_SECTION);
 }
 
+<INITIAL,ASSIGN,LBRACE,META_IDX,RESOURCE,GLOBAL,STARTUP,DISK,NET,SYNCER,HOST,PORT>{
+  {COMMENT_START}	{
+  				char c;
+				while ((c = input()) != '\n' && c != EOF);
+				if (c == '\n') ++line;
+			}
+}
+
 <INITIAL>{
-  {COMMENT}		/* discard last comment if no eol at eof */
-  {WSC}			update_lcnt();
+  {WS}			update_lcnt();
   global		section(GLOBAL); return TK_GLOBAL;
   resource		named_section(RESOURCE); return TK_RESOURCE;
   \}			syntax_error("unmached closing brace.");
@@ -98,8 +97,9 @@
 }
 
 <NAME>{
+  {ENAME}		syntax_error("name too long.\n");
   {NAME}		yy_pop_state(); CP; return TK_STRING;
-  [^ \t\n#]+		expect_error("name"); /* not referenced currently */
+  [^ \t\n#]{1,80}	expect_error("name"); /* not referenced currently */
 }
 
 <SEMICOLON>{
@@ -112,7 +112,7 @@
 <ASSIGN>{
   {ASSIGN}		yy_pop_state(); fline = line;
   =			syntax_error("don't use '=' signs anymore!");
-  {WSC}			syntax_error("linebreak between option and value not allowed.\n");
+  {WS}			syntax_error("linebreak between option and value not allowed.\n");
   {NDELIM}		expect_error("whitespace");
 }
 
@@ -134,8 +134,9 @@
 }
 
 <STRING>{
+  {ENAME}		syntax_error("name too long.\n");
+  {ESTRING}		syntax_error("string terminator missing or string too long.\n");
   {STRING}		yy_pop_state(); unescape(); CP; return TK_STRING;
-  {USTRING}		syntax_error("string terminator missing.\n");
   {NDELIM}		expect_error("string"); yy_pop_state();
 }
 
@@ -147,7 +148,8 @@
 
 <PORT>{
   :			BEGIN(NUM); /* this is only reached when I have a colon */
-  {WSC}port{ASSIGN}	{
+  {WS}			update_lcnt();
+  port{ASSIGN}		{
 			  /* or a 'port = ' following the 'address = ' */
 			  update_lcnt(); BEGIN(NUM);
 			  PRINTF("'port=<port>' deprecated, "
@@ -156,16 +158,17 @@
 }
 
 <IP_AND_PORT>{
+  {LS}			/* ignore */
+  \"			syntax_error("please do not quote IP:PORT.\n");
   {IPV4ADDR}/:{NUM}	BEGIN(PORT); CP; return TK_IPADDR;
   {IPV4ADDR}/{PORT}	BEGIN(PORT); CP; return TK_IPADDR;
   {IPV4ADDR}		syntax_error("':PORT' missing from IP:PORT.\n");
-  \"{IPV4ADDR}[^ \t\n]+	syntax_error("please do not quote IP:PORT.\n");
-  [0-9.:]+		expect_error("valid IP");
   {NDELIM}		expect_error("IP and port 'XXX.XXX.XXX.XXX:PORT'");
 }
 
 <META_IDX>{
   {META_IDX}		unescape_midx(); yy_pop_state(); CP; return TK_INTEGER;
+  {WS}			update_lcnt();
   {O_IDX}		{
 			  update_lcnt(); BEGIN(NUM);
 			  PRINTF("'meta-index=<idx>' deprecated, "
@@ -177,9 +180,10 @@
   {INTERN}		unescape(); yy_pop_state();  CP; return TK_STRING;
   {INTERN}{META_IDX}	|
   {INTERN}{O_IDX}	syntax_error("don't give an index for internal meta-data.");
+  {ESTRING}		syntax_error("string terminator missing or string too long.\n");
   {STRING}/{META_IDX}	|
   {STRING}/{O_IDX}{NUM} unescape(); BEGIN(META_IDX); CP; return TK_STRING;
-  {STRING}{LS}*{NDELIM}	expect_error("meta-disk: index missing; either 'internal' or '/dev/ice/name [index]'");
+  {STRING}{LS}?{NDELIM}	expect_error("meta-disk: index missing; either 'internal' or '/dev/ice/name [index]'");
   {NDELIM}		expect_error("either 'internal' or '/dev/ice/name [index]'");
 }
 
@@ -189,12 +193,14 @@
 }
 
 <LBRACE>{
-  {WSC}*\{{WSC}*	update_lcnt(); yy_pop_state();
-  {WSC}*[^{ \t\n]+	expect_error("'{'");
+  {WS}			update_lcnt();
+  \{			update_lcnt(); yy_pop_state();
+  [^{ \t\n]{1,40}	expect_error("'{'");
 }
 
 <IGNORE_SECTION>{
-  [^{}]+		update_lcnt(); /* no ECHO */
+  [^{}\n]{1,80}		/* no ECHO */
+  {WS}			update_lcnt(); /* no ECHO */
   \{			yy_push_state(IGNORE_SECTION);
 }
 
@@ -202,6 +208,7 @@
   minor-count	do_assign(NUM); CP; return TK_MINOR_COUNT;
   disable-io-hints yy_push_state(SEMICOLON); return TK_DISABLE_IO_HINTS;
   dialog-refresh        do_assign(NUM); CP; return TK_DIALOG_REFRESH;
+  disable-ip-verification  yy_push_state(SEMICOLON); return TK_DISABLE_IP_VERIFICATION;
   {NDELIM}		expect_error("'minor-count|disable-io-hints|dialog-refresh'");
 }
 
@@ -231,7 +238,8 @@
 <DISK>{
   on-io-error		do_assign(IO_ERROR); CP; return TK_ON_IO_ERROR;
   split-brain-fix 	yy_push_state(SEMICOLON); CP; return TK_SPLIT_BRAIN_FIX;
-  {NDELIM}		expect_error("'on-io-error|split-brain-fix'");
+  size                  do_assign(NUM_U); CP; return TK_SIZE;
+  {NDELIM}		expect_error("'on-io-error|split-brain-fix|size'");
 }
 
 <IO_ERROR>{

Modified: trunk/user/drbdsetup.c
===================================================================
--- trunk/user/drbdsetup.c	2005-07-26 11:37:12 UTC (rev 1899)
+++ trunk/user/drbdsetup.c	2005-07-26 12:05:27 UTC (rev 1900)
@@ -411,7 +411,7 @@
       switch(c)
 	{
 	case 'd':
-	  cn->config.disk_size = m_strtoll_range(optarg,'K', "disk-size",
+	  cn->config.disk_size = m_strtoll_range(optarg,'K', "size",
 			      DRBD_DISK_SIZE_SECT_MIN>>1,
 			      DRBD_DISK_SIZE_SECT_MAX>>1 ) << 1;
 	  break;
@@ -1042,7 +1042,7 @@
 	  switch(c)
 	    {
 	    case 'd':
-	      u_size=m_strtoll_range(optarg,'K', "disk-size",
+	      u_size=m_strtoll_range(optarg,'K', "size",
 			      DRBD_DISK_SIZE_SECT_MIN>>1,
 			      DRBD_DISK_SIZE_SECT_MAX>>1 ) << 1;
 	      break;

From www-data at linbit.com  Wed Jul 27 16:49:36 2005
From: www-data at linbit.com (www-data)
Date: Wed Jul 27 16:49:37 2005
Subject: [DRBD-cvs] r1904 - branches/drbd-0.7/drbd
Message-ID: <20050727144936.411AD143F3@mail.linbit.com>

Author: lars
Date: 2005-07-27 16:49:35 +0200 (Wed, 27 Jul 2005)
New Revision: 1904

Modified:
   branches/drbd-0.7/drbd/drbd_receiver.c
Log:
As suggested on drbd-user by Matthias Weigel,
do an explicit bind() before connect().

This makes sure the outgoing connection has the configured ip locally, which
might make a difference on multi-homed hosts with several routes to the peer,
or on aliased interfaces.


Modified: branches/drbd-0.7/drbd/drbd_receiver.c
===================================================================
--- branches/drbd-0.7/drbd/drbd_receiver.c	2005-07-27 12:06:10 UTC (rev 1903)
+++ branches/drbd-0.7/drbd/drbd_receiver.c	2005-07-27 14:49:35 UTC (rev 1904)
@@ -614,15 +614,37 @@
 {
 	int err;
 	struct socket *sock;
+	struct sockaddr_in src_in;
 
 	err = sock_create(AF_INET, SOCK_STREAM, 0, &sock);
 	if (err) {
 		ERR("sock_creat(..)=%d\n", err);
+		return NULL;
 	}
 
 	sock->sk->SK_(rcvtimeo) =
 	sock->sk->SK_(sndtimeo) =  mdev->conf.try_connect_int*HZ;
 
+       /* explicitly bind to the configured IP as source IP 
+	   for the outgoing connections.
+	   This is needed for multihomed hosts and to be 
+	   able to use lo: interfaces for drbd.
+          Make sure to use 0 as portnumber, so linux selects
+	   a free one dynamically.
+	*/
+	memcpy (&src_in, &(mdev->conf.my_addr), sizeof(struct sockaddr_in));
+	src_in.sin_port = 0; 
+
+	err = sock->ops->bind(sock,
+			      (struct sockaddr * ) &src_in,
+			      sizeof (struct sockaddr_in));
+	if (err) {
+		ERR("Unable to bind source sock (%d)\n", err);
+		sock_release(sock);
+		sock = NULL;
+		return sock;
+	}
+
 	err = sock->ops->connect(sock,
 				 (struct sockaddr *) mdev->conf.other_addr,
 				 mdev->conf.other_addr_len, 0);
@@ -642,7 +664,7 @@
 	err = sock_create(AF_INET, SOCK_STREAM, 0, &sock2);
 	if (err) {
 		ERR("sock_creat(..)=%d\n", err);
-		// FIXME return NULL ?
+		return NULL;
 	}
 
 	sock2->sk->SK_(reuse)    = 1; /* SO_REUSEADDR */
@@ -653,7 +675,7 @@
 			      (struct sockaddr *) mdev->conf.my_addr,
 			      mdev->conf.my_addr_len);
 	if (err) {
-		ERR("Unable to bind (%d)\n", err);
+		ERR("Unable to bind sock2 (%d)\n", err);
 		sock_release(sock2);
 		set_cstate(mdev,Unconnected);
 		return 0;

From www-data at linbit.com  Thu Jul 28 16:13:19 2005
From: www-data at linbit.com (www-data)
Date: Thu Jul 28 16:13:26 2005
Subject: [DRBD-cvs] r1906 - trunk/user
Message-ID: <20050728141324.4678B143B2@mail.linbit.com>

Author: phil
Date: 2005-07-28 16:13:18 +0200 (Thu, 28 Jul 2005)
New Revision: 1906

Modified:
   trunk/user/drbdmeta.c
Log:
It seems that some SATA divers do not support this ioctl.


Modified: trunk/user/drbdmeta.c
===================================================================
--- trunk/user/drbdmeta.c	2005-07-28 14:08:25 UTC (rev 1905)
+++ trunk/user/drbdmeta.c	2005-07-28 14:13:18 UTC (rev 1906)
@@ -735,8 +735,7 @@
 	}
 
 	if (ioctl(cfg->md_fd, BLKFLSBUF) == -1) {
-		PERROR("ioctl(,BLKFLSBUF,) failed");
-		exit(20);
+		PERROR("WARN: ioctl(,BLKFLSBUF,) failed");
 	}
 
 	offset = new_style_offset(cfg);

