summaryrefslogtreecommitdiffstats
path: root/include/linux/aio.h
diff options
context:
space:
mode:
authorDavide Libenzi <davidel@xmailserver.org>2007-05-10 22:23:21 -0700
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-11 08:29:37 -0700
commit9c3060bedd84144653a2ad7bea32389f65598d40 (patch)
tree80336eb24be8458cda1f35ee752f05bc7c329fbb /include/linux/aio.h
parentfdb902b1225e1668315f38e96d2f439452c03a15 (diff)
downloadlinux-9c3060bedd84144653a2ad7bea32389f65598d40.tar.gz
linux-9c3060bedd84144653a2ad7bea32389f65598d40.tar.bz2
linux-9c3060bedd84144653a2ad7bea32389f65598d40.zip
signal/timer/event: KAIO eventfd support example
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: http://www.xmailserver.org/eventfd-aio-test.c The test program uses poll(2), but it'd, of course, work with select and epoll too. This can allow to schedule both block I/O and other poll-able devices requests, and wait for results using select/poll/epoll. In a typical scenario, an application would submit KAIO request using aio_submit(), and will also use epoll_ctl() on the whole other class of devices (that with the addition of signals, timers and user events, now it's pretty much complete), and then would: epoll_wait(...); for_each_event { if (curr_event_is_kaiofd) { aio_getevents(); dispatch_aio_events(); } else { dispatch_epoll_event(); } } Signed-off-by: Davide Libenzi <davidel@xmailserver.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/aio.h')
-rw-r--r--include/linux/aio.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/include/linux/aio.h b/include/linux/aio.h
index 43dc2ebfaa0e..b903fc02bdb7 100644
--- a/include/linux/aio.h
+++ b/include/linux/aio.h
@@ -119,6 +119,12 @@ struct kiocb {
struct list_head ki_list; /* the aio core uses this
* for cancellation */
+
+ /*
+ * If the aio_resfd field of the userspace iocb is not zero,
+ * this is the underlying file* to deliver event to.
+ */
+ struct file *ki_eventfd;
};
#define is_sync_kiocb(iocb) ((iocb)->ki_key == KIOCB_SYNC_KEY)