diff options
author | Fengguang Wu <wfg@mail.ustc.edu.cn> | 2007-07-19 04:48:02 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-07-19 13:04:44 -0400 |
commit | 3ea89ee86a82e9fbde37018d9b9e92a552e5fd13 (patch) | |
tree | 5fef7216ef39d66684754e4aadf368ce9adfd72e /mm/filemap.c | |
parent | 122a21d11cbfda6d1e33cbc8ae9e4c4ee2f1886e (diff) |
readahead: convert filemap invocations
Convert filemap reads to use on-demand readahead.
The new call scheme is to
- call readahead on non-cached page
- call readahead on look-ahead page
- update prev_index when finished with the read request
Signed-off-by: Fengguang Wu <wfg@mail.ustc.edu.cn>
Cc: Steven Pratt <slpratt@austin.ibm.com>
Cc: Ram Pai <linuxram@us.ibm.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/filemap.c')
-rw-r--r-- | mm/filemap.c | 51 |
1 files changed, 31 insertions, 20 deletions
diff --git a/mm/filemap.c b/mm/filemap.c index 4fd9e3f0f48a..5eb0a6b9d607 100644 --- a/mm/filemap.c +++ b/mm/filemap.c | |||
@@ -891,15 +891,20 @@ void do_generic_mapping_read(struct address_space *mapping, | |||
891 | unsigned long nr, ret; | 891 | unsigned long nr, ret; |
892 | 892 | ||
893 | cond_resched(); | 893 | cond_resched(); |
894 | if (index == next_index) | ||
895 | next_index = page_cache_readahead(mapping, &ra, filp, | ||
896 | index, last_index - index); | ||
897 | |||
898 | find_page: | 894 | find_page: |
899 | page = find_get_page(mapping, index); | 895 | page = find_get_page(mapping, index); |
900 | if (unlikely(page == NULL)) { | 896 | if (!page) { |
901 | handle_ra_miss(mapping, &ra, index); | 897 | page_cache_readahead_ondemand(mapping, |
902 | goto no_cached_page; | 898 | &ra, filp, page, |
899 | index, last_index - index); | ||
900 | page = find_get_page(mapping, index); | ||
901 | if (unlikely(page == NULL)) | ||
902 | goto no_cached_page; | ||
903 | } | ||
904 | if (PageReadahead(page)) { | ||
905 | page_cache_readahead_ondemand(mapping, | ||
906 | &ra, filp, page, | ||
907 | index, last_index - index); | ||
903 | } | 908 | } |
904 | if (!PageUptodate(page)) | 909 | if (!PageUptodate(page)) |
905 | goto page_not_up_to_date; | 910 | goto page_not_up_to_date; |
@@ -1051,6 +1056,7 @@ no_cached_page: | |||
1051 | 1056 | ||
1052 | out: | 1057 | out: |
1053 | *_ra = ra; | 1058 | *_ra = ra; |
1059 | _ra->prev_index = prev_index; | ||
1054 | 1060 | ||
1055 | *ppos = ((loff_t) index << PAGE_CACHE_SHIFT) + offset; | 1061 | *ppos = ((loff_t) index << PAGE_CACHE_SHIFT) + offset; |
1056 | if (cached_page) | 1062 | if (cached_page) |
@@ -1333,26 +1339,30 @@ int filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf) | |||
1333 | goto no_cached_page; | 1339 | goto no_cached_page; |
1334 | 1340 | ||
1335 | /* | 1341 | /* |
1336 | * The readahead code wants to be told about each and every page | ||
1337 | * so it can build and shrink its windows appropriately | ||
1338 | * | ||
1339 | * For sequential accesses, we use the generic readahead logic. | ||
1340 | */ | ||
1341 | if (VM_SequentialReadHint(vma)) | ||
1342 | page_cache_readahead(mapping, ra, file, vmf->pgoff, 1); | ||
1343 | |||
1344 | /* | ||
1345 | * Do we have something in the page cache already? | 1342 | * Do we have something in the page cache already? |
1346 | */ | 1343 | */ |
1347 | retry_find: | 1344 | retry_find: |
1348 | page = find_lock_page(mapping, vmf->pgoff); | 1345 | page = find_lock_page(mapping, vmf->pgoff); |
1346 | /* | ||
1347 | * For sequential accesses, we use the generic readahead logic. | ||
1348 | */ | ||
1349 | if (VM_SequentialReadHint(vma)) { | ||
1350 | if (!page) { | ||
1351 | page_cache_readahead_ondemand(mapping, ra, file, page, | ||
1352 | vmf->pgoff, 1); | ||
1353 | page = find_lock_page(mapping, vmf->pgoff); | ||
1354 | if (!page) | ||
1355 | goto no_cached_page; | ||
1356 | } | ||
1357 | if (PageReadahead(page)) { | ||
1358 | page_cache_readahead_ondemand(mapping, ra, file, page, | ||
1359 | vmf->pgoff, 1); | ||
1360 | } | ||
1361 | } | ||
1362 | |||
1349 | if (!page) { | 1363 | if (!page) { |
1350 | unsigned long ra_pages; | 1364 | unsigned long ra_pages; |
1351 | 1365 | ||
1352 | if (VM_SequentialReadHint(vma)) { | ||
1353 | handle_ra_miss(mapping, ra, vmf->pgoff); | ||
1354 | goto no_cached_page; | ||
1355 | } | ||
1356 | ra->mmap_miss++; | 1366 | ra->mmap_miss++; |
1357 | 1367 | ||
1358 | /* | 1368 | /* |
@@ -1405,6 +1415,7 @@ retry_find: | |||
1405 | * Found the page and have a reference on it. | 1415 | * Found the page and have a reference on it. |
1406 | */ | 1416 | */ |
1407 | mark_page_accessed(page); | 1417 | mark_page_accessed(page); |
1418 | ra->prev_index = page->index; | ||
1408 | vmf->page = page; | 1419 | vmf->page = page; |
1409 | return ret | VM_FAULT_LOCKED; | 1420 | return ret | VM_FAULT_LOCKED; |
1410 | 1421 | ||