Commit 107b218e authored by Linus Torvalds's avatar Linus Torvalds

Merge master.kernel.org:/home/bcrl/aio-2.5

into penguin.transmeta.com:/home/penguin/torvalds/repositories/kernel/linux
parents b43e83e8 c1e52e2f
...@@ -132,6 +132,12 @@ M: A2232@gmx.net ...@@ -132,6 +132,12 @@ M: A2232@gmx.net
L: linux-m68k@lists.linux-m68k.org L: linux-m68k@lists.linux-m68k.org
S: Maintained S: Maintained
AIO
P: Benjamin LaHaise
M: bcrl@redhat.com
L: linux-aio@kvack.org
S: Supported
ACENIC DRIVER ACENIC DRIVER
P: Jes Sorensen P: Jes Sorensen
M: jes@trained-monkey.org M: jes@trained-monkey.org
......
...@@ -754,6 +754,11 @@ ENTRY(sys_call_table) ...@@ -754,6 +754,11 @@ ENTRY(sys_call_table)
.long sys_sched_getaffinity .long sys_sched_getaffinity
.long sys_set_thread_area .long sys_set_thread_area
.long sys_get_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 .rept NR_syscalls-(.-sys_call_table)/4
.long sys_ni_syscall .long sys_ni_syscall
......
...@@ -7,14 +7,14 @@ ...@@ -7,14 +7,14 @@
O_TARGET := fs.o O_TARGET := fs.o
export-objs := open.o dcache.o buffer.o bio.o inode.o dquot.o mpage.o export-objs := open.o dcache.o buffer.o bio.o inode.o dquot.o mpage.o aio.o
obj-y := open.o read_write.o devices.o file_table.o buffer.o \ obj-y := open.o read_write.o devices.o file_table.o buffer.o \
bio.o super.o block_dev.o char_dev.o stat.o exec.o pipe.o \ bio.o super.o block_dev.o char_dev.o stat.o exec.o pipe.o \
namei.o fcntl.o ioctl.o readdir.o select.o fifo.o locks.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 \ 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 \ 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),n)
ifneq ($(CONFIG_NFSD),) ifneq ($(CONFIG_NFSD),)
......
This diff is collapsed.
...@@ -19,7 +19,9 @@ D(5) KM_BIO_SRC_IRQ, ...@@ -19,7 +19,9 @@ D(5) KM_BIO_SRC_IRQ,
D(6) KM_BIO_DST_IRQ, D(6) KM_BIO_DST_IRQ,
D(7) KM_PTE0, D(7) KM_PTE0,
D(8) KM_PTE1, D(8) KM_PTE1,
D(9) KM_TYPE_NR D(9) KM_IRQ0,
D(10) KM_IRQ1,
D(11) KM_TYPE_NR
}; };
#undef D #undef D
......
...@@ -249,6 +249,11 @@ ...@@ -249,6 +249,11 @@
#define __NR_sched_getaffinity 242 #define __NR_sched_getaffinity 242
#define __NR_set_thread_area 243 #define __NR_set_thread_area 243
#define __NR_get_thread_area 244 #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> */ /* user-visible error numbers are in the range -1 - -124: see <asm-i386/errno.h> */
......
#ifndef __LINUX__AIO_H
#define __LINUX__AIO_H
#include <linux/tqueue.h>
#include <linux/list.h>
#include <asm/atomic.h>
#include <linux/aio_abi.h>
#define AIO_MAXSEGS 4
#define AIO_KIOGRP_NR_ATOMIC 8
struct kioctx;
/* Notes on cancelling a kiocb:
* If a kiocb is cancelled, aio_complete may return 0 to indicate
* that cancel has not yet disposed of the kiocb. All cancel
* operations *must* call aio_put_req to dispose of the kiocb
* to guard against races with the completion code.
*/
#define KIOCB_C_CANCELLED 0x01
#define KIOCB_C_COMPLETE 0x02
#define KIOCB_PRIVATE_SIZE (16 * sizeof(long))
struct kiocb {
int ki_users;
struct file *ki_filp;
struct kioctx *ki_ctx; /* may be NULL for sync ops */
int (*ki_cancel)(struct kiocb *, struct io_event *);
struct list_head ki_list;
void *ki_data; /* for use by the the file */
void *ki_user_obj; /* pointer to userland's iocb */
__u64 ki_user_data; /* user's data for completion */
unsigned ki_key; /* id of this request */
long private[KIOCB_PRIVATE_SIZE/sizeof(long)];
};
#define init_sync_kiocb(x, filp) \
do { \
(x)->ki_users = 1; \
(x)->ki_filp = (filp); \
(x)->ki_ctx = 0; \
(x)->ki_cancel = NULL; \
} while (0)
#define AIO_RING_MAGIC 0xa10a10a1
#define AIO_RING_COMPAT_FEATURES 1
#define AIO_RING_INCOMPAT_FEATURES 0
struct aio_ring {
unsigned id; /* kernel internal index number */
unsigned nr; /* number of io_events */
unsigned head;
unsigned tail;
unsigned magic;
unsigned compat_features;
unsigned incompat_features;
unsigned header_length; /* size of aio_ring */
struct io_event io_events[0];
}; /* 128 bytes + ring size */
#define aio_ring_avail(info, ring) (((ring)->head + (info)->nr - 1 - (ring)->tail) % (info)->nr)
#define AIO_RING_PAGES 8
struct aio_ring_info {
unsigned long mmap_base;
unsigned long mmap_size;
struct page **ring_pages;
spinlock_t ring_lock;
long nr_pages;
unsigned nr, tail;
struct page *internal_pages[AIO_RING_PAGES];
};
struct kioctx {
atomic_t users;
int dead;
struct mm_struct *mm;
/* This needs improving */
unsigned long user_id;
struct kioctx *next;
wait_queue_head_t wait;
spinlock_t ctx_lock;
int reqs_active;
struct list_head active_reqs; /* used for cancellation */
unsigned max_reqs;
struct aio_ring_info ring_info;
};
/* prototypes */
extern unsigned aio_max_size;
extern int FASTCALL(aio_put_req(struct kiocb *iocb));
extern int FASTCALL(aio_complete(struct kiocb *iocb, long res, long res2));
extern void FASTCALL(__put_ioctx(struct kioctx *ctx));
struct mm_struct;
extern void FASTCALL(exit_aio(struct mm_struct *mm));
#define get_ioctx(kioctx) do { if (unlikely(atomic_read(&(kioctx)->users) <= 0)) BUG(); atomic_inc(&(kioctx)->users); } while (0)
#define put_ioctx(kioctx) do { if (unlikely(atomic_dec_and_test(&(kioctx)->users))) __put_ioctx(kioctx); else if (unlikely(atomic_read(&(kioctx)->users) < 0)) BUG(); } while (0)
#include <linux/aio_abi.h>
static inline struct kiocb *list_kiocb(struct list_head *h)
{
return list_entry(h, struct kiocb, ki_list);
}
/* for sysctl: */
extern unsigned aio_max_nr, aio_max_size, aio_max_pinned;
#endif /* __LINUX__AIO_H */
/* 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 */
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#define ESERVERFAULT 526 /* An untranslatable error occurred */ #define ESERVERFAULT 526 /* An untranslatable error occurred */
#define EBADTYPE 527 /* Type not supported by server */ #define EBADTYPE 527 /* Type not supported by server */
#define EJUKEBOX 528 /* Request initiated, but will not complete before timeout */ #define EJUKEBOX 528 /* Request initiated, but will not complete before timeout */
#define EIOCBQUEUED 529 /* iocb queued, will get completion event */
#endif #endif
......
...@@ -740,11 +740,14 @@ struct block_device_operations { ...@@ -740,11 +740,14 @@ struct block_device_operations {
* read, write, poll, fsync, readv, writev can be called * read, write, poll, fsync, readv, writev can be called
* without the big kernel lock held in all filesystems. * without the big kernel lock held in all filesystems.
*/ */
struct kiocb;
struct file_operations { struct file_operations {
struct module *owner; struct module *owner;
loff_t (*llseek) (struct file *, loff_t, int); loff_t (*llseek) (struct file *, loff_t, int);
ssize_t (*read) (struct file *, char *, size_t, loff_t *); ssize_t (*read) (struct file *, char *, size_t, loff_t *);
ssize_t (*aio_read) (struct kiocb *, char *, size_t, loff_t);
ssize_t (*write) (struct file *, const char *, size_t, loff_t *); ssize_t (*write) (struct file *, const char *, size_t, loff_t *);
ssize_t (*aio_write) (struct kiocb *, char *, size_t, loff_t);
int (*readdir) (struct file *, void *, filldir_t); int (*readdir) (struct file *, void *, filldir_t);
unsigned int (*poll) (struct file *, struct poll_table_struct *); unsigned int (*poll) (struct file *, struct poll_table_struct *);
int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long); int (*ioctl) (struct inode *, struct file *, unsigned int, unsigned long);
...@@ -753,6 +756,7 @@ struct file_operations { ...@@ -753,6 +756,7 @@ struct file_operations {
int (*flush) (struct file *); int (*flush) (struct file *);
int (*release) (struct inode *, struct file *); int (*release) (struct inode *, struct file *);
int (*fsync) (struct file *, struct dentry *, int datasync); int (*fsync) (struct file *, struct dentry *, int datasync);
int (*aio_fsync) (struct kiocb *, int datasync);
int (*fasync) (int, struct file *, int); int (*fasync) (int, struct file *, int);
int (*lock) (struct file *, int, struct file_lock *); int (*lock) (struct file *, int, struct file_lock *);
ssize_t (*readv) (struct file *, const struct iovec *, unsigned long, loff_t *); ssize_t (*readv) (struct file *, const struct iovec *, unsigned long, loff_t *);
......
...@@ -170,6 +170,7 @@ struct namespace; ...@@ -170,6 +170,7 @@ struct namespace;
/* Maximum number of active map areas.. This is a random (large) number */ /* Maximum number of active map areas.. This is a random (large) number */
#define MAX_MAP_COUNT (65536) #define MAX_MAP_COUNT (65536)
struct kioctx;
struct mm_struct { struct mm_struct {
struct vm_area_struct * mmap; /* list of VMAs */ struct vm_area_struct * mmap; /* list of VMAs */
rb_root_t mm_rb; rb_root_t mm_rb;
...@@ -198,6 +199,10 @@ struct mm_struct { ...@@ -198,6 +199,10 @@ struct mm_struct {
/* Architecture-specific MM context */ /* Architecture-specific MM context */
mm_context_t context; mm_context_t context;
/* aio bits */
rwlock_t ioctx_list_lock;
struct kioctx *ioctx_list;
}; };
extern int mmlist_nr; extern int mmlist_nr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment