aboutsummaryrefslogtreecommitdiffstats
path: root/mm/filemap.c
diff options
context:
space:
mode:
Diffstat (limited to 'mm/filemap.c')
-rw-r--r--mm/filemap.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/mm/filemap.c b/mm/filemap.c
index cbea95a25283..07f5b77114a3 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -868,6 +868,7 @@ void do_generic_mapping_read(struct address_space *mapping,
868 unsigned long last_index; 868 unsigned long last_index;
869 unsigned long next_index; 869 unsigned long next_index;
870 unsigned long prev_index; 870 unsigned long prev_index;
871 unsigned int prev_offset;
871 loff_t isize; 872 loff_t isize;
872 struct page *cached_page; 873 struct page *cached_page;
873 int error; 874 int error;
@@ -877,6 +878,7 @@ void do_generic_mapping_read(struct address_space *mapping,
877 index = *ppos >> PAGE_CACHE_SHIFT; 878 index = *ppos >> PAGE_CACHE_SHIFT;
878 next_index = index; 879 next_index = index;
879 prev_index = ra.prev_page; 880 prev_index = ra.prev_page;
881 prev_offset = ra.offset;
880 last_index = (*ppos + desc->count + PAGE_CACHE_SIZE-1) >> PAGE_CACHE_SHIFT; 882 last_index = (*ppos + desc->count + PAGE_CACHE_SIZE-1) >> PAGE_CACHE_SHIFT;
881 offset = *ppos & ~PAGE_CACHE_MASK; 883 offset = *ppos & ~PAGE_CACHE_MASK;
882 884
@@ -924,10 +926,10 @@ page_ok:
924 flush_dcache_page(page); 926 flush_dcache_page(page);
925 927
926 /* 928 /*
927 * When (part of) the same page is read multiple times 929 * When a sequential read accesses a page several times,
928 * in succession, only mark it as accessed the first time. 930 * only mark it as accessed the first time.
929 */ 931 */
930 if (prev_index != index) 932 if (prev_index != index || offset != prev_offset)
931 mark_page_accessed(page); 933 mark_page_accessed(page);
932 prev_index = index; 934 prev_index = index;
933 935
@@ -945,6 +947,7 @@ page_ok:
945 offset += ret; 947 offset += ret;
946 index += offset >> PAGE_CACHE_SHIFT; 948 index += offset >> PAGE_CACHE_SHIFT;
947 offset &= ~PAGE_CACHE_MASK; 949 offset &= ~PAGE_CACHE_MASK;
950 prev_offset = ra.offset = offset;
948 951
949 page_cache_release(page); 952 page_cache_release(page);
950 if (ret == nr && desc->count) 953 if (ret == nr && desc->count)