2006-10-04 04:01:26 +07:00
|
|
|
/* include/linux/aio_abi.h
|
2005-04-17 05:20:36 +07:00
|
|
|
*
|
|
|
|
* Copyright 2000,2001,2002 Red Hat.
|
|
|
|
*
|
|
|
|
* Written by Benjamin LaHaise <bcrl@kvack.org>
|
|
|
|
*
|
|
|
|
* Distribute under the terms of the GPLv2 (see ../../COPYING) or under
|
|
|
|
* the following terms.
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software and its
|
|
|
|
* documentation is hereby granted, provided that the above copyright
|
|
|
|
* notice appears in all copies. This software is provided without any
|
|
|
|
* warranty, express or implied. Red Hat makes no representations about
|
|
|
|
* the suitability of this software for any purpose.
|
|
|
|
*
|
|
|
|
* IN NO EVENT SHALL RED HAT BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
|
|
|
|
* SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF RED HAT HAS BEEN ADVISED
|
|
|
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* RED HAT DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND
|
|
|
|
* RED HAT HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
|
|
|
|
* ENHANCEMENTS, OR MODIFICATIONS.
|
|
|
|
*/
|
|
|
|
#ifndef __LINUX__AIO_ABI_H
|
|
|
|
#define __LINUX__AIO_ABI_H
|
|
|
|
|
2009-01-30 21:50:10 +07:00
|
|
|
#include <linux/types.h>
|
2017-07-06 23:58:37 +07:00
|
|
|
#include <linux/fs.h>
|
aio: implement io_pgetevents
This is the io_getevents equivalent of ppoll/pselect and allows to
properly mix signals and aio completions (especially with IOCB_CMD_POLL)
and atomically executes the following sequence:
sigset_t origmask;
pthread_sigmask(SIG_SETMASK, &sigmask, &origmask);
ret = io_getevents(ctx, min_nr, nr, events, timeout);
pthread_sigmask(SIG_SETMASK, &origmask, NULL);
Note that unlike many other signal related calls we do not pass a sigmask
size, as that would get us to 7 arguments, which aren't easily supported
by the syscall infrastructure. It seems a lot less painful to just add a
new syscall variant in the unlikely case we're going to increase the
sigset size.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
2018-05-03 00:51:00 +07:00
|
|
|
#include <linux/signal.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
#include <asm/byteorder.h>
|
|
|
|
|
2012-02-15 03:58:56 +07:00
|
|
|
typedef __kernel_ulong_t aio_context_t;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
enum {
|
|
|
|
IOCB_CMD_PREAD = 0,
|
|
|
|
IOCB_CMD_PWRITE = 1,
|
|
|
|
IOCB_CMD_FSYNC = 2,
|
|
|
|
IOCB_CMD_FDSYNC = 3,
|
2018-03-20 22:34:36 +07:00
|
|
|
/* 4 was the experimental IOCB_CMD_PREADX */
|
|
|
|
IOCB_CMD_POLL = 5,
|
2005-04-17 05:20:36 +07:00
|
|
|
IOCB_CMD_NOOP = 6,
|
2006-10-01 13:28:49 +07:00
|
|
|
IOCB_CMD_PREADV = 7,
|
|
|
|
IOCB_CMD_PWRITEV = 8,
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|
|
|
|
|
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>
2007-05-11 12:23:21 +07:00
|
|
|
/*
|
|
|
|
* Valid flags for the "aio_flags" member of the "struct iocb".
|
|
|
|
*
|
|
|
|
* IOCB_FLAG_RESFD - Set if the "aio_resfd" member of the "struct iocb"
|
|
|
|
* is valid.
|
|
|
|
*/
|
|
|
|
#define IOCB_FLAG_RESFD (1 << 0)
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
/* read() from /dev/aio returns these structures. */
|
|
|
|
struct io_event {
|
|
|
|
__u64 data; /* the data field from the iocb */
|
|
|
|
__u64 obj; /* what iocb this event came from */
|
|
|
|
__s64 res; /* result code for this event */
|
|
|
|
__s64 res2; /* secondary result */
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* we always use a 64bit off_t when communicating
|
|
|
|
* with userland. its up to libraries to do the
|
|
|
|
* proper padding and aio_error abstraction
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct iocb {
|
|
|
|
/* these are internal to the kernel/libc. */
|
|
|
|
__u64 aio_data; /* data to be returned in event's data */
|
2017-07-06 23:58:37 +07:00
|
|
|
|
|
|
|
#if defined(__BYTE_ORDER) ? __BYTE_ORDER == __LITTLE_ENDIAN : defined(__LITTLE_ENDIAN)
|
|
|
|
__u32 aio_key; /* the kernel sets aio_key to the req # */
|
|
|
|
__kernel_rwf_t aio_rw_flags; /* RWF_* flags */
|
|
|
|
#elif defined(__BYTE_ORDER) ? __BYTE_ORDER == __BIG_ENDIAN : defined(__BIG_ENDIAN)
|
|
|
|
__kernel_rwf_t aio_rw_flags; /* RWF_* flags */
|
|
|
|
__u32 aio_key; /* the kernel sets aio_key to the req # */
|
|
|
|
#else
|
|
|
|
#error edit for your odd byteorder.
|
|
|
|
#endif
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* common fields */
|
|
|
|
__u16 aio_lio_opcode; /* see IOCB_CMD_ above */
|
|
|
|
__s16 aio_reqprio;
|
|
|
|
__u32 aio_fildes;
|
|
|
|
|
|
|
|
__u64 aio_buf;
|
|
|
|
__u64 aio_nbytes;
|
|
|
|
__s64 aio_offset;
|
|
|
|
|
|
|
|
/* extra parameters */
|
|
|
|
__u64 aio_reserved2; /* TODO: use this for a (struct sigevent *) */
|
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>
2007-05-11 12:23:21 +07:00
|
|
|
|
|
|
|
/* flags for the "struct iocb" */
|
|
|
|
__u32 aio_flags;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* if the IOCB_FLAG_RESFD flag of "aio_flags" is set, this is an
|
|
|
|
* eventfd to signal AIO readiness to
|
|
|
|
*/
|
|
|
|
__u32 aio_resfd;
|
2005-04-17 05:20:36 +07:00
|
|
|
}; /* 64 bytes */
|
|
|
|
|
|
|
|
#undef IFBIG
|
|
|
|
#undef IFLITTLE
|
|
|
|
|
aio: implement io_pgetevents
This is the io_getevents equivalent of ppoll/pselect and allows to
properly mix signals and aio completions (especially with IOCB_CMD_POLL)
and atomically executes the following sequence:
sigset_t origmask;
pthread_sigmask(SIG_SETMASK, &sigmask, &origmask);
ret = io_getevents(ctx, min_nr, nr, events, timeout);
pthread_sigmask(SIG_SETMASK, &origmask, NULL);
Note that unlike many other signal related calls we do not pass a sigmask
size, as that would get us to 7 arguments, which aren't easily supported
by the syscall infrastructure. It seems a lot less painful to just add a
new syscall variant in the unlikely case we're going to increase the
sigset size.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
2018-05-03 00:51:00 +07:00
|
|
|
struct __aio_sigset {
|
|
|
|
sigset_t __user *sigmask;
|
|
|
|
size_t sigsetsize;
|
|
|
|
};
|
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
#endif /* __LINUX__AIO_ABI_H */
|
|
|
|
|