From svn at svn.drbd.org  Wed Feb  2 22:19:47 2005
From: svn at svn.drbd.org (svn@svn.drbd.org)
Date: Wed Feb  2 22:19:49 2005
Subject: [DRBD-cvs] r1755 - in trunk/drbd: . linux
Message-ID: <20050202211947.7641B3BE6D@garcon.linbit.com>

Author: phil
Date: 2005-02-02 22:19:44 +0100 (Wed, 02 Feb 2005)
New Revision: 1755

Modified:
   trunk/drbd/drbd_compat_wrappers.h
   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
Log:
- Fixed random problems with the tl_hash
- Added the ee_hash
...everything ufinished currently...


Modified: trunk/drbd/drbd_compat_wrappers.h
===================================================================
--- trunk/drbd/drbd_compat_wrappers.h	2005-02-02 17:38:17 UTC (rev 1754)
+++ trunk/drbd/drbd_compat_wrappers.h	2005-02-02 21:19:44 UTC (rev 1755)
@@ -84,7 +84,7 @@
 	return req->master_bio->bi_size;
 }
 
-static inline drbd_bio_t* drbd_req_private_bio(struct drbd_request *req)
+static inline struct bio* drbd_req_private_bio(struct drbd_request *req)
 {
 	return req->private_bio;
 }

Modified: trunk/drbd/drbd_fs.c
===================================================================
--- trunk/drbd/drbd_fs.c	2005-02-02 17:38:17 UTC (rev 1754)
+++ trunk/drbd/drbd_fs.c	2005-02-02 21:19:44 UTC (rev 1755)
@@ -522,6 +522,8 @@
 	enum ret_codes retcode;
 	struct net_config new_conf;
 	struct crypto_tfm* tfm = NULL;
+	struct hlist_head *new_tl_hash = NULL;
+	struct hlist_head *new_ee_hash = NULL;
 
 	minor=(int)(mdev-drbd_conf);
 
@@ -566,6 +568,25 @@
 
 	mdev->cram_hmac_tfm = tfm;
 
+
+	if (mdev->tl_hash_s != new_conf.max_epoch_size/8 ) {
+		new_tl_hash = kmalloc(mdev->tl_hash_s * sizeof(void*),
+				      GFP_KERNEL);
+		if(!new_tl_hash) {
+			retcode=KMallocFailed;
+			goto fail_ioctl;
+		}
+	}
+
+	if (mdev->ee_hash_s != new_conf.max_buffers/8 ) {
+		new_ee_hash = kmalloc(mdev->ee_hash_s * sizeof(void*),
+				      GFP_KERNEL);
+		if(!new_ee_hash) {
+			retcode=KMallocFailed;
+			goto fail_ioctl;
+		}
+	}
+
 	/* IMPROVE:
 	   We should warn the user if the LL_DEV is
 	   used already. E.g. some FS mounted on it.
@@ -607,19 +628,20 @@
 	mdev->send_cnt = 0;
 	mdev->recv_cnt = 0;
 
-	if (mdev->tl_hash_s != mdev->conf.max_epoch_size/8 ) {
+	if(new_tl_hash) {
 		if (mdev->tl_hash) kfree(mdev->tl_hash);
 		mdev->tl_hash_s = mdev->conf.max_epoch_size/8;
-		mdev->tl_hash = kmalloc(mdev->tl_hash_s * sizeof(void*),
-					GFP_KERNEL);
-		if(!mdev->tl_hash) {
-			mdev->tl_hash_s = 0;
-			return -ENOMEM;
-		}
-
+		mdev->tl_hash = new_tl_hash;
 		memset(mdev->tl_hash, 0, mdev->tl_hash_s * sizeof(void*));
 	}
 
+	if(new_ee_hash) {
+		if (mdev->ee_hash) kfree(mdev->ee_hash);
+		mdev->ee_hash_s = mdev->conf.max_buffers/8;
+		mdev->ee_hash = new_ee_hash;
+		memset(mdev->ee_hash, 0, mdev->ee_hash_s * sizeof(void*));
+	}
+
 	drbd_thread_start(&mdev->worker);
 	if( drbd_request_state(mdev,NS(conn,Unconnected)) > 0) {
 		drbd_thread_start(&mdev->receiver);
@@ -628,6 +650,8 @@
 	return 0;
 
   fail_ioctl:
+	if (new_tl_hash) kfree(new_tl_hash);
+	if (new_ee_hash) kfree(new_ee_hash);
 	if (put_user(retcode, &arg->ret_code)) return -EFAULT;
 	return -EINVAL;
 }

Modified: trunk/drbd/drbd_int.h
===================================================================
--- trunk/drbd/drbd_int.h	2005-02-02 17:38:17 UTC (rev 1754)
+++ trunk/drbd/drbd_int.h	2005-02-02 21:19:44 UTC (rev 1755)
@@ -606,6 +606,7 @@
 	long magic;
 	unsigned int ee_size;
 	sector_t ee_sector;
+	struct hlist_node colision;
 	// THINK: maybe we rather want bio_alloc(GFP_*,1)
 	struct bio_vec ee_bvec;
 };
@@ -741,6 +742,8 @@
 	struct list_head done_ee;   // send ack
 	struct list_head read_ee;   // IO in progress
 	struct list_head net_ee;    // zero-copy network send in progress
+	struct hlist_head * ee_hash; // is proteced by tl_lock!
+	unsigned int ee_hash_s;     
 	spinlock_t pr_lock;
 	struct list_head app_reads;
 	struct list_head resync_reads;
@@ -789,7 +792,7 @@
 extern int tl_verify(drbd_dev *mdev, drbd_request_t * item, sector_t sector);
 #define TLHW_FLAG_SENT   0x10000000
 #define TLHW_FLAG_RECVW  0x20000000
-extern int req_have_write(drbd_dev *mdev, sector_t sector, int size_n_flags);
+extern int req_have_write(drbd_dev *mdev, struct Tl_epoch_entry *e, int flags);
 extern void drbd_free_sock(drbd_dev *mdev);
 extern int drbd_send(drbd_dev *mdev, struct socket *sock,
 		     void* buf, size_t size, unsigned msg_flags);

Modified: trunk/drbd/drbd_main.c
===================================================================
--- trunk/drbd/drbd_main.c	2005-02-02 17:38:17 UTC (rev 1754)
+++ trunk/drbd/drbd_main.c	2005-02-02 21:19:44 UTC (rev 1755)
@@ -201,6 +201,7 @@
 	b->n_req--;
 
 	list_del(&item->w.list);
+	hlist_del(&item->colision);
 	item->rq_status &= ~RQ_DRBD_IN_TL;
 
 	spin_unlock_irq(&mdev->tl_lock);
@@ -300,6 +301,7 @@
 
 	r = ( item->barrier == mdev->newest_barrier );
 	list_del(&item->w.list);
+	hlist_del(&item->colision);
 
 	if( item->rq_status & RQ_DRBD_RECVW ) wake_up(&mdev->cstate_wait);
 
@@ -360,6 +362,11 @@
 	}
 }
 
+STATIC unsigned int ee_hash_fn(drbd_dev *mdev, sector_t sector)
+{
+	return (sector>>HT_SHIFT) % mdev->ee_hash_s;
+}
+
 STATIC int overlaps(sector_t s1, int l1, sector_t s2, int l2)
 {
 	return !( ( s1 + (l1>>9) <= s2 ) || ( s1 >= s2 + (l2>>9) ) );
@@ -371,12 +378,13 @@
  * 1 ... a conflicting write, have not got ack by now.
  * 2 ... a conflicting write, have got also got ack.
  */
-int req_have_write(drbd_dev *mdev, sector_t sector, int size_n_flags)
+int req_have_write(drbd_dev *mdev, struct Tl_epoch_entry *e, int flags)
 {
 	struct hlist_head *slot;
 	struct hlist_node *n;
 	drbd_request_t * req;
-	int size = size_n_flags & ~(TLHW_FLAG_SENT|TLHW_FLAG_RECVW);
+	sector_t sector = drbd_ee_get_sector(e);	
+	int size = drbd_ee_get_size(e);
 	int i, rv=0;
 
 	D_ASSERT(size <= 1<<(HT_SHIFT+9) );
@@ -393,10 +401,10 @@
 				     size) ) {
 				rv=1;
 				if( req->rq_status & RQ_DRBD_SENT ) rv++;
-				if( size_n_flags & TLHW_FLAG_SENT ) {
+				if( flags & TLHW_FLAG_SENT ) {
 					req->rq_status |= RQ_DRBD_SENT;
 				}
-				if( size_n_flags & TLHW_FLAG_RECVW ) {
+				if( flags & TLHW_FLAG_RECVW ) {
 					req->rq_status |= RQ_DRBD_RECVW;
 				}
 				goto out;
@@ -404,7 +412,10 @@
 		} // hlist_for_each_entry()
 	}
 
-	// PRE TODO: insert ee onto ee_hash_table here...
+	// Good, no conflict found
+	INIT_HLIST_NODE(&e->colision);
+	hlist_add_head( &e->colision, mdev->ee_hash + 
+			ee_hash_fn(mdev, sector) );
  out:
 	spin_unlock_irq(&mdev->tl_lock);
 
@@ -1858,6 +1869,11 @@
 				__free_page(mdev->md_io_tmpp);
 
 			if (mdev->act_log) lc_free(mdev->act_log);
+
+			if(mdev->ee_hash) {
+				kfree(mdev->ee_hash);
+				mdev->ee_hash_s = 0;
+			}
 		}
 		drbd_destroy_mempools();
 	}

Modified: trunk/drbd/drbd_receiver.c
===================================================================
--- trunk/drbd/drbd_receiver.c	2005-02-02 17:38:17 UTC (rev 1754)
+++ trunk/drbd/drbd_receiver.c	2005-02-02 21:19:44 UTC (rev 1755)
@@ -1072,6 +1072,16 @@
 	e = read_in_block(mdev,data_size);
 	if (!e) return FALSE;
 
