[DRBD-cvs] drbd by phil; Whow, this one was really wicked. I spen...

drbd-user@lists.linbit.com drbd-user@lists.linbit.com
Sun, 7 Mar 2004 18:57:30 +0100 (CET)


DRBD CVS committal

Author  : phil
Module  : drbd

Dir     : drbd/drbd


Modified Files:
      Tag: rel-0_7-branch
	drbd_actlog.c drbd_dsender.c lru_cache.c 


Log Message:
Whow, this one was really wicked. I spent hours looking for the damned
bug in the activity log. But the root of the problem was that at
IO completion the bi_sector member of a bio gets increased.
Nice! Grumbl.
Now in drbd_dio_end() there is this call to drbd_al_complete_io(),
and since the sector gets converted to a extent number there, it
is most of the time correct, only sometimes not....

Well and while reading over and over the lru code I came up
with the idea that it might be a good idea not to return the
changing element as a result of lc_find().

===================================================================
RCS file: /var/lib/cvs/drbd/drbd/drbd/Attic/drbd_actlog.c,v
retrieving revision 1.1.2.75
retrieving revision 1.1.2.76
diff -u -3 -r1.1.2.75 -r1.1.2.76
--- drbd_actlog.c	7 Mar 2004 14:34:49 -0000	1.1.2.75
+++ drbd_actlog.c	7 Mar 2004 17:57:25 -0000	1.1.2.76
@@ -131,12 +131,14 @@
 	al_flags = mdev->act_log->flags;
 	spin_unlock_irq(&mdev->al_lock);
 
+	/*
 	if (!al_ext) {
 		if (al_flags & LC_STARVING)
 			WARN("Have to wait for LRU element (AL too small?)\n");
-		//if (al_flags & LC_DIRTY) // too noisy
-		//WARN("Ongoing AL update (AL device too slow?)\n");
+		if (al_flags & LC_DIRTY)
+			WARN("Ongoing AL update (AL device too slow?)\n");
 	}
+	*/
 
 	return al_ext;
 }
@@ -180,7 +182,7 @@
 
 	if(!extent) {
 		spin_unlock_irqrestore(&mdev->al_lock,flags);
-		ERR("drbd_al_complete_io() called on inactive extent\n");
+		ERR("al_complete_io() called on inactive extent %u\n",enr);
 		return;
 	}
 
===================================================================
RCS file: /var/lib/cvs/drbd/drbd/drbd/Attic/drbd_dsender.c,v
retrieving revision 1.1.2.81
retrieving revision 1.1.2.82
diff -u -3 -r1.1.2.81 -r1.1.2.82
--- drbd_dsender.c	7 Mar 2004 11:49:23 -0000	1.1.2.81
+++ drbd_dsender.c	7 Mar 2004 17:57:25 -0000	1.1.2.82
@@ -287,6 +287,7 @@
 {
 	struct Drbd_Conf* mdev;
 	drbd_request_t *req;
+	sector_t rsector;
 
 	// see above
 	if (bio->bi_size)
@@ -299,8 +300,10 @@
 	PARANOIA_BUG_ON(!VALID_POINTER(req));
 
 	drbd_chk_io_error(mdev,error);
-	drbd_end_req(req, RQ_DRBD_LOCAL, (error == 0), drbd_req_get_sector(req));
-	drbd_al_complete_io(mdev,drbd_req_get_sector(req));
+	rsector = drbd_req_get_sector(req); 
+        // the bi_sector of the bio gets modified somewhere in drbd_end_req()!
+	drbd_end_req(req, RQ_DRBD_LOCAL, (error == 0), rsector);
+	drbd_al_complete_io(mdev,rsector);
 	dec_local(mdev);
 	return 0;
 }
===================================================================
RCS file: /var/lib/cvs/drbd/drbd/drbd/Attic/lru_cache.c,v
retrieving revision 1.1.2.22
retrieving revision 1.1.2.23
diff -u -3 -r1.1.2.22 -r1.1.2.23
--- lru_cache.c	17 Feb 2004 09:10:35 -0000	1.1.2.22
+++ lru_cache.c	7 Mar 2004 17:57:25 -0000	1.1.2.23
@@ -107,7 +107,10 @@
 	BUG_ON(!lc);
 	BUG_ON(!lc->nr_elements);
 	hlist_for_each_entry(e, n, lc->slot + lc_hash_fn(lc, enr), colision) {
-		if (e->lc_number == enr) return e;
+		if (e->lc_number == enr) {
+			if( likely(e != lc->changing_element) ) return e;
+			return NULL;
+		}
 	}
 	return NULL;
 }