Subject: Re: kern/32193: vop_strategy gets broken struct buf's passed by genfs/bread, possible memory leakage
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: Jason Thorpe <thorpej@shagadelic.org>
List: netbsd-bugs
Date: 11/30/2005 18:36:02
The following reply was made to PR kern/32193; it has been noted by GNATS.

From: Jason Thorpe <thorpej@shagadelic.org>
To: Reinoud Zandijk <reinoud@netbsd.org>
Cc: gnats-bugs@netbsd.org, kern-bug-people@netbsd.org,
	gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: kern/32193: vop_strategy gets broken struct buf's passed by genfs/bread, possible memory leakage
Date: Wed, 30 Nov 2005 10:35:02 -0800

 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  
 command.
 
 - 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