+	if(!inc_local(mdev)) {
+		if (DRBD_ratelimit(5*HZ,5))
+			ERR("Can not write mirrored data block to local disk.\n");
+		drbd_send_ack(mdev,NegAck,e);
+		spin_lock_irq(&mdev->ee_lock);
+		drbd_put_ee(mdev,e);
+		spin_unlock_irq(&mdev->ee_lock);
+		return TRUE;
+	}
+
 	if(discard) {
 		spin_lock_irq(&mdev->ee_lock);
 		drbd_put_ee(mdev,e);
@@ -1081,13 +1091,13 @@
 		return TRUE;
 	}
 
-	switch( req_have_write(mdev, sector, data_size) ) {
+	switch( req_have_write(mdev, e, 0) ) {
 	case 2: /* Conflicting write, got ACK */
 		/* write afterwards ...*/
 		WARN("Concurrent write! [W AFTERWARDS] sec=%lu\n",
 		     (unsigned long)sector);
 		if( wait_event_interruptible(mdev->cstate_wait,
-		     !req_have_write(mdev,sector,data_size|TLHW_FLAG_RECVW))) {
+		     !req_have_write(mdev,e,TLHW_FLAG_RECVW))) {
 			spin_lock_irq(&mdev->ee_lock);
 			drbd_put_ee(mdev,e);
 			spin_unlock_irq(&mdev->ee_lock);
@@ -1106,7 +1116,7 @@
 			WARN("Concurrent write! [W AFTERWARDS] sec=%lu\n",
 			     (unsigned long)sector);
 			if( wait_event_interruptible(mdev->cstate_wait,
-			      !req_have_write(mdev,sector,data_size|
+			      !req_have_write(mdev,e,
 				            TLHW_FLAG_RECVW|TLHW_FLAG_SENT))) {
 				spin_lock_irq(&mdev->ee_lock);
 				drbd_put_ee(mdev,e);
@@ -1120,16 +1130,6 @@
 
 	e->block_id = p->block_id; // no meaning on this side, e* on partner
 
-	if(!inc_local(mdev)) {
-		if (DRBD_ratelimit(5*HZ,5))
-			ERR("Can not write mirrored data block to local disk.\n");
-		drbd_send_ack(mdev,NegAck,e);
-		spin_lock_irq(&mdev->ee_lock);
-		drbd_put_ee(mdev,e);
-		spin_unlock_irq(&mdev->ee_lock);
-		return TRUE;
-	}
-
 	drbd_ee_prepare_write(mdev, e, sector, data_size);
 	e->w.cb     = e_end_block;
 

Modified: trunk/drbd/drbd_req.c
===================================================================
--- trunk/drbd/drbd_req.c	2005-02-02 17:38:17 UTC (rev 1754)
+++ trunk/drbd/drbd_req.c	2005-02-02 21:19:44 UTC (rev 1755)
@@ -57,7 +57,6 @@
 	req->rq_status |= nextstate;
 	req->rq_status &= er_flags | ~0x0001;
 	if( (req->rq_status & RQ_DRBD_DONE) == RQ_DRBD_DONE ) {
-		hlist_del(&req->colision);
 		goto end_it;
 	}
 
@@ -81,6 +80,7 @@
 				set_bit(ISSUE_BARRIER,&mdev->flags);
 		} else {
 			list_del(&req->w.list); // we have the tl_lock...
+			hlist_del(&req->colision);
 		}
 	}
 
@@ -324,6 +324,9 @@
 		}
 	}
 
+	/* NOTE: drbd_send_dlobck() must happen before start of local IO,
+	         to get he concurrent write detection right. */
+
 	if (local) {
 		if (rw == WRITE) {
 			if (!remote) drbd_set_out_of_sync(mdev,sector,size);

Modified: trunk/drbd/linux/drbd.h
===================================================================
--- trunk/drbd/linux/drbd.h	2005-02-02 17:38:17 UTC (rev 1754)
+++ trunk/drbd/linux/drbd.h	2005-02-02 21:19:44 UTC (rev 1755)
@@ -136,6 +136,7 @@
 	MDIOError,
 	MDInvalid,
 	CRAMAlgNotAvail,
+	KMallocFailed,
 };
 
 struct ioctl_disk_config {

From svn at svn.drbd.org  Sun Feb  6 09:52:25 2005
From: svn at svn.drbd.org (svn@svn.drbd.org)
Date: Sun Feb  6 09:52:27 2005
Subject: [DRBD-cvs] r1756 - in trunk: drbd drbd/linux user
Message-ID: <20050206085225.1F7383BE6D@garcon.linbit.com>

Author: phil
Date: 2005-02-06 09:52:22 +0100 (Sun, 06 Feb 2005)
New Revision: 1756

Modified:
   trunk/drbd/drbd_fs.c
   trunk/drbd/linux/drbd.h
   trunk/user/drbdsetup.c
Log:
We need to make sure that the crypto transformation named by the user
is really a DIGEST transformation...


Modified: trunk/drbd/drbd_fs.c
===================================================================
--- trunk/drbd/drbd_fs.c	2005-02-02 21:19:44 UTC (rev 1755)
+++ trunk/drbd/drbd_fs.c	2005-02-06 08:52:22 UTC (rev 1756)
@@ -560,15 +560,14 @@
 			retcode=CRAMAlgNotAvail;
 			goto fail_ioctl;
 		}
-	}
 
-	if ( mdev->cram_hmac_tfm ) {
-		crypto_free_tfm(mdev->cram_hmac_tfm);
+		if (crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST) {
+			retcode=CRAMAlgNotDigest;
+			goto fail_ioctl;
+		}
 	}
 
-	mdev->cram_hmac_tfm = tfm;
 
-
 	if (mdev->tl_hash_s != new_conf.max_epoch_size/8 ) {
 		new_tl_hash = kmalloc(mdev->tl_hash_s * sizeof(void*),
 				      GFP_KERNEL);
@@ -642,6 +641,12 @@
 		memset(mdev->ee_hash, 0, mdev->ee_hash_s * sizeof(void*));
 	}
 
+	if ( mdev->cram_hmac_tfm ) {
+		crypto_free_tfm(mdev->cram_hmac_tfm);
+	}
+
+	mdev->cram_hmac_tfm = tfm;
+
 	drbd_thread_start(&mdev->worker);
 	if( drbd_request_state(mdev,NS(conn,Unconnected)) > 0) {
 		drbd_thread_start(&mdev->receiver);
@@ -650,6 +655,7 @@
 	return 0;
 
   fail_ioctl:
+	if (tfm) crypto_free_tfm(tfm);
 	if (new_tl_hash) kfree(new_tl_hash);
 	if (new_ee_hash) kfree(new_ee_hash);
 	if (put_user(retcode, &arg->ret_code)) return -EFAULT;

Modified: trunk/drbd/linux/drbd.h
===================================================================
--- trunk/drbd/linux/drbd.h	2005-02-02 21:19:44 UTC (rev 1755)
+++ trunk/drbd/linux/drbd.h	2005-02-06 08:52:22 UTC (rev 1756)
@@ -136,6 +136,7 @@
 	MDIOError,
 	MDInvalid,
 	CRAMAlgNotAvail,
+	CRAMAlgNotDigest,
 	KMallocFailed,
 };
 

Modified: trunk/user/drbdsetup.c
===================================================================
--- trunk/user/drbdsetup.c	2005-02-02 21:19:44 UTC (rev 1755)
+++ trunk/user/drbdsetup.c	2005-02-06 08:52:22 UTC (rev 1756)
@@ -566,7 +566,9 @@
     [MDInvalid]="No valid meta-data signature found.\n"
                 "Use 'drbdadm create-md res' to initialize meta-data area.\n",
     [CRAMAlgNotAvail]="The 'cram-hmac-alg' you specified is not known in "
-                      "the kernel.\n"
+                      "the kernel.\n",
+    [CRAMAlgNotDigest]="The 'cram-hmac-alg' you specified is not a digest.",
+    [KMallocFailed]="kmalloc() failed. Out of memory?"
   };
 
   if (err_no>ARRY_SIZE(etext) || err_no<0) err_no=0;

From svn at svn.drbd.org  Fri Feb 11 16:59:11 2005
From: svn at svn.drbd.org (svn@svn.drbd.org)
Date: Fri Feb 11 16:59:18 2005
Subject: [DRBD-cvs] r1757 - trunk/drbd
Message-ID: <20050211155911.66E1D3BE6D@garcon.linbit.com>

Author: phil
Date: 2005-02-11 16:59:06 +0100 (Fri, 11 Feb 2005)
New Revision: 1757

Modified:
   trunk/drbd/drbd_fs.c
   trunk/drbd/drbd_main.c
   trunk/drbd/drbd_receiver.c
   trunk/drbd/drbd_req.c
   trunk/drbd/drbd_worker.c
Log:
Slowly bringing the work on item 9 [two primaries] into
shape...


Modified: trunk/drbd/drbd_fs.c
===================================================================
--- trunk/drbd/drbd_fs.c	2005-02-06 08:52:22 UTC (rev 1756)
+++ trunk/drbd/drbd_fs.c	2005-02-11 15:59:06 UTC (rev 1757)
@@ -577,7 +577,8 @@
 		}
 	}
 
