From: Daniel McNeil More testing on AIO with O_DIRECT and /dev/raw/. Doing AIO reads was using a lot more cpu time than using dd on the raw partition even with the io_queue_wait patch. Found out that aio is doing readahead even for O_DIRECT. Here's a patch that fixes it. 25-akpm/fs/aio.c | 22 ++++++++++++++-------- 1 files changed, 14 insertions(+), 8 deletions(-) diff -puN fs/aio.c~aio-dio-no-readahead fs/aio.c --- 25/fs/aio.c~aio-dio-no-readahead Tue Jul 8 16:07:33 2003 +++ 25-akpm/fs/aio.c Tue Jul 8 16:07:33 2003 @@ -1352,15 +1352,21 @@ ssize_t aio_setup_iocb(struct kiocb *kio break; ret = -EINVAL; if (file->f_op->aio_read) { - struct address_space *mapping = - file->f_dentry->d_inode->i_mapping; - unsigned long index = kiocb->ki_pos >> PAGE_CACHE_SHIFT; - unsigned long end = (kiocb->ki_pos + kiocb->ki_left) - >> PAGE_CACHE_SHIFT; + /* + * Do not do readahead for DIRECT i/o + */ + if (!(file->f_flags & O_DIRECT)) { + struct address_space *mapping; + unsigned long index; + unsigned long end; - for (; index < end; index++) { - page_cache_readahead(mapping, &file->f_ra, - file, index); + mapping = file->f_dentry->d_inode->i_mapping; + index = kiocb->ki_pos >> PAGE_CACHE_SHIFT; + end = (kiocb->ki_pos + kiocb->ki_left) >> + PAGE_CACHE_SHIFT; + for (; index < end; index++) + page_cache_readahead(mapping, + &file->f_ra, file, index); } kiocb->ki_retry = aio_pread; } _