Remove the hardwired pagefault readaround distance in filemap_nopage() and
use the per-file readahead setting.

The main reason for this is in fact laptop-mode.  If you want to prevent the
disk from spinning up then you want all of your application's pages tp be
pulled into memory in one hit.  Otherwise the disk will spin up each time you
use a new part of whatever application(s) you are running.



---

 25-akpm/mm/filemap.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)

diff -puN mm/filemap.c~tunable-pagefault-readaround mm/filemap.c
--- 25/mm/filemap.c~tunable-pagefault-readaround	2004-03-26 01:11:59.041273704 -0800
+++ 25-akpm/mm/filemap.c	2004-03-26 01:32:26.047740368 -0800
@@ -1008,7 +1008,6 @@ static int fastcall page_cache_read(stru
 	return error == -EEXIST ? 0 : error;
 }
 
-#define MMAP_READAROUND (16UL)
 #define MMAP_LOTSAMISS  (100)
 
 /*
@@ -1064,6 +1063,8 @@ retry_all:
 retry_find:
 	page = find_get_page(mapping, pgoff);
 	if (!page) {
+		unsigned long ra_pages;
+
 		if (VM_SequentialReadHint(area)) {
 			handle_ra_miss(mapping, ra, pgoff);
 			goto no_cached_page;
@@ -1086,8 +1087,15 @@ retry_find:
 			inc_page_state(pgmajfault);
 		}
 		did_readaround = 1;
-		do_page_cache_readahead(mapping, file,
-				pgoff & ~(MMAP_READAROUND-1), MMAP_READAROUND);
+		ra_pages = max_sane_readahead(file->f_ra.ra_pages);
+		if (ra_pages) {
+			long start;
+
+			start = pgoff - ra_pages / 2;
+			if (pgoff < 0)
+				pgoff = 0;
+			do_page_cache_readahead(mapping, file, pgoff, ra_pages);
+		}
 		goto retry_find;
 	}
 

_