-	if (mdev->ee_hash_s != new_conf.max_buffers/8 ) {
+	if (mdev->conf.two_primaries &&
+	    ( mdev->ee_hash_s != new_conf.max_buffers/8 ) ) {
 		new_ee_hash = kmalloc(mdev->ee_hash_s * sizeof(void*),
 				      GFP_KERNEL);
 		if(!new_ee_hash) {

Modified: trunk/drbd/drbd_main.c
===================================================================
--- trunk/drbd/drbd_main.c	2005-02-06 08:52:22 UTC (rev 1756)
+++ trunk/drbd/drbd_main.c	2005-02-11 15:59:06 UTC (rev 1757)
@@ -168,12 +168,10 @@
 }
 
 
-STATIC void tl_add(drbd_dev *mdev, drbd_request_t * new_item)
+STATIC void _tl_add(drbd_dev *mdev, drbd_request_t * new_item)
 {
 	struct drbd_barrier *b;
 
-	spin_lock_irq(&mdev->tl_lock);
-
 	b=mdev->newest_barrier;
 
 	new_item->barrier = b;
@@ -187,7 +185,12 @@
 	INIT_HLIST_NODE(&new_item->colision);
 	hlist_add_head( &new_item->colision, mdev->tl_hash + 
 			tl_hash_fn(mdev, drbd_req_get_sector(new_item) ));
+}
 
+STATIC void tl_add(drbd_dev *mdev, drbd_request_t * new_item)
+{
+	spin_lock_irq(&mdev->tl_lock);
+	_tl_add(mdev,new_item);
 	spin_unlock_irq(&mdev->tl_lock);
 }
 
@@ -422,10 +425,39 @@
 	return rv;
 }
 
-int ee_have_write(drbd_dev *mdev, drbd_request_t * req)
+STATIC int ee_have_write(drbd_dev *mdev, drbd_request_t * req)
 {
-	// PRE TODO: same as above for a request agains our acive EEs.
-	return 0;
+	struct hlist_head *slot;
+	struct hlist_node *n;
+	struct Tl_epoch_entry *ee;
+	sector_t sector = drbd_req_get_sector(req);
+	int size = drbd_req_get_size(req);
+	int i, rv=0;
+
+	D_ASSERT(size <= 1<<(HT_SHIFT+9) );
+
+	spin_lock_irq(&mdev->tl_lock);
+
+	for(i=-1;i<=1;i++ ) {
+		slot = mdev->tl_hash + ee_hash_fn(mdev,
+						  sector + i*(1<<(HT_SHIFT)));
+		hlist_for_each_entry(ee, n, slot, colision) {
+			if( overlaps(drbd_ee_get_sector(ee),
+				     drbd_ee_get_size(ee),
+				     sector,
+				     size) ) {
+				rv=1;
+				goto out;
+			} //overlaps()
+		} // hlist_for_each_entry()
+	}
+
+	// Good, no conflict found
+	_tl_add(mdev,req);
+ out:
+	spin_unlock_irq(&mdev->tl_lock);
+
+	return rv;
 }
 
 /**
@@ -1308,7 +1340,11 @@
 	if(test_and_clear_bit(ISSUE_BARRIER,&mdev->flags))
 		ok = _drbd_send_barrier(mdev);
 	if(ok) {
-		tl_add(mdev,req);
+		if (mdev->conf.two_primaries) {
+			if(ee_have_write(mdev,req)) return -1;
+		} else {
+			tl_add(mdev,req);
+		}
 		dump_packet(mdev,mdev->data.socket,0,(void*)&p, __FILE__, __LINE__);
 		set_bit(UNPLUG_REMOTE,&mdev->flags);
 		ok = sizeof(p) == drbd_send(mdev,mdev->data.socket,&p,sizeof(p),MSG_MORE);

Modified: trunk/drbd/drbd_receiver.c
===================================================================
--- trunk/drbd/drbd_receiver.c	2005-02-06 08:52:22 UTC (rev 1756)
+++ trunk/drbd/drbd_receiver.c	2005-02-11 15:59:06 UTC (rev 1757)
@@ -1036,7 +1036,7 @@
 	sector_t sector;
 	struct Tl_epoch_entry *e;
 	Drbd_Data_Packet *p = (Drbd_Data_Packet*)h;
-	int header_size,data_size, packet_seq,discard;
+	int header_size,data_size, packet_seq,discard=0;
 
 	// FIXME merge this code dups into some helper function
 	header_size = sizeof(*p) - sizeof(*h);
@@ -1057,16 +1057,18 @@
 	   traveling on msock 
 	   PRE TODO: Wrap around of seq_num !!! 
 	*/
-	packet_seq = be32_to_cpu(p->seq_num);
-	if( wait_event_interruptible(mdev->cstate_wait, 
-				     packet_seq <= peer_seq(mdev)+1) )
-		return FALSE;
+	if (mdev->conf.two_primaries) {
+		packet_seq = be32_to_cpu(p->seq_num);
+		if( wait_event_interruptible(mdev->cstate_wait, 
+					     packet_seq <= peer_seq(mdev)+1) )
+			return FALSE;
 
-	spin_lock(&mdev->peer_seq_lock); 
-	mdev->peer_seq = max(mdev->peer_seq, packet_seq);
- 	/* is update_peer_seq(mdev,packet_seq); */
-	discard = drbd_chk_discard(mdev,p->block_id,packet_seq);
-	spin_unlock(&mdev->peer_seq_lock);
+		spin_lock(&mdev->peer_seq_lock); 
+		mdev->peer_seq = max(mdev->peer_seq, packet_seq);
+		/* is update_peer_seq(mdev,packet_seq); */
+		discard = drbd_chk_discard(mdev,p->block_id,packet_seq);
+		spin_unlock(&mdev->peer_seq_lock);
+	}
 
 	sector = be64_to_cpu(p->sector);
 	e = read_in_block(mdev,data_size);

Modified: trunk/drbd/drbd_req.c
===================================================================
--- trunk/drbd/drbd_req.c	2005-02-06 08:52:22 UTC (rev 1756)
+++ trunk/drbd/drbd_req.c	2005-02-11 15:59:06 UTC (rev 1757)
@@ -307,6 +307,25 @@
 		 */
 		inc_ap_pending(mdev);
 		if (rw == WRITE) {
+			switch(drbd_send_dblock(mdev,req)) {
+			case 0: /* sending failed */
+				if (mdev->state.s.conn >= Connected)
+					drbd_force_state(mdev,NS(conn,NetworkFailure));
+				dec_ap_pending(mdev);
+				drbd_thread_restart_nowait(&mdev->receiver);
+				break;
+			case -1: /* concurrent write */
+				WARN("Concurrent write! [DISCARD L] sec=%lu\n",
+				     (unsigned long)sector);
+				local=0;
+				drbd_end_req(req, RQ_DRBD_DONE, 1, sector);
+				break;
+			default: /* block was sent */
+				if(mdev->conf.wire_protocol == DRBD_PROT_A) {
+					dec_ap_pending(mdev);
+					drbd_end_req(req, RQ_DRBD_SENT, 1, sector);
+				}
+			}
 			if (!drbd_send_dblock(mdev,req)) {
 				if (mdev->state.s.conn >= Connected)
 					drbd_force_state(mdev,NS(conn,NetworkFailure));

Modified: trunk/drbd/drbd_worker.c
===================================================================
--- trunk/drbd/drbd_worker.c	2005-02-06 08:52:22 UTC (rev 1756)
+++ trunk/drbd/drbd_worker.c	2005-02-11 15:59:06 UTC (rev 1757)
@@ -125,6 +125,12 @@
 
 	spin_unlock_irqrestore(&mdev->ee_lock,flags);
 
+	if( !hlist_unhashed(&e->colision) ) {
+		spin_lock_irqsave(&mdev->tl_lock,flags);
+		hlist_del_init(&e->colision);
+		spin_unlock_irqrestore(&mdev->tl_lock,flags);
+	}
+
 	drbd_chk_io_error(mdev,error);
 	wake_asender(mdev);
 	dec_local(mdev);

From svn at svn.drbd.org  Sat Feb 12 18:48:22 2005
From: svn at svn.drbd.org (svn@svn.drbd.org)
Date: Sat Feb 12 18:48:26 2005
Subject: [DRBD-cvs] r1758 - in trunk/drbd: . linux
Message-ID: <20050212174822.D56BB3BE6D@garcon.linbit.com>

Author: phil
Date: 2005-02-12 18:48:17 +0100 (Sat, 12 Feb 2005)
New Revision: 1758

Modified:
   trunk/drbd/drbd_fs.c
   trunk/drbd/drbd_int.h
   trunk/drbd/drbd_main.c
   trunk/drbd/drbd_receiver.c
   trunk/drbd/drbd_sizeof_sanity_check.c
   trunk/drbd/linux/drbd.h
Log:
The implementation of the "allow-two-primaries" option
is now complete, but untested... might crash everywhere...


Modified: trunk/drbd/drbd_fs.c
===================================================================
--- trunk/drbd/drbd_fs.c	2005-02-11 15:59:06 UTC (rev 1757)
+++ trunk/drbd/drbd_fs.c	2005-02-12 17:48:17 UTC (rev 1758)
@@ -569,18 +569,18 @@
 
 
 	if (mdev->tl_hash_s != new_conf.max_epoch_size/8 ) {
-		new_tl_hash = kmalloc(mdev->tl_hash_s * sizeof(void*),
-				      GFP_KERNEL);
+		new_tl_hash=kmalloc((new_conf.max_epoch_size/8)*sizeof(void*),
+				    GFP_KERNEL);
 		if(!new_tl_hash) {
 			retcode=KMallocFailed;
 			goto fail_ioctl;
 		}
 	}
 
-	if (mdev->conf.two_primaries &&
+	if (new_conf.two_primaries &&
 	    ( mdev->ee_hash_s != new_conf.max_buffers/8 ) ) {
-		new_ee_hash = kmalloc(mdev->ee_hash_s * sizeof(void*),
-				      GFP_KERNEL);
+		new_ee_hash=kmalloc((new_conf.max_buffers/8)*sizeof(void*),
+				    GFP_KERNEL);
 		if(!new_ee_hash) {
 			retcode=KMallocFailed;
 			goto fail_ioctl;

Modified: trunk/drbd/drbd_int.h
===================================================================
--- trunk/drbd/drbd_int.h	2005-02-11 15:59:06 UTC (rev 1757)
+++ trunk/drbd/drbd_int.h	2005-02-12 17:48:17 UTC (rev 1758)
@@ -307,6 +307,7 @@
 	NegDReply,    // Local disk is broken...
 	NegRSDReply,  // Local disk is broken...
 	BarrierAck,
+	DiscardNote,
 
 	MAX_CMD,
 	MayIgnore = 0x100, // Flag only to test if (cmd > MayIgnore) ...
@@ -345,7 +346,8 @@
 		[NegAck]           = "NegAck",
 		[NegDReply]        = "NegDReply",
 		[NegRSDReply]      = "NegRSDReply",
-		[BarrierAck]       = "BarrierAck"
+		[BarrierAck]       = "BarrierAck",
+		[DiscardNote]      = "DiscardNote"
 	};
 
 	if (cmd == HandShake) return "HandShake";
@@ -490,6 +492,13 @@
 	u32       bit_map_gen[5];
 } __attribute((packed)) Drbd06_Parameter_P;
 
+typedef struct {
+	Drbd_Header head;
+	u64         block_id;
+	u32         seq_num;
+	u32         pad;
+} __attribute((packed)) Drbd_Discard_Packet;
+
 typedef union {
 	Drbd_Header              head;
 	Drbd_HandShake_Packet    HandShake;
@@ -560,13 +569,14 @@
 struct drbd_barrier;
 struct drbd_request {
 	struct drbd_work w;
-	long magic;
-	int rq_status;
 	struct drbd_barrier *barrier; // The next barrier.
 	struct bio *master_bio;       // master bio pointer
 	struct bio *private_bio;
 	struct hlist_node colision;
 	drbd_dev *mdev;
+	long magic;
+	int rq_status;
+	int seq_num;
 };
 
 struct drbd_barrier {
@@ -790,9 +800,7 @@
 extern void tl_clear(drbd_dev *mdev);
 extern int tl_dependence(drbd_dev *mdev, drbd_request_t * item);
 extern int tl_verify(drbd_dev *mdev, drbd_request_t * item, sector_t sector);
-#define TLHW_FLAG_SENT   0x10000000
-#define TLHW_FLAG_RECVW  0x20000000
-extern int req_have_write(drbd_dev *mdev, struct Tl_epoch_entry *e, int flags);
+extern drbd_request_t * req_have_write(drbd_dev *, struct Tl_epoch_entry *);
 extern void drbd_free_sock(drbd_dev *mdev);
 extern int drbd_send(drbd_dev *mdev, struct socket *sock,
 		     void* buf, size_t size, unsigned msg_flags);
@@ -822,6 +830,7 @@
 			      sector_t sector,int size, u64 block_id);
 extern int drbd_send_bitmap(drbd_dev *mdev);
 extern int _drbd_send_bitmap(drbd_dev *mdev);
+extern int drbd_send_discard(drbd_dev *mdev, drbd_request_t *req);
 extern void drbd_free_ll_dev(drbd_dev *mdev);
 extern int drbd_io_error(drbd_dev* mdev);
 extern void drbd_mdev_cleanup(drbd_dev *mdev);

Modified: trunk/drbd/drbd_main.c
===================================================================
--- trunk/drbd/drbd_main.c	2005-02-11 15:59:06 UTC (rev 1757)
+++ trunk/drbd/drbd_main.c	2005-02-12 17:48:17 UTC (rev 1758)
@@ -375,20 +375,14 @@
 	return !( ( s1 + (l1>>9) <= s2 ) || ( s1 >= s2 + (l2>>9) ) );
 }
 
-/* Return values:
- *
- * 0 ... no conflicting write
- * 1 ... a conflicting write, have not got ack by now.
- * 2 ... a conflicting write, have got also got ack.
- */
-int req_have_write(drbd_dev *mdev, struct Tl_epoch_entry *e, int flags)
+drbd_request_t * req_have_write(drbd_dev *mdev, struct Tl_epoch_entry *e)
 {
 	struct hlist_head *slot;
 	struct hlist_node *n;
 	drbd_request_t * req;
 	sector_t sector = drbd_ee_get_sector(e);	
 	int size = drbd_ee_get_size(e);
-	int i, rv=0;
+	int i;
 
 	D_ASSERT(size <= 1<<(HT_SHIFT+9) );
 
@@ -401,20 +395,10 @@
 			if( overlaps(drbd_req_get_sector(req),
 				     drbd_req_get_size(req),
 				     sector,
-				     size) ) {
-				rv=1;
-				if( req->rq_status & RQ_DRBD_SENT ) rv++;
-				if( flags & TLHW_FLAG_SENT ) {
-					req->rq_status |= RQ_DRBD_SENT;
-				}
-				if( flags & TLHW_FLAG_RECVW ) {
-					req->rq_status |= RQ_DRBD_RECVW;
-				}
-				goto out;
-			} //overlaps()
+				     size) ) goto out;
 		} // hlist_for_each_entry()
 	}
-
+	req = NULL;
 	// Good, no conflict found
 	INIT_HLIST_NODE(&e->colision);
 	hlist_add_head( &e->colision, mdev->ee_hash + 
@@ -422,17 +406,18 @@
  out:
 	spin_unlock_irq(&mdev->tl_lock);
 
-	return rv;
+	return req;
 }
 
-STATIC int ee_have_write(drbd_dev *mdev, drbd_request_t * req)
+STATIC struct Tl_epoch_entry * ee_have_write(drbd_dev *mdev, 
+					     drbd_request_t * req)
 {
 	struct hlist_head *slot;
 	struct hlist_node *n;
 	struct Tl_epoch_entry *ee;
 	sector_t sector = drbd_req_get_sector(req);
 	int size = drbd_req_get_size(req);
-	int i, rv=0;
+	int i;
 
 	D_ASSERT(size <= 1<<(HT_SHIFT+9) );
 
@@ -445,19 +430,16 @@
 			if( overlaps(drbd_ee_get_sector(ee),
 				     drbd_ee_get_size(ee),
 				     sector,
-				     size) ) {
-				rv=1;
-				goto out;
-			} //overlaps()
+				     size) ) goto out;
 		} // hlist_for_each_entry()
 	}
