diff options
| author | Benjamin LaHaise <bcrl@toomuch.toronto.redhat.com> | 2002-08-19 10:23:57 -0400 |
|---|---|---|
| committer | Benjamin LaHaise <bcrl@toomuch.toronto.redhat.com> | 2002-08-19 10:23:57 -0400 |
| commit | ea5097be4e814a2a9457e60653052306295941e8 (patch) | |
| tree | d5c2c56b628630cfa207ce4e4a7bce9ff796ed60 | |
| parent | 85f817cd10d1f01f42b36d9873dc527b212fea83 (diff) | |
add basic stubs for aio
| -rw-r--r-- | MAINTAINERS | 6 | ||||
| -rw-r--r-- | arch/i386/kernel/entry.S | 5 | ||||
| -rw-r--r-- | fs/Makefile | 2 | ||||
| -rw-r--r-- | fs/aio.c | 99 | ||||
| -rw-r--r-- | include/asm-i386/unistd.h | 5 | ||||
| -rw-r--r-- | include/linux/aio_abi.h | 92 |
6 files changed, 208 insertions, 1 deletions
diff --git a/MAINTAINERS b/MAINTAINERS index d201818b39bf..0fa326cc2c65 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -132,6 +132,12 @@ M: A2232@gmx.net L: linux-m68k@lists.linux-m68k.org S: Maintained +AIO +P: Benjamin LaHaise +M: bcrl@redhat.com +L: linux-aio@kvack.org +S: Supported + ACENIC DRIVER P: Jes Sorensen M: jes@trained-monkey.org diff --git a/arch/i386/kernel/entry.S b/arch/i386/kernel/entry.S index 249035fb7f41..1d622224ec3b 100644 --- a/arch/i386/kernel/entry.S +++ b/arch/i386/kernel/entry.S @@ -754,6 +754,11 @@ ENTRY(sys_call_table) .long sys_sched_getaffinity .long sys_set_thread_area .long sys_get_thread_area + .long sys_io_setup /* 245 */ + .long sys_io_destroy + .long sys_io_getevents + .long sys_io_submit + .long sys_io_cancel .rept NR_syscalls-(.-sys_call_table)/4 .long sys_ni_syscall diff --git a/fs/Makefile b/fs/Makefile index 51e7d8264aec..1155a22613fc 100644 --- a/fs/Makefile +++ b/fs/Makefile @@ -14,7 +14,7 @@ obj-y := open.o read_write.o devices.o file_table.o buffer.o \ namei.o fcntl.o ioctl.o readdir.o select.o fifo.o locks.o \ dcache.o inode.o attr.o bad_inode.o file.o iobuf.o dnotify.o \ filesystems.o namespace.o seq_file.o xattr.o libfs.o \ - fs-writeback.o mpage.o direct-io.o + fs-writeback.o mpage.o direct-io.o aio.o ifneq ($(CONFIG_NFSD),n) ifneq ($(CONFIG_NFSD),) diff --git a/fs/aio.c b/fs/aio.c new file mode 100644 index 000000000000..5ce3f594bd76 --- /dev/null +++ b/fs/aio.c @@ -0,0 +1,99 @@ +/* + * An async IO implementation for Linux + * Written by Benjamin LaHaise <bcrl@redhat.com> + * + * Implements an efficient asynchronous io interface. + * + * Copyright 2000, 2001, 2002 Red Hat, Inc. All Rights Reserved. + * + * See ../COPYING for licensing terms. + */ +#include <linux/kernel.h> +#include <linux/errno.h> +#include <linux/time.h> +#include <linux/aio_abi.h> + +/* io_setup: + * Create an aio_context capable of receiving at least nr_events. + * ctxp must not point to an aio_context that already exists, and + * must be initialized to 0 prior to the call. On successful + * creation of the aio_context, *ctxp is filled in with the resulting + * handle. May fail with -EINVAL if *ctxp is not initialized, + * if the specified nr_events exceeds internal limits. May fail + * with -EAGAIN if the specified nr_events exceeds the user's limit + * of available events. May fail with -ENOMEM if insufficient kernel + * resources are available. May fail with -EFAULT if an invalid + * pointer is passed for ctxp. Will fail with -ENOSYS if not + * implemented. + */ +asmlinkage long sys_io_setup(unsigned nr_events, aio_context_t *ctxp) +{ + return -ENOSYS; +} + +/* io_destroy: + * Destroy the aio_context specified. May cancel any outstanding + * AIOs and block on completion. Will fail with -ENOSYS if not + * implemented. May fail with -EFAULT if the context pointed to + * is invalid. + */ +asmlinkage long sys_io_destroy(aio_context_t ctx) +{ + return -ENOSYS; +} + +/* io_submit: + * Queue the nr iocbs pointed to by iocbpp for processing. Returns + * the number of iocbs queued. May return -EINVAL if the aio_context + * specified by ctx_id is invalid, if nr is < 0, if the iocb at + * *iocbpp[0] is not properly initialized, if the operation specified + * is invalid for the file descriptor in the iocb. May fail with + * -EFAULT if any of the data structures point to invalid data. May + * fail with -EBADF if the file descriptor specified in the first + * iocb is invalid. May fail with -EAGAIN if insufficient resources + * are available to queue any iocbs. Will return 0 if nr is 0. Will + * fail with -ENOSYS if not implemented. + */ +asmlinkage long sys_io_submit(aio_context_t ctx_id, long nr, + struct iocb **iocbpp) +{ + return -ENOSYS; +} + +/* io_cancel: + * Attempts to cancel an iocb previously passed to io_submit. If + * the operation is successfully cancelled, the resulting event is + * copied into the memory pointed to by result without being placed + * into the completion queue and 0 is returned. May fail with + * -EFAULT if any of the data structures pointed to are invalid. + * May fail with -EINVAL if aio_context specified by ctx_id is + * invalid. May fail with -EAGAIN if the iocb specified was not + * cancelled. Will fail with -ENOSYS if not implemented. + */ +asmlinkage long sys_io_cancel(aio_context_t ctx_id, struct iocb *iocb, + struct io_event *result) +{ + return -ENOSYS; +} + +/* io_getevents: + * Attempts to read at least min_nr events and up to nr events from + * the completion queue for the aio_context specified by ctx_id. May + * fail with -EINVAL if ctx_id is invalid, if min_nr is out of range, + * if nr is out of range, if when is out of range. May fail with + * -EFAULT if any of the memory specified to is invalid. May return + * 0 or < min_nr if no events are available and the timeout specified + * by when has elapsed, where when == NULL specifies an infinite + * timeout. Note that the timeout pointed to by when is relative and + * will be updated if not NULL and the operation blocks. Will fail + * with -ENOSYS if not implemented. + */ +asmlinkage long sys_io_getevents(aio_context_t ctx_id, + long min_nr, + long nr, + struct io_event *events, + struct timespec *when) +{ + return -ENOSYS; +} + diff --git a/include/asm-i386/unistd.h b/include/asm-i386/unistd.h index 6735e8a7595a..4b702bd8e683 100644 --- a/include/asm-i386/unistd.h +++ b/include/asm-i386/unistd.h @@ -249,6 +249,11 @@ #define __NR_sched_getaffinity 242 #define __NR_set_thread_area 243 #define __NR_get_thread_area 244 +#define __NR_io_setup 245 +#define __NR_io_destroy 246 +#define __NR_io_getevents 247 +#define __NR_io_submit 248 +#define __NR_io_cancel 249 /* user-visible error numbers are in the range -1 - -124: see <asm-i386/errno.h> */ diff --git a/include/linux/aio_abi.h b/include/linux/aio_abi.h new file mode 100644 index 000000000000..e7fc6b234efb --- /dev/null +++ b/include/linux/aio_abi.h @@ -0,0 +1,92 @@ +/* linux/aio_abi.h + * + * Copyright 2000,2001,2002 Red Hat. + * + * Written by Benjamin LaHaise <bcrl@redhat.com> + * + * 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 + +#include <asm/byteorder.h> + +typedef unsigned long aio_context_t; + +enum { + IOCB_CMD_PREAD = 0, + IOCB_CMD_PWRITE = 1, + IOCB_CMD_FSYNC = 2, + IOCB_CMD_FDSYNC = 3, + /* These two are experimental. + * IOCB_CMD_PREADX = 4, + * IOCB_CMD_POLL = 5, + */ + IOCB_CMD_NOOP = 6, +}; + +/* 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 */ +}; + +#if defined(__LITTLE_ENDIAN) +#define PADDED(x,y) x, y +#elif defined(__BIG_ENDIAN) +#define PADDED(x,y) y, x +#else +#error edit for your odd byteorder. +#endif + +/* + * 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 */ + __u32 PADDED(aio_key, aio_reserved1); + /* the kernel sets aio_key to the req # */ + + /* 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 *) */ + __u64 aio_reserved3; +}; /* 64 bytes */ + +#undef IFBIG +#undef IFLITTLE + +#endif /* __LINUX__AIO_ABI_H */ + |
