X-Git-Url: http://drtracing.org/?a=blobdiff_plain;f=mm%2Ffadvise.c;h=6c707bfe02fde002feae9ea2fab3fc9647c3baa0;hb=89c7cb2cad5e5e3675df3ba1c12fe2f64dc691d6;hp=b8024fa7101d9a8ff625606de973b9b670d0ecf4;hpb=ecc5fbd5ef472a4c659dc56a5739b3f041c0530c;p=deliverable%2Flinux.git diff --git a/mm/fadvise.c b/mm/fadvise.c index b8024fa7101d..6c707bfe02fd 100644 --- a/mm/fadvise.c +++ b/mm/fadvise.c @@ -126,6 +126,17 @@ SYSCALL_DEFINE4(fadvise64_64, int, fd, loff_t, offset, loff_t, len, int, advice) */ start_index = (offset+(PAGE_SIZE-1)) >> PAGE_SHIFT; end_index = (endbyte >> PAGE_SHIFT); + if ((endbyte & ~PAGE_MASK) != ~PAGE_MASK) { + /* First page is tricky as 0 - 1 = -1, but pgoff_t + * is unsigned, so the end_index >= start_index + * check below would be true and we'll discard the whole + * file cache which is not what was asked. + */ + if (end_index == 0) + break; + + end_index--; + } if (end_index >= start_index) { unsigned long count = invalidate_mapping_pages(mapping,