Subject: Re: kern/33112
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: Hubert Feyrer <hubert@feyrer.de>
List: netbsd-bugs
Date: 03/06/2007 00:40:02
The following reply was made to PR kern/33112; it has been noted by GNATS.
From: Hubert Feyrer <hubert@feyrer.de>
To: gnats-bugs@NetBSD.org
Cc:
Subject: Re: kern/33112
Date: Tue, 6 Mar 2007 00:39:32 +0000 (UTC)
Just so this isn't lost... there's more meat in that thread,
and I think Cliff's got a point (for as much as *I* can judge,
which isn't much for kernal stuff :). Still, it's a quick fix.
- Hubert
---------- Forwarded message ----------
Date: Sun, 4 Mar 2007 14:33:14 -0800
From: Cliff Wright <cliff@snipe444.org>
To: tech-kern@netbsd.org
Subject: Re: pseudo device vnd compress problem
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)