- Clarify the definitions of b_bufsize, b_bcount, and b_resid.
authorMatthew Dillon <dillon@dragonflybsd.org>
Wed, 3 May 2006 20:44:49 +0000 (20:44 +0000)
committerMatthew Dillon <dillon@dragonflybsd.org>
Wed, 3 May 2006 20:44:49 +0000 (20:44 +0000)
commit9a71d53f1732dd51ac3962df765fad39561f035f
tree2820e90681448c62ad46dcaa9d04c4db632ef74d
parent1f97d0731bf0d7340cb4c3444f67ede2ff93b5fe
- Clarify the definitions of b_bufsize, b_bcount, and b_resid.
- Remove unnecessary assignments based on the clarified fields.
- Add additional checks for premature EOF.

b_bufsize is only used by buffer management entities such as getblk() and
other vnode-backed buffer handling procedures.  b_bufsize is not required
for calls to vn_strategy() or dev_dstrategy().  A number of other subsystems
use it to track the original request size.

b_bcount is the I/O request size, but b_bcount() is allowed to be truncated
by the device chain if the request encompasses EOF (such as on a raw disk
device).  A caller which needs to record the original buffer size verses
the EOF-truncated buffer can compare b_bcount after the I/O against a
recorded copy of the original request size.  This copy can be recorded in
b_bufsize for unmanaged buffers (malloced or getpbuf()'d buffers).

b_resid is always relative to b_bcount, not b_bufsize.  A successful read
that is truncated to the device EOF will thus have a b_resid of 0 and a
truncated b_bcount.
14 files changed:
sys/dev/disk/ccd/ccd.c
sys/dev/disk/vn/vn.c
sys/dev/raid/vinum/vinuminterrupt.c
sys/dev/raid/vinum/vinumrequest.c
sys/kern/kern_physio.c
sys/kern/subr_disk.c
sys/kern/subr_diskslice.c
sys/kern/vfs_bio.c
sys/kern/vfs_cluster.c
sys/sys/buf.h
sys/vfs/specfs/spec_vnops.c
sys/vm/swap_pager.c
sys/vm/vm_pager.c
sys/vm/vnode_pager.c