Native Linux AIO in Samba4

Andrew Tridgell tridge at au1.ibm.com
Fri Jan 12 06:11:54 GMT 2007


I've been working a bit on supporting the native Linux AIO API in
Samba4. The code is now committed, and is working well.

The native Linux API is somewhat different to the posix AIO API. The
native API is based on libaio.h, and uses io_submit() and
io_getevents(). The posix API uses calls like aio_read().

The main advantages of the native Linux API are that:

 - on Linux it doesn't spawn off threads to do the work. This makes it
   much more efficient

 - it can be hooked into a unified event system with epoll, allowing
   our main event loop to sanely wait for both aio disk events and
   network events. No signals (yipee!).

Over the last couple of weeks I've been working with Suparna
Bhattacharya and Jeff Moyer on ironing out some of the glitches with
the kernel side of all this. There were some timing bugs that caused
it to initially be very slow, plus a crash bug that has been fixed. It
is now working well.

If you want to experiment with it you'll need:

 1) a very recent linux kernel. I'm using 2.6.20-rc4.

 2) AIO patches from Suparna. I've collected patches for a 2.6.20-rc4
    kernel in http://samba.org/~tridge/aio-2620-rc4.patch. Also watch
    http://www.kernel.org/pub/linux/kernel/people/suparna/aio/ for new
    patch sets (I hope these will appear in standard kernels in due
    course).

 3) a recent Samba4 svn. At least rev 20698.

 4) in smb.conf you need to set the options
	event:backend = aio
	posix:aio = yes
    the first option must be global. The 2nd option can be per-share
    or global.

Performance seems to be good. At the moment it only does AIO for read
and write operations, but I am looking at the possibility of using
some clone() tricks to make some other operations async (maybe open,
close, fsync). I'd also like to somehow do async sendfile if we can
find a way to do it.

For most people AIO won't matter much, but for some applications
(eg. HFS systems) it will help a lot. Many thanks to Suparna and the
other kernel developers for helping us get this far!

Regarding the epoll/aio kernel code that this relies on, there is some
discussion of using a new events system in the kernel called kevents
instead. The kevents API is certainly much cleaner (the aio/epoll
integration is a pretty nasty hack in comparison!), but I don't know
which will end up being the standard. Maybe we'll end up with both,
in which case we'll support both in Samba4.

Cheers, Tridge


More information about the samba-technical mailing list