diff options
author | Jan Kara <jack@suse.cz> | 2007-05-06 17:49:25 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-05-07 15:12:52 -0400 |
commit | ec0f16372277052a29a6c17527c6cae5e898b3fd (patch) | |
tree | 35636edac6ed01baf301f3aca96f090caae82c9d /mm/readahead.c | |
parent | b813e931b4c8235bb42e301096ea97dbdee3e8fe (diff) |
readahead: improve heuristic detecting sequential reads
Introduce ra.offset and store in it an offset where the previous read
ended. This way we can detect whether reads are really sequential (and
thus we should not mark the page as accessed repeatedly) or whether they
are random and just happen to be in the same page (and the page should
really be marked accessed again).
Signed-off-by: Jan Kara <jack@suse.cz>
Acked-by: Nick Piggin <nickpiggin@yahoo.com.au>
Cc: WU Fengguang <wfg@mail.ustc.edu.cn>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/readahead.c')
-rw-r--r-- | mm/readahead.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/mm/readahead.c b/mm/readahead.c index 93d9ee692fd8..0a6fed9d365c 100644 --- a/mm/readahead.c +++ b/mm/readahead.c | |||
@@ -207,6 +207,8 @@ out: | |||
207 | * If page_cache_readahead sees that it is again being called for | 207 | * If page_cache_readahead sees that it is again being called for |
208 | * a page which it just looked at, it can return immediately without | 208 | * a page which it just looked at, it can return immediately without |
209 | * making any state changes. | 209 | * making any state changes. |
210 | * offset: Offset in the prev_page where the last read ended - used for | ||
211 | * detection of sequential file reading. | ||
210 | * ahead_start, | 212 | * ahead_start, |
211 | * ahead_size: Together, these form the "ahead window". | 213 | * ahead_size: Together, these form the "ahead window". |
212 | * ra_pages: The externally controlled max readahead for this fd. | 214 | * ra_pages: The externally controlled max readahead for this fd. |
@@ -473,6 +475,7 @@ page_cache_readahead(struct address_space *mapping, struct file_ra_state *ra, | |||
473 | /* Note that prev_page == -1 if it is a first read */ | 475 | /* Note that prev_page == -1 if it is a first read */ |
474 | sequential = (offset == ra->prev_page + 1); | 476 | sequential = (offset == ra->prev_page + 1); |
475 | ra->prev_page = offset; | 477 | ra->prev_page = offset; |
478 | ra->offset = 0; | ||
476 | 479 | ||
477 | max = get_max_readahead(ra); | 480 | max = get_max_readahead(ra); |
478 | newsize = min(req_size, max); | 481 | newsize = min(req_size, max); |