This is an example about how to add eventfd support to the current KAIO code,
in order to enable KAIO to post readiness events to a pollable fd
(hence compatible with POSIX select/poll). The KAIO code simply signals
the eventfd fd when events are ready, and this triggers a POLLIN in the fd.
This patch uses a reserved for future use member of the struct iocb to pass
an eventfd file descriptor, that KAIO will use to post events every time
a request completes. At that point, an aio_getevents() will return the
completed result to a struct io_event.
I made a quick test program to verify the patch, and it runs fine here:
Index: linux-2.6.21-rc5.fds/include/linux/aio_abi.h
===================================================================
--- linux-2.6.21-rc5.fds.orig/include/linux/aio_abi.h 2007-03-31 12:45:30.000000000 -0700
+++ linux-2.6.21-rc5.fds/include/linux/aio_abi.h 2007-03-31 12:46:31.000000000 -0700
@@ -84,7 +84,11 @@
/* extra parameters */
__u64 aio_reserved2; /* TODO: use this for a (struct sigevent *) */
- __u64 aio_reserved3;
+ __u32 aio_reserved3;
+ /*
+ * If different from 0, this is an eventfd to deliver AIO results to
+ */
+ __u32 aio_resfd;
}; /* 64 bytes */