Re: sendfile and aio_write: a match made in heaven?

From: Ananth Ananthanarayanan (ananth@sgi.com)
Date: Wed Jan 12 2000 - 18:24:43 EST


DanKegel@aol.com wrote:
>
> khttpd is a fine way to get fast static file http performance, but one
> shouldn't need to write code in the kernel to handle such a simple task.
>
> sendfile() plus the new sigio stuff gets user programs most of the way towards
> doing what khttpd does, but when sendfile() has to read from disk,
> it blocks; this kills server performance. You can put the sendfile() in a
> worker thread, but it'd be nice if there was another way to deal with this.
>
> The aio_write interface could be extended to handle this
> by adding two new fields to struct aiocb:
> int aio_filedes2;
> off_t aio_offset2;
> These would only be checked if the aio_buf field were NULL,
> in which case aio_write would cause bytes to be transferred
> from aio_filedes2 to aio_filedes1.
>
> This could potentially fit in very, very nicely with the new sigio stuff;
> it would be AFAICS a drop-in replacement for synchronous sendfile()
> in a sigio-style server.
>
> Comments?
>
> - Dan
> (usually dank@alumni.caltech.edu)

The idea of extending aio_*() to include sendfile() is good,
but I'm not sure you'd want to do that with aio_write(), or
for that matter extend aiocb with extra fields. For example,
if aio_buf were NULL in an erroneous program, then with
the proposed modifications it might do wierd things, esp.
if aio_filedes2 wasn't used in that program and happend to
contain a valid file descriptor; without the proposed
modification, the program would have generated a EFAULT.

Instead, may I suggest aio_sendfile(aiocb, int outfd, int outoffset),
where aiocb defines the "input" & the outfd/offset define the "output".
We need an aiocb to support aio_error(), aio_return(),
aio_suspend(), etc ... to provide a handle to the request in progress.

ananth.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Jan 15 2000 - 21:00:21 EST