Block devices generally truncate the size of I/O requests which go past EOF.
authorMatthew Dillon <dillon@dragonflybsd.org>
Thu, 4 May 2006 18:32:23 +0000 (18:32 +0000)
committerMatthew Dillon <dillon@dragonflybsd.org>
Thu, 4 May 2006 18:32:23 +0000 (18:32 +0000)
commit4414f2c9899662f87337780133eb0cd819fcc546
tree69ff6a5bac128a704640d7d9403362a6a3e118b7
parentc8bcf9784ba80d10bf73d76e22dea799aaa0b741
Block devices generally truncate the size of I/O requests which go past EOF.
This is exactly what we want when manually reading or writing a block device
such as /dev/ad0s1a, but is not desired when a VFS issues I/O ops on
filesystem buffers.  In such cases, any EOF condition must be considered an
error.

Implement a new filesystem buffer flag B_BNOCLIP, which getblk() and friends
automatically set.  If set, block devices are guarenteed to return an error
if the I/O request is at EOF or would otherwise have to be clipped to EOF.
Block devices further guarentee that b_bcount will not be modified when this
flag is set.

Adjust all block device EOF checks to use the new flag, and clean up the code
while I'm there.  Also, set b_resid in a couple of degenerate cases where
it was not being set.
sys/dev/disk/ccd/ccd.c
sys/dev/disk/vn/vn.c
sys/i386/i386/machdep.c
sys/kern/subr_diskslice.c
sys/kern/vfs_bio.c
sys/kern/vfs_cluster.c
sys/platform/pc32/i386/machdep.c
sys/sys/buf.h
sys/vfs/mfs/mfs_vfsops.c