diff options
author | Miklos Szeredi <miklos@szeredi.hu> | 2004-07-28 09:03:33 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-07-28 09:03:33 -0700 |
commit | 1dbfb17ea5b5a511290e3783b9d920f6fdb83277 (patch) | |
tree | 8a136bd50be9b33bf2545cd408ec16bb5fc78c8b /mm | |
parent | 2513f65439ed5a26f2331dd4d70e8685db51ac58 (diff) | |
download | history-1dbfb17ea5b5a511290e3783b9d920f6fdb83277.tar.gz |
[PATCH] fix readahead breakage for sequential after random reads
Current readahead logic is broken when a random read pattern is followed by
a long sequential read. The cause is that on a window miss ra->next_size
is set to ra->average, but ra->average is only updated at the end of a
sequence, so window size will remain 1 until the end of the sequential
read.
This patch fixes this by taking the current sequence length into account
(code taken from towards end of page_cache_readahead()), and also setting
ra->average to a decent value in handle_ra_miss() when sequential access is
detected.
Signed-off-by: Miklos Szeredi <miklos@szeredi.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/readahead.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/mm/readahead.c b/mm/readahead.c index 97239562622d41..b7f8cd8ea9ca58 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -470,7 +470,11 @@ do_io: * pages shall be accessed in the next * current window. */ - ra->next_size = min(ra->average , (unsigned long)max); + average = ra->average; + if (ra->serial_cnt > average) + average = (ra->serial_cnt + ra->average + 1) / 2; + + ra->next_size = min(average , (unsigned long)max); } ra->start = offset; ra->size = ra->next_size; @@ -552,6 +556,7 @@ void handle_ra_miss(struct address_space *mapping, ra->size = max; ra->ahead_start = 0; ra->ahead_size = 0; + ra->average = max / 2; } } ra->prev_page = offset; |