]> bbs.cooldavid.org Git - net-next-2.6.git/blame - fs/aio.c
drbd: fix in_flight rw indexing
[net-next-2.6.git] / fs / aio.c
CommitLineData
1da177e4
LT
1/*
2 * An async IO implementation for Linux
3 * Written by Benjamin LaHaise <bcrl@kvack.org>
4 *
5 * Implements an efficient asynchronous io interface.
6 *
7 * Copyright 2000, 2001, 2002 Red Hat, Inc. All Rights Reserved.
8 *
9 * See ../COPYING for licensing terms.
10 */
11#include <linux/kernel.h>
12#include <linux/init.h>
13#include <linux/errno.h>
14#include <linux/time.h>
15#include <linux/aio_abi.h>
16#include <linux/module.h>
17#include <linux/syscalls.h>
027445c3 18#include <linux/uio.h>
1da177e4
LT
19
20#define DEBUG 0
21
22#include <linux/sched.h>
23#include <linux/fs.h>
24#include <linux/file.h>
25#include <linux/mm.h>
26#include <linux/mman.h>
3d2d827f 27#include <linux/mmu_context.h>
1da177e4
LT
28#include <linux/slab.h>
29#include <linux/timer.h>
30#include <linux/aio.h>
31#include <linux/highmem.h>
32#include <linux/workqueue.h>
33#include <linux/security.h>
9c3060be 34#include <linux/eventfd.h>
cfb1e33e
JM
35#include <linux/blkdev.h>
36#include <linux/mempool.h>
37#include <linux/hash.h>
1da177e4
LT
38
39#include <asm/kmap_types.h>
40#include <asm/uaccess.h>
1da177e4
LT
41
42#if DEBUG > 1
43#define dprintk printk
44#else
45#define dprintk(x...) do { ; } while (0)
46#endif
47
1da177e4 48/*------ sysctl variables----*/
d55b5fda
ZB
49static DEFINE_SPINLOCK(aio_nr_lock);
50unsigned long aio_nr; /* current system wide number of aio requests */
51unsigned long aio_max_nr = 0x10000; /* system wide maximum number of aio requests */
1da177e4
LT
52/*----end sysctl variables---*/
53
e18b890b
CL
54static struct kmem_cache *kiocb_cachep;
55static struct kmem_cache *kioctx_cachep;
1da177e4
LT
56
57static struct workqueue_struct *aio_wq;
58
59/* Used for rare fput completion. */
65f27f38
DH
60static void aio_fput_routine(struct work_struct *);
61static DECLARE_WORK(fput_work, aio_fput_routine);
1da177e4
LT
62
63static DEFINE_SPINLOCK(fput_lock);
25ee7e38 64static LIST_HEAD(fput_head);
1da177e4 65
cfb1e33e
JM
66#define AIO_BATCH_HASH_BITS 3 /* allocated on-stack, so don't go crazy */
67#define AIO_BATCH_HASH_SIZE (1 << AIO_BATCH_HASH_BITS)
68struct aio_batch_entry {
69 struct hlist_node list;
70 struct address_space *mapping;
71};
72mempool_t *abe_pool;
73
65f27f38 74static void aio_kick_handler(struct work_struct *);