On Tue, Feb 21, 2012 at 12:55:36PM -0500, Ted Unangst wrote:
> On Tue, Feb 21, 2012, Kenneth R Westerback wrote:
> > On Tue, Feb 21, 2012 at 03:15:29PM +0200, Alexey Vatchenko wrote:
> >> Reading 512 bytes from raw device with 2048 sector size fails. If i read
> >> 512 bytes from block device the problem is not reproduced.
> 
> > This is intentional. You cannot read from a raw device fewer bytes
> > at a time than the minimum the device provides per i/o. On block
> > devices the buffer cache does the correct size i/o and extracts
> > just the number of bytes you requested.
> 
> That's backwards from what I thought.  The raw device should let you
> read byte by byte, the block device only lets you read block by block,
> as it were.

Block/Sector based devices can only provide entire blocks/sectors,
at block/sector addresses. The buffer cache and standard i/o routines
provide the abstraction that you can start and stop at any byte.

Doing I/O to raw devices means you are taking full responsibility for
paying attention to the boundaries and sizes of the i/o.

This is how OpenBSD works. Whether that is 'correct' or not, I don't
know. :-)

Hence the mad dancing over the last few years to make more devices with
non-DEV_BSIZE sectors work with various bits of software that do 'raw'
i/o and have always assumed DEV_BSIZE is and always will be 512 bytes.

.... Ken

Reply via email to