- 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: