<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">
From: Daniel McNeil &lt;daniel@osdl.org&gt;

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.



 fs/aio.c |   24 +++++++++++++++---------
 1 files changed, 15 insertions(+), 9 deletions(-)

diff -puN fs/aio.c~aio-dio-no-readahead fs/aio.c
--- 25/fs/aio.c~aio-dio-no-readahead	2003-08-30 15:42:30.000000000 -0700
+++ 25-akpm/fs/aio.c	2003-08-30 15:42:30.000000000 -0700
@@ -1353,15 +1353,21 @@ ssize_t aio_setup_iocb(struct kiocb *kio
 			break;
 		ret = -EINVAL;
 		if (file-&gt;f_op-&gt;aio_read) {
-			struct address_space *mapping =
-				file-&gt;f_dentry-&gt;d_inode-&gt;i_mapping;
-			unsigned long index = kiocb-&gt;ki_pos &gt;&gt; PAGE_CACHE_SHIFT;
-			unsigned long end = (kiocb-&gt;ki_pos + kiocb-&gt;ki_left)
-				&gt;&gt; PAGE_CACHE_SHIFT;
-
-			for (; index &lt; end; index++) {
-				page_cache_readahead(mapping, &amp;file-&gt;f_ra,
-							file, index);
+			/*
+			 * Do not do readahead for DIRECT i/o
+			 */
+			if (!(file-&gt;f_flags &amp; O_DIRECT)) {
+				struct address_space *mapping;
+				unsigned long index;
+				unsigned long end;
+
+				mapping = file-&gt;f_dentry-&gt;d_inode-&gt;i_mapping;
+				index = kiocb-&gt;ki_pos &gt;&gt; PAGE_CACHE_SHIFT;
+				end = (kiocb-&gt;ki_pos + kiocb-&gt;ki_left) &gt;&gt;
+						PAGE_CACHE_SHIFT;
+				for (; index &lt; end; index++)
+					page_cache_readahead(mapping,
+						&amp;file-&gt;f_ra, file, index);
 			}
 			kiocb-&gt;ki_retry = aio_pread;
 		}

_
</pre></body></html>