-
+	ee = NULL;
 	// Good, no conflict found
 	_tl_add(mdev,req);
  out:
 	spin_unlock_irq(&mdev->tl_lock);
 
-	return rv;
+	return ee;
 }
 
 /**
@@ -1000,7 +982,17 @@
 	return ok;
 }
 
+int drbd_send_discard(drbd_dev *mdev, drbd_request_t *req)
+{
+	Drbd_Discard_Packet p;
 
+	p.block_id = (unsigned long)req;
+	p.seq_num  = cpu_to_be32(req->seq_num);
+
+	return drbd_send_cmd(mdev,mdev->meta.socket,DiscardNote,
+			     (Drbd_Header*)&p,sizeof(p));
+}
+
 int drbd_send_state(drbd_dev *mdev)
 {
 	Drbd_State_Packet p;
@@ -1307,7 +1299,8 @@
 
 	p.sector   = cpu_to_be64(drbd_req_get_sector(req));
 	p.block_id = (unsigned long)req;
-	p.seq_num  = cpu_to_be32(atomic_add_return(1,&mdev->packet_seq));
+	p.seq_num  = cpu_to_be32( req->seq_num =
+				  atomic_add_return(1,&mdev->packet_seq) );
 
 	/* About tl_add():
 	1. This must be within the semaphor,

Modified: trunk/drbd/drbd_receiver.c
===================================================================
--- trunk/drbd/drbd_receiver.c	2005-02-11 15:59:06 UTC (rev 1757)
+++ trunk/drbd/drbd_receiver.c	2005-02-12 17:48:17 UTC (rev 1758)
@@ -1011,21 +1011,26 @@
 	return ok;
 }
 
-STATIC int drbd_chk_discard(drbd_dev *mdev,u64 block_id,int seq_num)
+STATIC int drbd_chk_discard(drbd_dev *mdev,struct Tl_epoch_entry *e)
 {
 	struct drbd_discard_note *dn;
 	struct list_head *le;
 
 	MUST_HOLD(&mdev->peer_seq_lock);
-
+ start_over:
 	list_for_each(le,&mdev->discard) {
 		dn = list_entry(le, struct drbd_discard_note, list);
-		if( dn->seq_num == seq_num ) {
-			D_ASSERT( dn->block_id == block_id );
+		if( dn->seq_num == mdev->peer_seq ) {
+			D_ASSERT( dn->block_id == e->block_id );
 			list_del(le);
 			kfree(dn);
 			return 1;
-		} 
+		}
+		if( dn->seq_num < mdev->peer_seq ) {
+			list_del(le);
+			kfree(dn);
+			goto start_over;
+		}
 	}
 	return 0;
 }
@@ -1035,8 +1040,9 @@
 {
 	sector_t sector;
 	struct Tl_epoch_entry *e;
+	drbd_request_t * req;
 	Drbd_Data_Packet *p = (Drbd_Data_Packet*)h;
-	int header_size,data_size, packet_seq,discard=0;
+	int header_size, data_size, packet_seq, discard;
 
 	// FIXME merge this code dups into some helper function
 	header_size = sizeof(*p) - sizeof(*h);
@@ -1052,6 +1058,20 @@
 	if (drbd_recv(mdev, h->payload, header_size) != header_size)
 		return FALSE;
 
+	sector = be64_to_cpu(p->sector);
+	e = read_in_block(mdev,data_size);
+	if (!e) return FALSE;
+
+	if(!inc_local(mdev)) {
+		if (DRBD_ratelimit(5*HZ,5))
+			ERR("Can not write mirrored data block to local disk.\n");
+		drbd_send_ack(mdev,NegAck,e);
+		spin_lock_irq(&mdev->ee_lock);
+		drbd_put_ee(mdev,e);
+		spin_unlock_irq(&mdev->ee_lock);
+		return TRUE;
+	}
+
 	/* This wait_event is here to make sure that never ever an
 	   DATA packet traveling via sock can overtake an ACK packet
 	   traveling on msock 
@@ -1066,68 +1086,58 @@
 		spin_lock(&mdev->peer_seq_lock); 
 		mdev->peer_seq = max(mdev->peer_seq, packet_seq);
 		/* is update_peer_seq(mdev,packet_seq); */
-		discard = drbd_chk_discard(mdev,p->block_id,packet_seq);
+		discard = drbd_chk_discard(mdev,e);
 		spin_unlock(&mdev->peer_seq_lock);
-	}
 
