aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorAndrew Morton <akpm@osdl.org>2004-05-10 00:05:18 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2004-05-10 00:05:18 -0700
commit2a12ed0ef2685626ad90736243747c9167535d82 (patch)
tree4d8fe0da96d23c7bb81b4deb47533917ace1e6ba /mm
parent6096781056dd1af176317798bbdafcd8c8c8a282 (diff)
downloadhistory-2a12ed0ef2685626ad90736243747c9167535d82.tar.gz
[PATCH] readahead: keep file->f_ra sane
When two threads are simultaneously pread()ing from the same fd (which is a legitimate thing to do), the readahead code thinks that a huge amount of seeking is happening and shrinks the window, damaging performance a lot. I don't see a sane way to avoid this within the readahead code, so take a private copy of the readahead state and restore it prior to returning from the read.
Diffstat (limited to 'mm')
-rw-r--r--mm/filemap.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/mm/filemap.c b/mm/filemap.c
index 1abe874e88e132..b7c98868c76a48 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -606,7 +606,7 @@ EXPORT_SYMBOL(grab_cache_page_nowait);
* - note the struct file * is only passed for the use of readpage
*/
void do_generic_mapping_read(struct address_space *mapping,
- struct file_ra_state *ra,
+ struct file_ra_state *_ra,
struct file * filp,
loff_t *ppos,
read_descriptor_t * desc,
@@ -616,6 +616,7 @@ void do_generic_mapping_read(struct address_space *mapping,
unsigned long index, offset;
struct page *cached_page;
int error;
+ struct file_ra_state ra = *_ra;
cached_page = NULL;
index = *ppos >> PAGE_CACHE_SHIFT;
@@ -638,13 +639,13 @@ void do_generic_mapping_read(struct address_space *mapping,
}
cond_resched();
- page_cache_readahead(mapping, ra, filp, index);
+ page_cache_readahead(mapping, &ra, filp, index);
nr = nr - offset;
find_page:
page = find_get_page(mapping, index);
if (unlikely(page == NULL)) {
- handle_ra_miss(mapping, ra, index);
+ handle_ra_miss(mapping, &ra, index);
goto no_cached_page;
}
if (!PageUptodate(page))
@@ -746,6 +747,8 @@ no_cached_page:
goto readpage;
}
+ *_ra = ra;
+
*ppos = ((loff_t) index << PAGE_CACHE_SHIFT) + offset;
if (cached_page)
page_cache_release(cached_page);