Take hash recalculation into do_lookup()
[linux-2.6-block.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>
b9d128f1 18#include <linux/backing-dev.h>
027445c3 19#include <linux/uio.h>
1da177e4
LT
20
21#define DEBUG 0
22
23#include <linux/sched.h>
24#include <linux/fs.h>
25#include <linux/file.h>
26#include <linux/mm.h>
27#include <linux/mman.h>
3d2d827f 28#include <linux/mmu_context.h>
1da177e4
LT
29#include <linux/slab.h>
30#include <linux/timer.h>
31#include <linux/aio.h>
32#include <linux/highmem.h>
33#include <linux/workqueue.h>
34#include <linux/security.h>
9c3060be 35#include <linux/eventfd.h>
cfb1e33e
JM
36#include <linux/blkdev.h>
37#include <linux/mempool.h>
38#include <linux/hash.h>
1da177e4
LT
39
40#include <asm/kmap_types.h>
41#include <asm/uaccess.h>
1da177e4
LT
42
43#if DEBUG > 1
44#define dprintk printk
45#else
46#define dprintk(x...) do { ; } while (0)
47#endif
48
1da177e4 49/*------ sysctl variables----*/
d55b5fda
ZB
50static DEFINE_SPINLOCK(aio_nr_lock);
51unsigned long aio_nr; /* current system wide number of aio requests */
52unsigned long aio_max_nr = 0x10000; /* system wide maximum number of aio requests */
1da177e4
LT
53/*----end sysctl variables---*/
54
e18b890b
CL
55static struct kmem_cache *kiocb_cachep;
56static struct kmem_cache *kioctx_cachep;
1da177e4
LT
57
58static struct workqueue_struct *aio_wq;
59
60/* Used for rare fput completion. */
65f27f38
DH
61static void aio_fput_routine(struct work_struct *);
62static DECLARE_WORK(fput_work, aio_fput_routine);
1da177e4
LT
63
64static DEFINE_SPINLOCK(fput_lock);
25ee7e38 65static LIST_HEAD(fput_head);
1da177e4 66
cfb1e33e
JM
67#define AIO_BATCH_HASH_BITS 3 /* allocated on-stack, so don't go crazy */
68#define AIO_BATCH_HASH_SIZE (1 << AIO_BATCH_HASH_BITS)
69struct aio_batch_entry {
70 struct hlist_node list;
71 struct address_space *mapping;
72};
73mempool_t *abe_pool;
74
65f27f38 75static void aio_kick_handler(struct work_struct *);