-	sector = be64_to_cpu(p->sector);
-	e = read_in_block(mdev,data_size);
-	if (!e) return FALSE;
-
-	if(!inc_local(mdev)) {
-		if (DRBD_ratelimit(5*HZ,5))
-			ERR("Can not write mirrored data block to local disk.\n");
-		drbd_send_ack(mdev,NegAck,e);
-		spin_lock_irq(&mdev->ee_lock);
-		drbd_put_ee(mdev,e);
-		spin_unlock_irq(&mdev->ee_lock);
-		return TRUE;
-	}
-
-	if(discard) {
-		spin_lock_irq(&mdev->ee_lock);
-		drbd_put_ee(mdev,e);
-		spin_unlock_irq(&mdev->ee_lock);
-		WARN("Concurrent write! [DISCARD BY LIST] sec=%lu\n",
-		     (unsigned long)sector);
-		return TRUE;
-	}
-
-	switch( req_have_write(mdev, e, 0) ) {
-	case 2: /* Conflicting write, got ACK */
-		/* write afterwards ...*/
-		WARN("Concurrent write! [W AFTERWARDS] sec=%lu\n",
-		     (unsigned long)sector);
-		if( wait_event_interruptible(mdev->cstate_wait,
-		     !req_have_write(mdev,e,TLHW_FLAG_RECVW))) {
+		if(discard) {
 			spin_lock_irq(&mdev->ee_lock);
 			drbd_put_ee(mdev,e);
 			spin_unlock_irq(&mdev->ee_lock);
-			return FALSE;
-		}
-	case 1: /* Conflicting write, no ACK by now*/
-		if (test_bit(UNIQUE,&mdev->flags)) {
-			spin_lock_irq(&mdev->ee_lock);
-			drbd_put_ee(mdev,e);
-			spin_unlock_irq(&mdev->ee_lock);
-			WARN("Concurrent write! [DISCARD BY FLAG] sec=%lu\n",
+			WARN("Concurrent write! [DISCARD BY LIST] sec=%lu\n",
 			     (unsigned long)sector);
 			return TRUE;
-		} else {
-			/* write afterwards, do not expect ACK */
-			WARN("Concurrent write! [W AFTERWARDS] sec=%lu\n",
-			     (unsigned long)sector);
-			if( wait_event_interruptible(mdev->cstate_wait,
-			      !req_have_write(mdev,e,
-				            TLHW_FLAG_RECVW|TLHW_FLAG_SENT))) {
-				spin_lock_irq(&mdev->ee_lock);
-				drbd_put_ee(mdev,e);
-				spin_unlock_irq(&mdev->ee_lock);
-				return FALSE;
+		}
+
+		req = req_have_write(mdev, e);
+		
+		if(req) {
+			if( req->rq_status & RQ_DRBD_SENT ) {
+				/* Conflicting write, got ACK */
+				/* write afterwards ...*/
+				WARN("Concurrent write! [W AFTERWARDS] "
+				     "sec=%lu\n",(unsigned long)sector);
+				if( wait_event_interruptible(mdev->cstate_wait,
+					       !req_have_write(mdev,e))) {
+					spin_lock_irq(&mdev->ee_lock);
+					drbd_put_ee(mdev,e);
+					spin_unlock_irq(&mdev->ee_lock);
+					return FALSE;
+				}
+			} else {
+				/* Conflicting write, no ACK by now*/
+				if (test_bit(UNIQUE,&mdev->flags)) {
+					spin_lock_irq(&mdev->ee_lock);
+					drbd_put_ee(mdev,e);
+					spin_unlock_irq(&mdev->ee_lock);
+					WARN("Concurrent write! [DISCARD BY FLAG] sec=%lu\n",
+					     (unsigned long)sector);
+					return TRUE;
+				} else {
+					/* write afterwards do not exp ACK */
+					WARN("Concurrent write! [W AFTERWARDS] sec=%lu\n",
+					     (unsigned long)sector);
+					drbd_send_discard(mdev,req);
+					drbd_end_req(req, RQ_DRBD_SENT, 1, sector);
+					if( wait_event_interruptible(mdev->cstate_wait,
+								     !req_have_write(mdev,e))) {
+						spin_lock_irq(&mdev->ee_lock);
+						drbd_put_ee(mdev,e);
+						spin_unlock_irq(&mdev->ee_lock);
+						return FALSE;
+					}
+				}
 			}
 		}
-		/* case 0:   no conflicting write. */
-		/* write it to disk now... */
 	}
 
 	e->block_id = p->block_id; // no meaning on this side, e* on partner
@@ -2265,6 +2275,27 @@
 	return TRUE;
 }
 
+STATIC int got_Discard(drbd_dev *mdev, Drbd_Header* h)
+{
+	Drbd_Discard_Packet *p = (Drbd_Discard_Packet*)h;
+	struct drbd_discard_note *dn;
+
+	dn = kmalloc(sizeof(struct drbd_discard_note),GFP_KERNEL);
+	if(!dn) {
+		ERR("kmalloc(drbd_discard_note) failed.");
+		return FALSE;
+	}
+
+	dn->block_id = (long)p->block_id;
+	dn->seq_num = be32_to_cpu(p->seq_num);
+
+	spin_lock(&mdev->peer_seq_lock);
+	list_add(&dn->list,&mdev->discard);
+	spin_unlock(&mdev->peer_seq_lock);
+
+	return TRUE;
+}
+
 struct asender_cmd {
 	size_t pkt_size;
 	int (*process)(drbd_dev *mdev, Drbd_Header* h);
@@ -2290,6 +2321,7 @@
 		[NegDReply] ={ sizeof(Drbd_BlockAck_Packet),  got_NegDReply },
 		[NegRSDReply]={sizeof(Drbd_BlockAck_Packet),  got_NegRSDReply},
 		[BarrierAck]={ sizeof(Drbd_BarrierAck_Packet),got_BarrierAck },
+		[DiscardNote]={sizeof(Drbd_Discard_Packet),   got_Discard },
 	};
 
 	sprintf(current->comm, "drbd%d_asender", (int)(mdev-drbd_conf));

Modified: trunk/drbd/drbd_sizeof_sanity_check.c
===================================================================
--- trunk/drbd/drbd_sizeof_sanity_check.c	2005-02-11 15:59:06 UTC (rev 1757)
+++ trunk/drbd/drbd_sizeof_sanity_check.c	2005-02-12 17:48:17 UTC (rev 1758)
@@ -15,10 +15,10 @@
 int sizeof_drbd_structs_sanity_check(void)
 {
 	int err = 0, s = 0;
-	SZO(struct disk_config,		 24)
+	SZO(struct disk_config,		 32)
 	SZO(struct net_config,		432)
 	SZO(struct syncer_config,	 24)
-	SZO(struct ioctl_disk_config,	 32)
+	SZO(struct ioctl_disk_config,	 40)
 	SZO(struct ioctl_net_config,	440)
 	SZO(struct ioctl_syncer_config,	 32)
 	SZO(struct ioctl_wait,		 16)

Modified: trunk/drbd/linux/drbd.h
===================================================================
--- trunk/drbd/linux/drbd.h	2005-02-11 15:59:06 UTC (rev 1757)
+++ trunk/drbd/linux/drbd.h	2005-02-12 17:48:17 UTC (rev 1758)
@@ -77,6 +77,7 @@
 	IN int      meta_device;
 	IN int      meta_index;
 	IN int      split_brain_fix;
+	const int   _pad;
 };
 
 enum disconnect_handler {

From svn at svn.drbd.org  Sat Feb 12 19:14:29 2005
From: svn at svn.drbd.org (svn@svn.drbd.org)
Date: Sat Feb 12 19:14:30 2005
Subject: [DRBD-cvs] r1759 - trunk/user
Message-ID: <20050212181429.787EB3BE6D@garcon.linbit.com>

Author: phil
Date: 2005-02-12 19:14:25 +0100 (Sat, 12 Feb 2005)
New Revision: 1759

Modified:
   trunk/user/drbdadm_main.c
   trunk/user/drbdmeta.c
Log:
Two micro fixes...


Modified: trunk/user/drbdadm_main.c
===================================================================
--- trunk/user/drbdadm_main.c	2005-02-12 17:48:17 UTC (rev 1758)
+++ trunk/user/drbdadm_main.c	2005-02-12 18:14:25 UTC (rev 1759)
@@ -873,6 +873,7 @@
   struct sigaction so,sa;
 
   saved_stdin = -1;
+  saved_stdout = -1;
   if( isatty(fileno(stdin)) == 0 || isatty(fileno(stdout)) == 0 ) {
     fprintf(stderr,"WARN: stdin/stdout is not a TTY; using /dev/console");
     fprintf(stdout,"WARN: stdin/stdout is not a TTY; using /dev/console");

Modified: trunk/user/drbdmeta.c
===================================================================
--- trunk/user/drbdmeta.c	2005-02-12 17:48:17 UTC (rev 1758)
+++ trunk/user/drbdmeta.c	2005-02-12 18:14:25 UTC (rev 1759)
@@ -554,8 +554,10 @@
 	char answer[16];
 	int rr;
 
-	printf("%s [yes/no] ", text);
-	rr = scanf("%[yesno]15s", answer);
+	do {
+		printf("%s [yes/no] ", text);
+		rr = scanf("%15s", answer);
+	} while (rr != 1);
 	return !strcmp(answer, "yes");
 }
 

From svn at svn.drbd.org  Sun Feb 13 20:34:23 2005
From: svn at svn.drbd.org (svn@svn.drbd.org)
Date: Sun Feb 13 20:34:26 2005
Subject: [DRBD-cvs] r1760 - in trunk: drbd testing
Message-ID: <20050213193423.0CECA3BE6D@garcon.linbit.com>

Author: phil
Date: 2005-02-13 20:34:19 +0100 (Sun, 13 Feb 2005)
New Revision: 1760

Modified:
   trunk/drbd/drbd_int.h
   trunk/drbd/drbd_main.c
   trunk/drbd/drbd_receiver.c
   trunk/drbd/drbd_req.c
   trunk/testing/uml-2.6.gdbinit
Log:
A little debugging session. Basic mirroring is working again...


Modified: trunk/drbd/drbd_int.h
===================================================================
--- trunk/drbd/drbd_int.h	2005-02-12 18:14:25 UTC (rev 1759)
+++ trunk/drbd/drbd_int.h	2005-02-13 19:34:19 UTC (rev 1760)
@@ -1400,8 +1400,8 @@
 {
 	spin_lock(&mdev->peer_seq_lock);
 	mdev->peer_seq = max(mdev->peer_seq, new_seq);
+	spin_unlock(&mdev->peer_seq_lock);
 	wake_up(&mdev->cstate_wait);
-	spin_unlock(&mdev->peer_seq_lock);
 }
 
 static inline int peer_seq(drbd_dev* mdev)

Modified: trunk/drbd/drbd_main.c
===================================================================
--- trunk/drbd/drbd_main.c	2005-02-12 18:14:25 UTC (rev 1759)
+++ trunk/drbd/drbd_main.c	2005-02-13 19:34:19 UTC (rev 1760)
@@ -424,7 +424,7 @@
 	spin_lock_irq(&mdev->tl_lock);
 
 	for(i=-1;i<=1;i++ ) {
-		slot = mdev->tl_hash + ee_hash_fn(mdev,
+		slot = mdev->ee_hash + ee_hash_fn(mdev,
 						  sector + i*(1<<(HT_SHIFT)));
 		hlist_for_each_entry(ee, n, slot, colision) {
 			if( overlaps(drbd_ee_get_sector(ee),
@@ -1614,6 +1614,7 @@
 	atomic_set(&mdev->unacked_cnt,0);
 	atomic_set(&mdev->local_cnt,0);
 	atomic_set(&mdev->resync_locked,0);
+	atomic_set(&mdev->packet_seq,0);
 
 	init_MUTEX(&mdev->md_io_mutex);
 	init_MUTEX(&mdev->data.mutex);

Modified: trunk/drbd/drbd_receiver.c
===================================================================
--- trunk/drbd/drbd_receiver.c	2005-02-12 18:14:25 UTC (rev 1759)
+++ trunk/drbd/drbd_receiver.c	2005-02-13 19:34:19 UTC (rev 1760)
@@ -756,7 +756,6 @@
 	int epoch_size;
 	Drbd_Barrier_Packet *p = (Drbd_Barrier_Packet*)h;
 
-	ERR_IF(mdev->state.s.role != Secondary) return FALSE;
 	ERR_IF(h->length != (sizeof(*p)-sizeof(*h))) return FALSE;
 
 	rv = drbd_recv(mdev, h->payload, h->length);

Modified: trunk/drbd/drbd_req.c
===================================================================
--- trunk/drbd/drbd_req.c	2005-02-12 18:14:25 UTC (rev 1759)
+++ trunk/drbd/drbd_req.c	2005-02-13 19:34:19 UTC (rev 1760)
@@ -326,15 +326,6 @@
 					drbd_end_req(req, RQ_DRBD_SENT, 1, sector);
 				}
 			}
-			if (!drbd_send_dblock(mdev,req)) {
-				if (mdev->state.s.conn >= Connected)
-					drbd_force_state(mdev,NS(conn,NetworkFailure));
-				dec_ap_pending(mdev);
-				drbd_thread_restart_nowait(&mdev->receiver);
-			} else if(mdev->conf.wire_protocol == DRBD_PROT_A) {
-				dec_ap_pending(mdev);
-				drbd_end_req(req, RQ_DRBD_SENT, 1, sector);
-			}
 		} else if (target_area_out_of_sync) {
 			drbd_read_remote(mdev,req);
 		} else {

Modified: trunk/testing/uml-2.6.gdbinit
===================================================================
--- trunk/testing/uml-2.6.gdbinit	2005-02-12 18:14:25 UTC (rev 1759)
+++ trunk/testing/uml-2.6.gdbinit	2005-02-13 19:34:19 UTC (rev 1760)
@@ -33,20 +33,41 @@
   p $rv->module_core
 end
 
+# for old kernels, worked with linux-2.6.1
+#define linux-ps
+#  set $ps_ph_i = 1<<pidhash_shift
+#  printf "---TASK---  -PID-  --------COMM----------\n"
+#  while $ps_ph_i > 0
+#    set $ps_ph_i = $ps_ph_i - 1
+#    set $ps_plist = &pid_hash[0][$ps_ph_i]
+#    set $ps_pitem = $ps_plist->next
+#    while $ps_pitem != $ps_plist
+#      lx-container-of-struct $ps_pitem pid hash_chain
+#      set $ps_pid = $rv
+#      set $ps_h = $ps_pid->task_list.next
+#      lx-container-of-struct $ps_h task_struct pids[0].pid_chain
+#      set $ps_t = $rv
+#      printf "%8p  %-5d  %-20s\n", $ps_t, $ps_pid->nr, $ps_t->comm
+#      set $ps_pitem = $ps_pitem->next
+#    end
+#  end
+#end
+
 define linux-ps
   set $ps_ph_i = 1<<pidhash_shift
   printf "---TASK---  -PID-  --------COMM----------\n"
   while $ps_ph_i > 0
     set $ps_ph_i = $ps_ph_i - 1
-    set $ps_plist = &pid_hash[0][$ps_ph_i]
-    set $ps_pitem = $ps_plist->next
-    while $ps_pitem != $ps_plist
-      lx-container-of-struct $ps_pitem pid hash_chain
+    set $ps_pitem = pid_hash[0][$ps_ph_i]->first
+    while $ps_pitem != 0
+      lx-container-of-struct $ps_pitem pid pid_chain
       set $ps_pid = $rv
-      set $ps_h = $ps_pid->task_list.next
-      lx-container-of-struct $ps_h task_struct pids[0].pid_chain
+      set $ps_h = $ps_pid->pid_list.next
+      lx-container-of-struct $ps_h task_struct pids[0].pid_list
       set $ps_t = $rv
-      printf "%8p  %-5d  %-20s\n", $ps_t, $ps_pid->nr, $ps_t->comm
+      if $ps_pid->nr != 0
+        printf "%8p  %-5d  %-20s\n", $ps_t, $ps_pid->nr, $ps_t->comm
+      end
       set $ps_pitem = $ps_pitem->next
     end
   end

From svn at svn.drbd.org  Mon Feb 14 17:01:05 2005
From: svn at svn.drbd.org (svn@svn.drbd.org)
Date: Mon Feb 14 17:01:08 2005
Subject: [DRBD-cvs] r1761 - trunk/drbd
Message-ID: <20050214160105.C80693BE6E@garcon.linbit.com>

Author: phil
Date: 2005-02-14 17:01:02 +0100 (Mon, 14 Feb 2005)
New Revision: 1761

Modified:
   trunk/drbd/drbd_fs.c
   trunk/drbd/drbd_main.c
   trunk/drbd/drbd_receiver.c
   trunk/drbd/drbd_req.c
Log:
Another debugging session

* initialize sequencer to 0 on connect
* Fill ee_size before calling req_have_write()
* Print WARN() before waiting for correct seq_num
* Fix various counter if we discard a packet
* Only increate packet_seq if we really send a packet

... this was for sure not the last debugging session, but
we are comming along...


Modified: trunk/drbd/drbd_fs.c
===================================================================
--- trunk/drbd/drbd_fs.c	2005-02-13 19:34:19 UTC (rev 1760)
+++ trunk/drbd/drbd_fs.c	2005-02-14 16:01:02 UTC (rev 1761)
@@ -978,6 +978,10 @@
 	struct ioctl_get_gen_cnt cn;
 	int i;
 
+	if( mdev->state.s.disk <= Failed ) {
+		return -EIO;
+	}
+
 	memset(&cn,0,sizeof(cn));
 
 	for(i=Flags;i<=ArbitraryCnt;i++)

Modified: trunk/drbd/drbd_main.c
===================================================================
--- trunk/drbd/drbd_main.c	2005-02-13 19:34:19 UTC (rev 1760)
+++ trunk/drbd/drbd_main.c	2005-02-14 16:01:02 UTC (rev 1761)
@@ -1292,16 +1292,6 @@
 
 	ERR_IF(!req || !req->master_bio) return FALSE;
 
-	p.head.magic   = BE_DRBD_MAGIC;
-	p.head.command = cpu_to_be16(Data);
-	p.head.length  = cpu_to_be16( sizeof(p)-sizeof(Drbd_Header)
-				     + drbd_req_get_size(req) );
-
-	p.sector   = cpu_to_be64(drbd_req_get_sector(req));
-	p.block_id = (unsigned long)req;
-	p.seq_num  = cpu_to_be32( req->seq_num =
-				  atomic_add_return(1,&mdev->packet_seq) );
-
 	/* About tl_add():
 	1. This must be within the semaphor,
 	   to ensure right order in tl_ data structure and to
@@ -1334,11 +1324,29 @@
 		ok = _drbd_send_barrier(mdev);
 	if(ok) {
 		if (mdev->conf.two_primaries) {
-			if(ee_have_write(mdev,req)) return -1;
+			if(ee_have_write(mdev,req)) {
+				ok=-1;
+				goto out;
+			}
 		} else {
 			tl_add(mdev,req);
 		}
+
+		p.head.magic   = BE_DRBD_MAGIC;
+		p.head.command = cpu_to_be16(Data);
+		p.head.length  = cpu_to_be16( sizeof(p)-sizeof(Drbd_Header)
+					      + drbd_req_get_size(req) );
+
+		p.sector   = cpu_to_be64(drbd_req_get_sector(req));
+		p.block_id = (unsigned long)req;
+		p.seq_num  = cpu_to_be32( req->seq_num =
+				     atomic_add_return(1,&mdev->packet_seq) );
+
 		dump_packet(mdev,mdev->data.socket,0,(void*)&p, __FILE__, __LINE__);
+		// Instrumentation
+		set_current_state(TASK_INTERRUPTIBLE);
+		schedule_timeout(HZ);
+
 		set_bit(UNPLUG_REMOTE,&mdev->flags);
 		ok = sizeof(p) == drbd_send(mdev,mdev->data.socket,&p,sizeof(p),MSG_MORE);
 		if(ok) {
@@ -1357,6 +1365,7 @@
 		drbd_end_req(req,RQ_DRBD_SENT,ERF_NOTLD|1,
 			     drbd_req_get_sector(req));
 	}
+ out:
 	spin_lock(&mdev->send_task_lock);
 	mdev->send_task=NULL;
 	spin_unlock(&mdev->send_task_lock);

Modified: trunk/drbd/drbd_receiver.c
===================================================================
--- trunk/drbd/drbd_receiver.c	2005-02-13 19:34:19 UTC (rev 1760)
+++ trunk/drbd/drbd_receiver.c	2005-02-14 16:01:02 UTC (rev 1761)
@@ -716,6 +716,9 @@
 	sock->sk->sk_sndtimeo = mdev->conf.timeout*HZ/20;
 	sock->sk->sk_rcvtimeo = MAX_SCHEDULE_TIMEOUT;
 
+	atomic_set(&mdev->packet_seq,0);
+	mdev->peer_seq=0;
+
 	drbd_thread_start(&mdev->asender);
 
 	drbd_send_protocol(mdev);
@@ -1071,6 +1074,10 @@
 		return TRUE;
 	}
 
+	e->block_id = p->block_id; // no meaning on this side, e* on partner
+	drbd_ee_prepare_write(mdev, e, sector, data_size);
+	e->w.cb     = e_end_block;
+
 	/* This wait_event is here to make sure that never ever an
 	   DATA packet traveling via sock can overtake an ACK packet
 	   traveling on msock 
@@ -1078,6 +1085,10 @@
 	*/
 	if (mdev->conf.two_primaries) {
 		packet_seq = be32_to_cpu(p->seq_num);
+		if( packet_seq > peer_seq(mdev)+1 ) {
+			WARN(" will wait till (packet_seq) %d <= %d\n",
+			     packet_seq,peer_seq(mdev)+1);
+		}
 		if( wait_event_interruptible(mdev->cstate_wait, 
 					     packet_seq <= peer_seq(mdev)+1) )
 			return FALSE;
@@ -1092,6 +1103,8 @@
 			spin_lock_irq(&mdev->ee_lock);
 			drbd_put_ee(mdev,e);
 			spin_unlock_irq(&mdev->ee_lock);
+			atomic_inc(&mdev->epoch_size);
+			dec_local(mdev);
 			WARN("Concurrent write! [DISCARD BY LIST] sec=%lu\n",
 			     (unsigned long)sector);
 			return TRUE;
@@ -1103,7 +1116,7 @@
 			if( req->rq_status & RQ_DRBD_SENT ) {
 				/* Conflicting write, got ACK */
 				/* write afterwards ...*/
-				WARN("Concurrent write! [W AFTERWARDS] "
+				WARN("Concurrent write! [W AFTERWARDS1] "
 				     "sec=%lu\n",(unsigned long)sector);
 				if( wait_event_interruptible(mdev->cstate_wait,
 					       !req_have_write(mdev,e))) {
@@ -1118,12 +1131,14 @@
 					spin_lock_irq(&mdev->ee_lock);
 					drbd_put_ee(mdev,e);
 					spin_unlock_irq(&mdev->ee_lock);
+					atomic_inc(&mdev->epoch_size);
+					dec_local(mdev);
 					WARN("Concurrent write! [DISCARD BY FLAG] sec=%lu\n",
 					     (unsigned long)sector);
 					return TRUE;
 				} else {
 					/* write afterwards do not exp ACK */
-					WARN("Concurrent write! [W AFTERWARDS] sec=%lu\n",
+					WARN("Concurrent write! [W AFTERWARDS2] sec=%lu\n",
 					     (unsigned long)sector);
 					drbd_send_discard(mdev,req);
 					drbd_end_req(req, RQ_DRBD_SENT, 1, sector);
@@ -1139,11 +1154,6 @@
 		}
 	}
 
-	e->block_id = p->block_id; // no meaning on this side, e* on partner
-
-	drbd_ee_prepare_write(mdev, e, sector, data_size);
-	e->w.cb     = e_end_block;
-
 	spin_lock_irq(&mdev->ee_lock);
 	list_add(&e->w.list,&mdev->active_ee);
 	spin_unlock_irq(&mdev->ee_lock);
@@ -1160,6 +1170,10 @@
 		break;
 	}
 
+	// Instrumentation
+	set_current_state(TASK_INTERRUPTIBLE);
+	schedule_timeout(HZ);
+
 	drbd_generic_make_request(WRITE,&e->private_bio);
 
 	receive_data_tail(mdev,data_size);

Modified: trunk/drbd/drbd_req.c
===================================================================
--- trunk/drbd/drbd_req.c	2005-02-13 19:34:19 UTC (rev 1760)
+++ trunk/drbd/drbd_req.c	2005-02-14 16:01:02 UTC (rev 1761)
@@ -317,6 +317,8 @@
 			case -1: /* concurrent write */
 				WARN("Concurrent write! [DISCARD L] sec=%lu\n",
 				     (unsigned long)sector);
+				dec_local(mdev);
+				dec_ap_pending(mdev);
 				local=0;
 				drbd_end_req(req, RQ_DRBD_DONE, 1, sector);
 				break;

From svn at svn.drbd.org  Mon Feb 14 21:08:47 2005
From: svn at svn.drbd.org (svn@svn.drbd.org)
Date: Mon Feb 14 21:08:50 2005
Subject: [DRBD-cvs] r1762 - in trunk: . drbd
Message-ID: <20050214200847.29E313BE6E@garcon.linbit.com>

Author: phil
Date: 2005-02-14 21:08:40 +0100 (Mon, 14 Feb 2005)
New Revision: 1762

Modified:
   trunk/ROADMAP
   trunk/drbd/drbd_main.c
   trunk/drbd/drbd_receiver.c
Log:
Well, it seems that all code pathes of the item 9 code,
work fine. I need to check our OCFS2...


Modified: trunk/ROADMAP
===================================================================
--- trunk/ROADMAP	2005-02-14 16:01:02 UTC (rev 1761)
+++ trunk/ROADMAP	2005-02-14 20:08:40 UTC (rev 1762)
@@ -86,7 +86,9 @@
 
   Note: The actual key to the hash should be (sector & ~0x7).
         See item 9 for more details.
-  99% DONE
+  80% DONE ; There are more places where we case an block_id
+             to an req pointer, need to make sure that we
+             cover all of these places.
 
 7 Handle split brain situations; Support IO fencing; 
   
@@ -321,8 +323,7 @@
         to find IO operations starting in the same 4k block of
         data quickly. -> With two lookups the hash table we can
 	find any concurrent access.
-  70% DONE ; Implement discard info packets. Code an equivalent
-             hash table for EEs, to solve example case 5.
+  99% DONE
 
 10 Change Sync-groups to sync-after
   

Modified: trunk/drbd/drbd_main.c
===================================================================
--- trunk/drbd/drbd_main.c	2005-02-14 16:01:02 UTC (rev 1761)
+++ trunk/drbd/drbd_main.c	2005-02-14 20:08:40 UTC (rev 1762)
@@ -1343,10 +1343,6 @@
 				     atomic_add_return(1,&mdev->packet_seq) );
 
 		dump_packet(mdev,mdev->data.socket,0,(void*)&p, __FILE__, __LINE__);
-		// Instrumentation
-		set_current_state(TASK_INTERRUPTIBLE);
-		schedule_timeout(HZ);
-
 		set_bit(UNPLUG_REMOTE,&mdev->flags);
 		ok = sizeof(p) == drbd_send(mdev,mdev->data.socket,&p,sizeof(p),MSG_MORE);
 		if(ok) {
@@ -1389,7 +1385,7 @@
 
 	p.sector   = cpu_to_be64(drbd_ee_get_sector(e));
 	p.block_id = e->block_id;
-	p.seq_num  = cpu_to_be32(atomic_add_return(1,&mdev->packet_seq));
+	/* p.seq_num  = 0;    No sequence numbers here.. */
 
 	/* Only called by our kernel thread.
 	 * This one may be interupted by DRBD_SIG and/or DRBD_SIGKILL

Modified: trunk/drbd/drbd_receiver.c
===================================================================
--- trunk/drbd/drbd_receiver.c	2005-02-14 16:01:02 UTC (rev 1761)
+++ trunk/drbd/drbd_receiver.c	2005-02-14 20:08:40 UTC (rev 1762)
@@ -1044,7 +1044,7 @@
 	struct Tl_epoch_entry *e;
 	drbd_request_t * req;
 	Drbd_Data_Packet *p = (Drbd_Data_Packet*)h;
-	int header_size, data_size, packet_seq, discard;
+	int header_size, data_size, packet_seq, discard, rv;
 
 	// FIXME merge this code dups into some helper function
 	header_size = sizeof(*p) - sizeof(*h);
@@ -1068,10 +1068,8 @@
 		if (DRBD_ratelimit(5*HZ,5))
 			ERR("Can not write mirrored data block to local disk.\n");
 		drbd_send_ack(mdev,NegAck,e);
-		spin_lock_irq(&mdev->ee_lock);
-		drbd_put_ee(mdev,e);
-		spin_unlock_irq(&mdev->ee_lock);
-		return TRUE;
+		rv = TRUE;
+		goto out1;
 	}
 
 	e->block_id = p->block_id; // no meaning on this side, e* on partner
@@ -1085,13 +1083,15 @@
 	*/
 	if (mdev->conf.two_primaries) {
 		packet_seq = be32_to_cpu(p->seq_num);
-		if( packet_seq > peer_seq(mdev)+1 ) {
+		/* if( packet_seq > peer_seq(mdev)+1 ) {
 			WARN(" will wait till (packet_seq) %d <= %d\n",
 			     packet_seq,peer_seq(mdev)+1);
-		}
+			     } */
 		if( wait_event_interruptible(mdev->cstate_wait, 
-					     packet_seq <= peer_seq(mdev)+1) )
-			return FALSE;
+					     packet_seq <= peer_seq(mdev)+1)) {
+			rv = FALSE;
+			goto out2;
+		}
 
 		spin_lock(&mdev->peer_seq_lock); 
 		mdev->peer_seq = max(mdev->peer_seq, packet_seq);
@@ -1100,14 +1100,10 @@
 		spin_unlock(&mdev->peer_seq_lock);
 
 		if(discard) {
-			spin_lock_irq(&mdev->ee_lock);
-			drbd_put_ee(mdev,e);
-			spin_unlock_irq(&mdev->ee_lock);
-			atomic_inc(&mdev->epoch_size);
-			dec_local(mdev);
 			WARN("Concurrent write! [DISCARD BY LIST] sec=%lu\n",
 			     (unsigned long)sector);
-			return TRUE;
+			rv = TRUE;
+			goto out2;
 		}
 
 		req = req_have_write(mdev, e);
@@ -1120,34 +1116,27 @@
 				     "sec=%lu\n",(unsigned long)sector);
 				if( wait_event_interruptible(mdev->cstate_wait,
 					       !req_have_write(mdev,e))) {
-					spin_lock_irq(&mdev->ee_lock);
-					drbd_put_ee(mdev,e);
-					spin_unlock_irq(&mdev->ee_lock);
-					return FALSE;
+					rv = FALSE;
+					goto out2;
 				}
 			} else {
 				/* Conflicting write, no ACK by now*/
 				if (test_bit(UNIQUE,&mdev->flags)) {
-					spin_lock_irq(&mdev->ee_lock);
-					drbd_put_ee(mdev,e);
-					spin_unlock_irq(&mdev->ee_lock);
-					atomic_inc(&mdev->epoch_size);
-					dec_local(mdev);
 					WARN("Concurrent write! [DISCARD BY FLAG] sec=%lu\n",
 					     (unsigned long)sector);
-					return TRUE;
+					rv = TRUE;
+					goto out2;
 				} else {
 					/* write afterwards do not exp ACK */
 					WARN("Concurrent write! [W AFTERWARDS2] sec=%lu\n",
 					     (unsigned long)sector);
 					drbd_send_discard(mdev,req);
 					drbd_end_req(req, RQ_DRBD_SENT, 1, sector);
+					dec_ap_pending(mdev);
 					if( wait_event_interruptible(mdev->cstate_wait,
 								     !req_have_write(mdev,e))) {
-						spin_lock_irq(&mdev->ee_lock);
-						drbd_put_ee(mdev,e);
-						spin_unlock_irq(&mdev->ee_lock);
-						return FALSE;
+						rv = FALSE;
+						goto out2;
 					}
 				}
 			}
@@ -1170,14 +1159,19 @@
 		break;
 	}
 
-	// Instrumentation
-	set_current_state(TASK_INTERRUPTIBLE);
-	schedule_timeout(HZ);
-
 	drbd_generic_make_request(WRITE,&e->private_bio);
 
 	receive_data_tail(mdev,data_size);
 	return TRUE;
+
+ out2:
+	atomic_inc(&mdev->epoch_size);
+	dec_local(mdev);
+ out1:
+	spin_lock_irq(&mdev->ee_lock);
+	drbd_put_ee(mdev,e);
+	spin_unlock_irq(&mdev->ee_lock);
+	return rv;
 }
 
 STATIC int receive_DataRequest(drbd_dev *mdev,Drbd_Header *h)
@@ -2191,7 +2185,7 @@
 			drbd_set_in_sync(mdev,sector,blksize);
 			__set_bit(SYNC_STARTED,&mdev->flags);
 		} else {
-			req=(drbd_request_t*)(long)p->block_id;
+			req=(drbd_request_t*)(unsigned long)p->block_id;
 
 			if (unlikely(!tl_verify(mdev,req,sector))) {
 				ERR("Got a corrupt block_id/sector pair.\n");
@@ -2239,7 +2233,7 @@
 	drbd_request_t *req;
 	Drbd_BlockAck_Packet *p = (Drbd_BlockAck_Packet*)h;
 
-	req = (drbd_request_t *)(long)p->block_id;
+	req = (drbd_request_t *)(unsigned long)p->block_id;
 	D_ASSERT(req->w.cb == w_is_app_read);
 
 	spin_lock(&mdev->pr_lock);
@@ -2299,7 +2293,7 @@
 		return FALSE;
 	}
 
-	dn->block_id = (long)p->block_id;
+	dn->block_id = p->block_id;
 	dn->seq_num = be32_to_cpu(p->seq_num);
 
 	spin_lock(&mdev->peer_seq_lock);

From svn at svn.drbd.org  Thu Feb 17 15:14:13 2005
From: svn at svn.drbd.org (svn@svn.drbd.org)
Date: Thu Feb 17 15:14:21 2005
Subject: [DRBD-cvs] r1763 - branches/drbd-0.7
Message-ID: <20050217141413.9929B3BE6E@garcon.linbit.com>

Author: phil
Date: 2005-02-17 15:14:10 +0100 (Thu, 17 Feb 2005)
New Revision: 1763

Modified:
   branches/drbd-0.7/drbd.spec.in
Log:
To make building RPMs on RHAS4 work.


Modified: branches/drbd-0.7/drbd.spec.in
===================================================================
--- branches/drbd-0.7/drbd.spec.in	2005-02-14 20:08:40 UTC (rev 1762)
+++ branches/drbd-0.7/drbd.spec.in	2005-02-17 14:14:10 UTC (rev 1763)
@@ -76,8 +76,8 @@
 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}
-
+#       unset LOCALVERSION for building on RHEL AS 4
+make all doc PREFIX=%{buildroot}/ MANDIR=%{_mandir} KDIR=%{kdir} LOCALVERSION=""
 %install
 make install PREFIX=%{buildroot}/ MANDIR=%{_mandir}
 cd drbd

From svn at svn.drbd.org  Tue Feb 22 11:01:39 2005
From: svn at svn.drbd.org (svn@svn.drbd.org)
Date: Tue Feb 22 11:01:43 2005
Subject: [DRBD-cvs] r1764 - trunk
Message-ID: <20050222100139.0069B3BE6D@garcon.linbit.com>

Author: phil
Date: 2005-02-22 11:01:35 +0100 (Tue, 22 Feb 2005)
New Revision: 1764

Modified:
   trunk/ROADMAP
Log:
Thoughts about a new way of data-generation identifying...


Modified: trunk/ROADMAP
===================================================================
--- trunk/ROADMAP	2005-02-17 14:14:10 UTC (rev 1763)
+++ trunk/ROADMAP	2005-02-22 10:01:35 UTC (rev 1764)
@@ -332,7 +332,7 @@
   are not flexible enough to cover all real world scenarios.
 
   E.g. Two physical disks should be mirrored with DRBD. On one
-svn d       of the disks there is only a single partition, while the
+       of the disks there is only a single partition, while the
        other one is divided into many (e.g. 4 smaller) partitions.
        One would want to sync the big one in parallel to the 
        4 small ones. While the resync process of the 4 small
@@ -367,6 +367,8 @@
   If the peer's UUID is different to what we expect we know that 
   we have to do a full sync....
   99% DONE
+  -> Will be go out again, and become replaced by UUID for data
+     generations. See item 16
 
 14 Sanitize ioctls to inlcude a standard device information struct
   at the beginning, including the expected API version.
@@ -379,6 +381,54 @@
   bitmap to account for more then 4k e.g. 64k
   0% DONE
 
+[ Item 16 is still unfinished, as described here, the algorithm has
+  some loose ends... ]
+16 Displace the current generation-counters with a generation-UUID concept.
+  The current generation counters have various weaknesses:
+   * In a split braine'd cluster the appliance of the same events
+     to both cluster nodes could lead to equal generation-counters
+     on both nodes, while the data is not in sync for sure.
+   * They are completely unsuitable if a 3rd node is used for 
+     e.g. weekly snapshots.
+
+  We associate each data generation with an unique UUID (=64 bit random
+  number). A new data generation is created if a node becomes primary
+  and the new auth-enum (see below) is different from the current
+  auth enum.
+
+  In the meta-data we store a few generations-UUIDs: 
+   * current
+   * bitmap
+   * history[4]
+
+  In addition there is an enum describing the authorisation of the
+  current gen-uuid: Human, Timout, Connected, Degraded
+  As well as the currently known flags: 
+     Consistent, WasUpToDate, LastState, ConnectedInd, WantFullSync
+
+  The difference here is that the former flags are determined
+  when the gen-uuid is created, while the latter are modified
+  as the state changes.
+
+  When the cluster is in Connected state, then the bitmpat gen-uuid
+  is set to 0 (Since the Bitmap is empty). When we create a new current
+  gen-uuid while we are disconencted the (old) current gets backuped
+  to the bitmap gen-uuid. (This allowes us to identify the base of
+  of the bitmap later)
+
+  Algorithm on connect:
+   If the current gen-uuids are equal -> No sync.
+   else -> Need sync.
+
+   The node which has bitmap gen-uuid == peer's current gen-uuid is
+   sync source.
+
+   The node with the higher value in the authorisation enum is sync source.
+
+   
+
+
+
 plus-banches:
 ----------------------
 

From svn at svn.drbd.org  Tue Feb 22 11:07:16 2005
From: svn at svn.drbd.org (svn@svn.drbd.org)
Date: Tue Feb 22 11:07:23 2005
Subject: [DRBD-cvs] r1765 - in trunk: drbd user
Message-ID: <20050222100716.BFCEA3BE6D@garcon.linbit.com>

Author: phil
Date: 2005-02-22 11:07:13 +0100 (Tue, 22 Feb 2005)
New Revision: 1765

Modified:
   trunk/drbd/drbd_main.c
   trunk/user/drbdmeta.c
Log:
Some fixes from LMB to make it work on i386 with 64 bit sector_t
and other misc stuff.


Modified: trunk/drbd/drbd_main.c
===================================================================
--- trunk/drbd/drbd_main.c	2005-02-22 10:01:35 UTC (rev 1764)
+++ trunk/drbd/drbd_main.c	2005-02-22 10:07:13 UTC (rev 1765)
@@ -164,7 +164,7 @@
 
 STATIC unsigned int tl_hash_fn(drbd_dev *mdev, sector_t sector)
 {
-	return (sector>>HT_SHIFT) % mdev->tl_hash_s;
+	return (unsigned int)(sector>>HT_SHIFT) % mdev->tl_hash_s;
 }
 
 
@@ -367,7 +367,7 @@
 
 STATIC unsigned int ee_hash_fn(drbd_dev *mdev, sector_t sector)
 {
-	return (sector>>HT_SHIFT) % mdev->ee_hash_s;
+	return (unsigned int)(sector>>HT_SHIFT) % mdev->ee_hash_s;
 }
 
 STATIC int overlaps(sector_t s1, int l1, sector_t s2, int l2)

Modified: trunk/user/drbdmeta.c
===================================================================
--- trunk/user/drbdmeta.c	2005-02-22 10:01:35 UTC (rev 1764)
+++ trunk/user/drbdmeta.c	2005-02-22 10:07:13 UTC (rev 1765)
@@ -40,7 +40,7 @@
 #include <unistd.h>
 #include <fcntl.h>
 
-#include <linux/fs.h>		/* for BLKGETSIZE64 */
+#include <sys/mount.h>         /* for BLKGETSIZE64 */
 #include <linux/drbd.h>		/* only use DRBD_MAGIC from here! */
 
 #include "drbdtool_common.h"

