2005-09-04 00:57:45 +02:00
|
|
|
/*
|
2007-10-16 10:27:00 +02:00
|
|
|
* Copyright (C) 2004 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
|
2005-09-04 00:57:45 +02:00
|
|
|
* Licensed under the GPL
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <unistd.h>
|
2007-10-16 10:27:00 +02:00
|
|
|
#include <sched.h>
|
2005-09-04 00:57:45 +02:00
|
|
|
#include <signal.h>
|
|
|
|
#include <errno.h>
|
2007-10-16 10:27:00 +02:00
|
|
|
#include <sys/time.h>
|
|
|
|
#include <asm/unistd.h>
|
2012-10-08 04:27:32 +02:00
|
|
|
#include <aio.h>
|
|
|
|
#include <init.h>
|
|
|
|
#include <kern_util.h>
|
|
|
|
#include <os.h>
|
2005-09-04 00:57:45 +02:00
|
|
|
|
2005-10-11 05:10:32 +02:00
|
|
|
struct aio_thread_req {
|
2006-01-06 09:18:50 +01:00
|
|
|
enum aio_type type;
|
|
|
|
int io_fd;
|
|
|
|
unsigned long long offset;
|
|
|
|
char *buf;
|
|
|
|
int len;
|
|
|
|
struct aio_context *aio;
|
2005-10-11 05:10:32 +02:00
|
|
|
};
|
|
|
|
|
2005-09-04 00:57:45 +02:00
|
|
|
#if defined(HAVE_AIO_ABI)
|
|
|
|
#include <linux/aio_abi.h>
|
|
|
|
|
2007-10-16 10:27:00 +02:00
|
|
|
/*
|
|
|
|
* If we have the headers, we are going to build with AIO enabled.
|
2005-09-04 00:57:45 +02:00
|
|
|
* If we don't have aio in libc, we define the necessary stubs here.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if !defined(HAVE_AIO_LIBC)
|
|
|
|
|
|
|
|
static long io_setup(int n, aio_context_t *ctxp)
|
|
|
|
{
|
2006-01-06 09:18:50 +01:00
|
|
|
return syscall(__NR_io_setup, n, ctxp);
|
2005-09-04 00:57:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static long io_submit(aio_context_t ctx, long nr, struct iocb **iocbpp)
|
|
|
|
{
|
2006-01-06 09:18:50 +01:00
|
|
|
return syscall(__NR_io_submit, ctx, nr, iocbpp);
|
2005-09-04 00:57:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static long io_getevents(aio_context_t ctx_id, long min_nr, long nr,
|
2006-01-06 09:18:50 +01:00
|
|
|
struct io_event *events, struct timespec *timeout)
|
2005-09-04 00:57:45 +02:00
|
|
|
{
|
2006-01-06 09:18:50 +01:00
|
|
|
return syscall(__NR_io_getevents, ctx_id, min_nr, nr, events, timeout);
|
2005-09-04 00:57:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2007-10-16 10:27:00 +02:00
|
|
|
/*
|
|
|
|
* The AIO_MMAP cases force the mmapped page into memory here
|
2005-09-04 00:57:45 +02:00
|
|
|
* rather than in whatever place first touches the data. I used
|
|
|
|
* to do this by touching the page, but that's delicate because
|
|
|
|
* gcc is prone to optimizing that away. So, what's done here
|
|
|
|
* is we read from the descriptor from which the page was
|
|
|
|
* mapped. The caller is required to pass an offset which is
|
|
|
|
* inside the page that was mapped. Thus, when the read
|
|
|
|
* returns, we know that the page is in the page cache, and
|
|
|
|
* that it now backs the mmapped area.
|
|
|
|
*/
|
|
|
|
|
2005-10-11 05:10:32 +02:00
|
|
|
static int do_aio(aio_context_t ctx, enum aio_type type, int fd, char *buf,
|
2006-01-06 09:18:50 +01:00
|
|
|
int len, unsigned long long offset, struct aio_context *aio)
|
2005-09-04 00:57:45 +02:00
|
|
|
{
|
2007-07-24 03:43:47 +02:00
|
|
|
struct iocb *iocbp = & ((struct iocb) {
|
|
|
|
.aio_data = (unsigned long) aio,
|
|
|
|
.aio_fildes = fd,
|
|
|
|
.aio_buf = (unsigned long) buf,
|
|
|
|
.aio_nbytes = len,
|
|
|
|
.aio_offset = offset
|
|
|
|
});
|
2006-01-06 09:18:50 +01:00
|
|
|
char c;
|
2007-07-24 03:43:47 +02:00
|
|
|
|
|
|
|
switch (type) {
|
2006-01-06 09:18:50 +01:00
|
|
|
case AIO_READ:
|
2007-07-24 03:43:47 +02:00
|
|
|
iocbp->aio_lio_opcode = IOCB_CMD_PREAD;
|
2006-01-06 09:18:50 +01:00
|
|
|
break;
|
|
|
|
case AIO_WRITE:
|
2007-07-24 03:43:47 +02:00
|
|
|
iocbp->aio_lio_opcode = IOCB_CMD_PWRITE;
|
2006-01-06 09:18:50 +01:00
|
|
|
break;
|
|
|
|
case AIO_MMAP:
|
2007-07-24 03:43:47 +02:00
|
|
|
iocbp->aio_lio_opcode = IOCB_CMD_PREAD;
|
|
|
|
iocbp->aio_buf = (unsigned long) &c;
|
|
|
|
iocbp->aio_nbytes = sizeof(c);
|
2006-01-06 09:18:50 +01:00
|
|
|
break;
|
|
|
|
default:
|
2007-07-24 03:43:47 +02:00
|
|
|
printk(UM_KERN_ERR "Bogus op in do_aio - %d\n", type);
|
|
|
|
return -EINVAL;
|
2006-01-06 09:18:50 +01:00
|
|
|
}
|
|
|
|
|
2007-07-24 03:43:47 +02:00
|
|
|
return (io_submit(ctx, 1, &iocbp) > 0) ? 0 : -errno;
|
2005-09-04 00:57:45 +02:00
|
|
|
}
|
|
|
|
|
2007-02-10 10:44:27 +01:00
|
|
|
/* Initialized in an initcall and unchanged thereafter */
|
2005-09-04 00:57:45 +02:00
|
|
|
static aio_context_t ctx = 0;
|
|
|
|
|
|
|
|
static int aio_thread(void *arg)
|
|
|
|
{
|
2006-01-06 09:18:50 +01:00
|
|
|
struct aio_thread_reply reply;
|
|
|
|
struct io_event event;
|
|
|
|
int err, n, reply_fd;
|
|
|
|
|
|
|
|
signal(SIGWINCH, SIG_IGN);
|
|
|
|
|
2007-10-16 10:27:00 +02:00
|
|
|
while (1) {
|
2006-01-06 09:18:50 +01:00
|
|
|
n = io_getevents(ctx, 1, 1, &event, NULL);
|
2007-10-16 10:27:00 +02:00
|
|
|
if (n < 0) {
|
|
|
|
if (errno == EINTR)
|
2006-01-06 09:18:50 +01:00
|
|
|
continue;
|
2007-10-16 10:27:00 +02:00
|
|
|
printk(UM_KERN_ERR "aio_thread - io_getevents failed, "
|
2006-01-06 09:18:50 +01:00
|
|
|
"errno = %d\n", errno);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
reply = ((struct aio_thread_reply)
|
|
|
|
{ .data = (void *) (long) event.data,
|
|
|
|
.err = event.res });
|
2005-10-11 05:10:32 +02:00
|
|
|
reply_fd = ((struct aio_context *) reply.data)->reply_fd;
|
2007-05-06 23:51:35 +02:00
|
|
|
err = write(reply_fd, &reply, sizeof(reply));
|
2007-10-16 10:27:00 +02:00
|
|
|
if (err != sizeof(reply))
|
|
|
|
printk(UM_KERN_ERR "aio_thread - write failed, "
|
|
|
|
"fd = %d, err = %d\n", reply_fd, errno);
|
2006-01-06 09:18:50 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
2005-09-04 00:57:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2005-10-11 05:10:32 +02:00
|
|
|
static int do_not_aio(struct aio_thread_req *req)
|
2005-09-04 00:57:45 +02:00
|
|
|
{
|
2006-01-06 09:18:50 +01:00
|
|
|
char c;
|
2007-05-06 23:51:33 +02:00
|
|
|
unsigned long long actual;
|
2007-05-06 23:51:35 +02:00
|
|
|
int n;
|
2006-01-06 09:18:50 +01:00
|
|
|
|
2007-05-06 23:51:33 +02:00
|
|
|
actual = lseek64(req->io_fd, req->offset, SEEK_SET);
|
2007-10-16 10:27:00 +02:00
|
|
|
if (actual != req->offset)
|
2007-05-06 23:51:33 +02:00
|
|
|
return -errno;
|
|
|
|
|
2008-02-08 13:22:08 +01:00
|
|
|
switch (req->type) {
|
2006-01-06 09:18:50 +01:00
|
|
|
case AIO_READ:
|
2007-05-06 23:51:35 +02:00
|
|
|
n = read(req->io_fd, req->buf, req->len);
|
2006-01-06 09:18:50 +01:00
|
|
|
break;
|
|
|
|
case AIO_WRITE:
|
2007-05-06 23:51:35 +02:00
|
|
|
n = write(req->io_fd, req->buf, req->len);
|
2006-01-06 09:18:50 +01:00
|
|
|
break;
|
|
|
|
case AIO_MMAP:
|
2007-05-06 23:51:35 +02:00
|
|
|
n = read(req->io_fd, &c, sizeof(c));
|
2006-01-06 09:18:50 +01:00
|
|
|
break;
|
|
|
|
default:
|
2007-10-16 10:27:00 +02:00
|
|
|
printk(UM_KERN_ERR "do_not_aio - bad request type : %d\n",
|
|
|
|
req->type);
|
2007-05-06 23:51:35 +02:00
|
|
|
return -EINVAL;
|
2006-01-06 09:18:50 +01:00
|
|
|
}
|
|
|
|
|
2007-10-16 10:27:00 +02:00
|
|
|
if (n < 0)
|
2007-05-06 23:51:35 +02:00
|
|
|
return -errno;
|
|
|
|
return 0;
|
2005-09-04 00:57:45 +02:00
|
|
|
}
|
|
|
|
|
2007-02-10 10:44:27 +01:00
|
|
|
/* These are initialized in initcalls and not changed */
|
|
|
|
static int aio_req_fd_r = -1;
|
|
|
|
static int aio_req_fd_w = -1;
|
|
|
|
static int aio_pid = -1;
|
2007-07-16 08:38:56 +02:00
|
|
|
static unsigned long aio_stack;
|
2007-02-10 10:44:27 +01:00
|
|
|
|
2005-09-04 00:57:45 +02:00
|
|
|
static int not_aio_thread(void *arg)
|
|
|
|
{
|
2006-01-06 09:18:50 +01:00
|
|
|
struct aio_thread_req req;
|
|
|
|
struct aio_thread_reply reply;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
signal(SIGWINCH, SIG_IGN);
|
2007-10-16 10:27:00 +02:00
|
|
|
while (1) {
|
2007-05-06 23:51:35 +02:00
|
|
|
err = read(aio_req_fd_r, &req, sizeof(req));
|
2007-10-16 10:27:00 +02:00
|
|
|
if (err != sizeof(req)) {
|
|
|
|
if (err < 0)
|
|
|
|
printk(UM_KERN_ERR "not_aio_thread - "
|
|
|
|
"read failed, fd = %d, err = %d\n",
|
|
|
|
aio_req_fd_r,
|
2007-05-06 23:51:35 +02:00
|
|
|
errno);
|
2006-01-06 09:18:50 +01:00
|
|
|
else {
|
2007-10-16 10:27:00 +02:00
|
|
|
printk(UM_KERN_ERR "not_aio_thread - short "
|
|
|
|
"read, fd = %d, length = %d\n",
|
|
|
|
aio_req_fd_r, err);
|
2006-01-06 09:18:50 +01:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
err = do_not_aio(&req);
|
|
|
|
reply = ((struct aio_thread_reply) { .data = req.aio,
|
2007-05-06 23:51:33 +02:00
|
|
|
.err = err });
|
2007-05-06 23:51:35 +02:00
|
|
|
err = write(req.aio->reply_fd, &reply, sizeof(reply));
|
2007-10-16 10:27:00 +02:00
|
|
|
if (err != sizeof(reply))
|
|
|
|
printk(UM_KERN_ERR "not_aio_thread - write failed, "
|
|
|
|
"fd = %d, err = %d\n", req.aio->reply_fd, errno);
|
2006-01-06 09:18:50 +01:00
|
|
|
}
|
2006-01-06 09:18:49 +01:00
|
|
|
|
|
|
|
return 0;
|
2005-09-04 00:57:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int init_aio_24(void)
|
|
|
|
{
|
2006-01-06 09:18:50 +01:00
|
|
|
int fds[2], err;
|
|
|
|
|
|
|
|
err = os_pipe(fds, 1, 1);
|
2007-10-16 10:27:00 +02:00
|
|
|
if (err)
|
2006-01-06 09:18:50 +01:00
|
|
|
goto out;
|
|
|
|
|
|
|
|
aio_req_fd_w = fds[0];
|
|
|
|
aio_req_fd_r = fds[1];
|
2007-05-06 23:51:44 +02:00
|
|
|
|
|
|
|
err = os_set_fd_block(aio_req_fd_w, 0);
|
2007-10-16 10:27:00 +02:00
|
|
|
if (err)
|
2007-05-06 23:51:44 +02:00
|
|
|
goto out_close_pipe;
|
|
|
|
|
2006-01-06 09:18:50 +01:00
|
|
|
err = run_helper_thread(not_aio_thread, NULL,
|
2007-12-18 01:19:46 +01:00
|
|
|
CLONE_FILES | CLONE_VM, &aio_stack);
|
2007-10-16 10:27:00 +02:00
|
|
|
if (err < 0)
|
2006-01-06 09:18:50 +01:00
|
|
|
goto out_close_pipe;
|
|
|
|
|
|
|
|
aio_pid = err;
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
out_close_pipe:
|
2007-10-16 10:27:11 +02:00
|
|
|
close(fds[0]);
|
|
|
|
close(fds[1]);
|
2006-01-06 09:18:50 +01:00
|
|
|
aio_req_fd_w = -1;
|
|
|
|
aio_req_fd_r = -1;
|
|
|
|
out:
|
2005-09-04 00:57:45 +02:00
|
|
|
#ifndef HAVE_AIO_ABI
|
2007-10-16 10:27:00 +02:00
|
|
|
printk(UM_KERN_INFO "/usr/include/linux/aio_abi.h not present during "
|
|
|
|
"build\n");
|
2005-09-04 00:57:45 +02:00
|
|
|
#endif
|
2007-10-16 10:27:00 +02:00
|
|
|
printk(UM_KERN_INFO "2.6 host AIO support not used - falling back to "
|
|
|
|
"I/O thread\n");
|
2006-01-06 09:18:50 +01:00
|
|
|
return 0;
|
2005-09-04 00:57:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef HAVE_AIO_ABI
|
|
|
|
#define DEFAULT_24_AIO 0
|
|
|
|
static int init_aio_26(void)
|
|
|
|
{
|
2006-01-06 09:18:50 +01:00
|
|
|
int err;
|
2005-09-04 00:57:45 +02:00
|
|
|
|
2007-10-16 10:27:00 +02:00
|
|
|
if (io_setup(256, &ctx)) {
|
[PATCH] uml: preserve errno in error paths
The poster child for this patch is the third tuntap_user hunk. When an ioctl
fails, it properly closes the opened file descriptor and returns. However,
the close resets errno to 0, and the 'return errno' that follows returns 0
rather than the value that ioctl set. This caused the caller to believe that
the device open succeeded and had opened file descriptor 0, which caused no
end of interesting behavior.
The rest of this patch is a pass through the UML sources looking for places
where errno could be reset before being passed back out. A common culprit is
printk, which could call write, being called before errno is returned.
In some cases, where the code ends up being much smaller, I just deleted the
printk.
There was another case where a caller of run_helper looked at errno after a
failure, rather than the return value of run_helper, which was the errno value
that it wanted.
Signed-off-by: Jeff Dike <jdike@addtoit.com>
Cc: Paolo Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-09-17 04:27:49 +02:00
|
|
|
err = -errno;
|
2007-10-16 10:27:00 +02:00
|
|
|
printk(UM_KERN_ERR "aio_thread failed to initialize context, "
|
|
|
|
"err = %d\n", errno);
|
2006-01-06 09:18:50 +01:00
|
|
|
return err;
|
|
|
|
}
|
2005-09-04 00:57:45 +02:00
|
|
|
|
2006-01-06 09:18:50 +01:00
|
|
|
err = run_helper_thread(aio_thread, NULL,
|
2007-12-18 01:19:46 +01:00
|
|
|
CLONE_FILES | CLONE_VM, &aio_stack);
|
2007-10-16 10:27:00 +02:00
|
|
|
if (err < 0)
|
2006-01-06 09:18:50 +01:00
|
|
|
return err;
|
2005-09-04 00:57:45 +02:00
|
|
|
|
2006-01-06 09:18:50 +01:00
|
|
|
aio_pid = err;
|
2005-09-04 00:57:45 +02:00
|
|
|
|
2007-10-16 10:27:00 +02:00
|
|
|
printk(UM_KERN_INFO "Using 2.6 host AIO\n");
|
2006-01-06 09:18:50 +01:00
|
|
|
return 0;
|
2005-10-11 05:10:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int submit_aio_26(enum aio_type type, int io_fd, char *buf, int len,
|
|
|
|
unsigned long long offset, struct aio_context *aio)
|
|
|
|
{
|
2006-01-06 09:18:50 +01:00
|
|
|
struct aio_thread_reply reply;
|
|
|
|
int err;
|
|
|
|
|
|
|
|
err = do_aio(ctx, type, io_fd, buf, len, offset, aio);
|
2007-10-16 10:27:00 +02:00
|
|
|
if (err) {
|
2006-01-06 09:18:50 +01:00
|
|
|
reply = ((struct aio_thread_reply) { .data = aio,
|
|
|
|
.err = err });
|
2007-05-06 23:51:35 +02:00
|
|
|
err = write(aio->reply_fd, &reply, sizeof(reply));
|
2007-10-16 10:27:00 +02:00
|
|
|
if (err != sizeof(reply)) {
|
2007-05-06 23:51:35 +02:00
|
|
|
err = -errno;
|
2007-10-16 10:27:00 +02:00
|
|
|
printk(UM_KERN_ERR "submit_aio_26 - write failed, "
|
2006-01-06 09:18:50 +01:00
|
|
|
"fd = %d, err = %d\n", aio->reply_fd, -err);
|
2007-05-06 23:51:35 +02:00
|
|
|
}
|
2006-01-06 09:18:50 +01:00
|
|
|
else err = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return err;
|
2005-09-04 00:57:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
#define DEFAULT_24_AIO 1
|
2005-10-11 05:10:32 +02:00
|
|
|
static int init_aio_26(void)
|
2005-09-04 00:57:45 +02:00
|
|
|
{
|
2006-01-06 09:18:50 +01:00
|
|
|
return -ENOSYS;
|
2005-09-04 00:57:45 +02:00
|
|
|
}
|
|
|
|
|
2005-10-11 05:10:32 +02:00
|
|
|
static int submit_aio_26(enum aio_type type, int io_fd, char *buf, int len,
|
|
|
|
unsigned long long offset, struct aio_context *aio)
|
2005-09-04 00:57:45 +02:00
|
|
|
{
|
2006-01-06 09:18:50 +01:00
|
|
|
return -ENOSYS;
|
2005-09-04 00:57:45 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-02-10 10:44:27 +01:00
|
|
|
/* Initialized in an initcall and unchanged thereafter */
|
2005-09-04 00:57:45 +02:00
|
|
|
static int aio_24 = DEFAULT_24_AIO;
|
|
|
|
|
|
|
|
static int __init set_aio_24(char *name, int *add)
|
|
|
|
{
|
2006-01-06 09:18:50 +01:00
|
|
|
aio_24 = 1;
|
|
|
|
return 0;
|
2005-09-04 00:57:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
__uml_setup("aio=2.4", set_aio_24,
|
|
|
|
"aio=2.4\n"
|
|
|
|
" This is used to force UML to use 2.4-style AIO even when 2.6 AIO is\n"
|
|
|
|
" available. 2.4 AIO is a single thread that handles one request at a\n"
|
|
|
|
" time, synchronously. 2.6 AIO is a thread which uses the 2.6 AIO \n"
|
|
|
|
" interface to handle an arbitrary number of pending requests. 2.6 AIO \n"
|
|
|
|
" is not available in tt mode, on 2.4 hosts, or when UML is built with\n"
|
|
|
|
" /usr/include/linux/aio_abi.h not available. Many distributions don't\n"
|
|
|
|
" include aio_abi.h, so you will need to copy it from a kernel tree to\n"
|
|
|
|
" your /usr/include/linux in order to build an AIO-capable UML\n\n"
|
|
|
|
);
|
|
|
|
|
|
|
|
static int init_aio(void)
|
|
|
|
{
|
2006-01-06 09:18:50 +01:00
|
|
|
int err;
|
|
|
|
|
2007-10-16 10:27:00 +02:00
|
|
|
if (!aio_24) {
|
2006-01-06 09:18:50 +01:00
|
|
|
err = init_aio_26();
|
2007-10-16 10:27:00 +02:00
|
|
|
if (err && (errno == ENOSYS)) {
|
|
|
|
printk(UM_KERN_INFO "2.6 AIO not supported on the "
|
|
|
|
"host - reverting to 2.4 AIO\n");
|
2006-01-06 09:18:50 +01:00
|
|
|
aio_24 = 1;
|
|
|
|
}
|
|
|
|
else return err;
|
|
|
|
}
|
|
|
|
|
2007-10-16 10:27:00 +02:00
|
|
|
if (aio_24)
|
2006-01-06 09:18:50 +01:00
|
|
|
return init_aio_24();
|
|
|
|
|
|
|
|
return 0;
|
2005-09-04 00:57:45 +02:00
|
|
|
}
|
|
|
|
|
2007-10-16 10:27:00 +02:00
|
|
|
/*
|
|
|
|
* The reason for the __initcall/__uml_exitcall asymmetry is that init_aio
|
2005-09-04 00:57:45 +02:00
|
|
|
* needs to be called when the kernel is running because it calls run_helper,
|
|
|
|
* which needs get_free_page. exit_aio is a __uml_exitcall because the generic
|
|
|
|
* kernel does not run __exitcalls on shutdown, and can't because many of them
|
|
|
|
* break when called outside of module unloading.
|
|
|
|
*/
|
|
|
|
__initcall(init_aio);
|
|
|
|
|
|
|
|
static void exit_aio(void)
|
|
|
|
{
|
2007-07-16 08:38:56 +02:00
|
|
|
if (aio_pid != -1) {
|
2006-01-06 09:18:50 +01:00
|
|
|
os_kill_process(aio_pid, 1);
|
2007-07-16 08:38:56 +02:00
|
|
|
free_stack(aio_stack, 0);
|
|
|
|
}
|
2005-09-04 00:57:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
__uml_exitcall(exit_aio);
|
|
|
|
|
2005-10-11 05:10:32 +02:00
|
|
|
static int submit_aio_24(enum aio_type type, int io_fd, char *buf, int len,
|
|
|
|
unsigned long long offset, struct aio_context *aio)
|
2005-09-04 00:57:45 +02:00
|
|
|
{
|
2006-01-06 09:18:50 +01:00
|
|
|
struct aio_thread_req req = { .type = type,
|
|
|
|
.io_fd = io_fd,
|
|
|
|
.offset = offset,
|
|
|
|
.buf = buf,
|
|
|
|
.len = len,
|
|
|
|
.aio = aio,
|
|
|
|
};
|
|
|
|
int err;
|
|
|
|
|
2007-05-06 23:51:35 +02:00
|
|
|
err = write(aio_req_fd_w, &req, sizeof(req));
|
2007-10-16 10:27:00 +02:00
|
|
|
if (err == sizeof(req))
|
2006-01-06 09:18:50 +01:00
|
|
|
err = 0;
|
2007-05-06 23:51:35 +02:00
|
|
|
else err = -errno;
|
2006-01-06 09:18:50 +01:00
|
|
|
|
|
|
|
return err;
|
2005-10-11 05:10:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int submit_aio(enum aio_type type, int io_fd, char *buf, int len,
|
2006-01-06 09:18:50 +01:00
|
|
|
unsigned long long offset, int reply_fd,
|
|
|
|
struct aio_context *aio)
|
2005-10-11 05:10:32 +02:00
|
|
|
{
|
2006-01-06 09:18:50 +01:00
|
|
|
aio->reply_fd = reply_fd;
|
2007-10-16 10:27:00 +02:00
|
|
|
if (aio_24)
|
2006-01-06 09:18:50 +01:00
|
|
|
return submit_aio_24(type, io_fd, buf, len, offset, aio);
|
2007-10-16 10:27:00 +02:00
|
|
|
else
|
2006-01-06 09:18:50 +01:00
|
|
|
return submit_aio_26(type, io_fd, buf, len, offset, aio);
|
2005-09-04 00:57:45 +02:00
|
|
|
}
|