Subject: pseudo device vnd compress problem
To: None <tech-kern@netbsd.org>
From: Cliff Wright <cliff@snipe444.org>
List: tech-kern
Date: 03/04/2007 04:32:06
I have found the problem of the pseudo device vnd not working with
compression on partition a.
A buffer object is used that contains the desired number of bytes to
be transfered (b_bcount), and the bytes left (residual) to be transfered
(b_resid). Near the begining of the transfer the residual is set to
the total transfer count, then a routine bounds_check_with_label
(in kern/subr_disk.c) is called, that can adjust the residual count
if the end of the partition is seen. Although this adjustment looks
questionable as their appears to be a check of number of blocks against
number of bytes. At first their appears to be no other change on b_resid
by this routine. But looking at sys/buf.h it can be seen that b_cylinder
is by #define the same as b_resid, and is thus set to a cylinder number
by this routine destroying b_resid.
  So I can fix vnd by reseting b_resid to b_bcount. However the
residual adjustment made by bounds_check_with_label is now superfluous,
and should be removed. But should I now add this check in the vnd code?
After being carefull to use b_resid instead of b_bcount, it looks like
no other driver was doing this, so the end of partition check was not
done any way, and even if it was used, it may have had a bug.
	Cliff Wright