Subject: Re: kern/32193: vop_strategy gets broken struct buf's passed by genfs/bread, possible memory leakage
To: Reinoud Zandijk <>
From: Jason Thorpe <>
List: netbsd-bugs
Date: 11/30/2005 10:35:02
On Nov 30, 2005, at 10:21 AM, Reinoud Zandijk wrote:

> That bp->b_bufsize indicates the length of the datablock pointed to by
> bp->b_data ?

That's not what b_bufsize is for.  b_bcount indicates the length of  
the data pointed to by b_data.

b_bufsize is really almost historical, at this point... it indicates  
the total size of the data area allocated to the buf, not all of  
which contains valid data.  I'm not even clear on the semantics of  
b_bufsize in the New World Order of the dynamically allocated bio cache.

> Consistency. If one wants to be consistent, b_resid ought to allways
> indicate the number of bytes to be transfered independent of the  
> place one
> finds the buf used and not for conventions sake suddenly been taken  
> over by
> b_bcount.

Suddenly?  As long as I can remember (no jokes, please :-):

- b_bcount has indicated the amount that is to be transferred.   
Device drivers read this field to determine how to set up the device  

- b_resid has indicated the amount of data NOT transferred for one  
reason or another.  Device drivers write this field after the device  
command has completed.

-- thorpej