On Thu, 4 May 2000, Graham; Stephen wrote:

> I understand the dangers involved, but have written a fairly good disk manager
> that handles threadsafe multiple access to the database, ensuring that no
> two blocks are being accessed at the same time (threads need to obtain leases
> on the blocks before accessing them, and the lease handler is thread-safe).
> 
> The two options I can see are either using fread and fwrite to handle to IO
> 
> or to create my own stream type using the cookie stuff.
> 

I'm not sure how deep you want to go into this project but there is
another (fairly advanced) option with raw i/o.  In a nutshell, this
bypasses the kernel buffer cache and gives you direct access to disk.  It
is often used (and even required) by high-end database products.

Raw i/o support for Linux is evolving, but is included with some recent
redhat distributions (check for a raw(8) man page and 'raw' utility), and
current sources are available from ftp://ftp.linux.org.uk/pub/linux/sct/fs/raw-io/

At this stage, raw i/o is only supported for entire partitions, although
raw access on a per-file basis is currently being developed by Stephen 
Tweedie (this would use an O_DIRECT flag to open()).

A quick way to get started is to use a floppy disk as a raw device, which
you would set up with something like:

# raw /dev/raw0 /dev/fd0

This "binds" the first floppy disk to the first raw device.  You can then
open(), seek(), read(), write() etc. /dev/raw0 as a character device, and
effectively have complete control over how and when data is written and
read from the disk.

The only catch is that you must use page-aligned memory to access the
device.  There's some code which shows you how to do this at
http://www.intercode.com.au/jmorris/rawutil/ (and I think the 'dd' 
provided with redhat 6.2 also now uses aligned memory).


- James
--
James Morris
<[EMAIL PROTECTED]>


--
SLUG - Sydney Linux Users Group Mailing List - http://www.slug.org.au
To unsubscribe send email to [EMAIL PROTECTED] with
unsubscribe in the text

Reply via email to