Subject: Re: pseudo device vnd compress problem
To: None <tech-kern@netbsd.org>
From: Cliff Wright <cliff@snipe444.org>
List: tech-kern
Date: 03/04/2007 14:33:14
I may have been to subtle in my previous message.
The bound_check_with_label subroutine is serverly broken.
If it is fixed, then how it is fixed will determine the change
required for vnd.
I say severly broken because their is a break, on top of a break, on
top of a break. That is three breaks.
  Break one: because b_cylinder, and b_resid are one and the same.
The work the routine was commented as being its primary function,
end of patition adjustment, is wiped out, as at the end of
the routine b_cylinder is set, splat, doing a wipe out of the adjustment
to b_resid.
  Break two: When doing the adjustment, a block count is created from a
byte count, a block calculation is done, then the results are compared to
the original byte count. i.e. apples to oranges, not blocks to blocks,
but blocks to bytes.
  Break three: since if all the other drivers that used this routine
would have broken as vnd compress did, I must assume they always ignored
the results of this routine. So if end of patition adjustment is
really required then all these other drivers have been broken for a
long time.

So I can put a quick hack in vnd to fix the compression (and have done
so, and it works), but this severe broken routine (bounds_check_with_label
in kern/subr_disk.c) needs to be looked at.

Here is a quick hack for vnd against cvs 1.162

--- dev/vnd.c.orig	2007-02-26 10:56:07.000000000 -0800
+++ dev/vnd.c	2007-03-04 14:19:20.000000000 -0800
@@ -491,6 +491,7 @@
 		    bp, vnd->sc_flags & (VNF_WLABEL|VNF_LABELLING)) <= 0)
 			goto done;
 	}
+	bp->b_resid = bp->b_bcount;
 
 	/* If it's a nil transfer, wake up the top half now. */
 	if (bp->b_bcount == 0)