[linux-audio-dev] O_DIRECT architecture (was Re: info point on linux hdr)

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: [linux-audio-dev] O_DIRECT architecture (was Re: info point on linux hdr)
From: Stephen C. Tweedie (sct_AT_redhat.com)
Date: Tue Apr 18 2000 - 13:14:26 EEST


Hi,

On Mon, Apr 17, 2000 at 05:58:48PM -0500, Steve Lord wrote:
>
> O_DIRECT on Linux XFS is still a work in progress, we only have
> direct reads so far. A very basic implementation was made available
> this weekend.

Care to elaborate on how you are doing O_DIRECT?

It's something I've been thinking about in the general case. Basically
what I want to do is this:

Augment the inode operations with a new operation, "rw_kiovec" which
performs reads and writes on vectors of kiobufs.

Provide a generic_rw_kiovec() function which uses the existing page-
oriented IO vectors to set up page mappings much as generic_file_{read,
write} do, but honouring the following flags in the file descriptor:

 * O_ALIAS
   
   Allows the write function to install the page in the kiobuf
   into the page cache if the data is correctly aligned and there is
   not already a page in the page cache.

   For read, the meaning is different: it allows existing pages in
   the page cache to be installed into the kiobuf.

 * O_UNCACHE

   If the IO created a new page in the page cache, then attempt to
   unlink the page after the IO completes.

 * O_SYNC

   Usual meaning: wait for synchronous write IO completion.

O_DIRECT becomes no more than a combination of these options.

Furthermore, by implementing this mechanism with kiobufs, we can go
one step further and perform things like Larry's splice operations by
performing reads and writes in kiobufs. Using O_ALIAS kiobuf reads and
writes gives us copies between regular files entirely in kernel space
with the minimum possible memory copies. sendfile() between regular
files can be optimised to use this mechanism. The data never has to
hit user space.

As an example of the flexibility of the interface, you can perform
an O_ALIAS, O_UNCACHE sendfile to copy one file to another, with full
readahead still being performed on the input file but with no memory
copies at all. You can also choose not to have O_UNCACHE and O_SYNC
on the writes, in which case you have both readahead and writebehind
with zero copy.

This is all fairly easy to implement (at least for ext2), and gives
us much more than just O_DIRECT for no extra work.

--Stephen


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : Tue Apr 18 2000 - 13:40:14 EEST