Re: Sub-optimal libc's read-ahead buffering behaviour

From: Andrey Chernov <ache_at_FreeBSD.ORG>
Date: Fri, 5 Aug 2005 13:38:43 +0400
On Fri, Aug 05, 2005 at 05:38:48AM +1000, Peter Jeremy wrote:
> Consider buffered stdio to a disk device.  The underlying device
> requires I/O to be in multiples of 512 bytes with an offset at
> multiples of 512 bytes.  IMHO, these alignment requirements should
> be hidden from the user - I should be able to write code like:
> 	c = getc(disk);
> 	fseek(disk, 3, SEEK_CUR);
> 	w = getw(disk);
> 	fseek(disk, 1, SEEK_CUR);
> 	c1 = getc(disk);
> 	fseek(disk, c1, SEEK_CUR);
> to work my way through data on the disk.  Currently, I can't do that
> because the fseek() is transparent and the underlying lseek() will
> fail.  Instead, I need to write code like:

If the underlying lseek() fails, it sounds like _driver_ problem. Ideally 
it should hide all internal I/O granulation from the user and allow seek 
to any position. If the position is in the middle, the driver can transfer 
only needed part of block. So, don't blame _stdio_ for not nice driver 
behaviour.

Looking more practical, aligned seeks and blocked read are enough in most 
situations, so there is no urgent demand to complicate drivers to do nice 
things.

-- 
http://ache.pp.ru/
Received on Fri Aug 05 2005 - 07:38:52 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:40 UTC