
From: Miquel van Smoorenburg <miquels@cistron.nl>

I just discovered there's a thinko in the mark-page-accessed change in
do_generic_mapping_read() in 2.6.11-rc1.  ra.prev_page is compared to index
to see if we read from this page before - except that prev_page is actually
set to the recent page or even a page in front of the current page.

So we should store ra.prev_page in a seperate variable at the start of
do_generic_mapping_read().

Signed-off-by: Andrew Morton <akpm@osdl.org>
---

 25-akpm/mm/filemap.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletion(-)

diff -puN mm/filemap.c~mark-page-accessed-in-filemapc-not-quite-right mm/filemap.c
--- 25/mm/filemap.c~mark-page-accessed-in-filemapc-not-quite-right	Wed Jan 12 16:37:16 2005
+++ 25-akpm/mm/filemap.c	Wed Jan 12 16:37:16 2005
@@ -693,6 +693,7 @@ void do_generic_mapping_read(struct addr
 	unsigned long offset;
 	unsigned long req_size;
 	unsigned long next_index;
+	unsigned long prev_index;
 	loff_t isize;
 	struct page *cached_page;
 	int error;
@@ -701,6 +702,7 @@ void do_generic_mapping_read(struct addr
 	cached_page = NULL;
 	index = *ppos >> PAGE_CACHE_SHIFT;
 	next_index = index;
+	prev_index = ra.prev_page;
 	req_size = (desc->count + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
 	offset = *ppos & ~PAGE_CACHE_MASK;
 
@@ -754,8 +756,9 @@ page_ok:
 		 * When (part of) the same page is read multiple times
 		 * in succession, only mark it as accessed the first time.
 		 */
-		if (ra.prev_page != index)
+		if (prev_index != index)
 			mark_page_accessed(page);
+		prev_index = index;
 
 		/*
 		 * Ok, we have the page, and it's up-to-date, so
_
