From: WU Fengguang <wfg@mail.ustc.edu.cn>
- In sys_fadvise64_64(): if the start and/or end offsets do not fall on
page boundaries, preserve the partial pages. The thinking here is that it
is better to preserve needed memory than to not shoot down unneeded memory.
- In invalidate_mapping_pages(): we were invalidating an entire pagevec's
worth of pages each time around, even if that went beyond the part of the
file which the caller asked to be invalidated. Fix that up.
case POSIX_FADV_DONTNEED:
if (!bdi_write_congested(mapping->backing_dev_info))
filemap_flush(mapping);
- start_index = offset >> PAGE_CACHE_SHIFT;
- end_index = (offset + len + PAGE_CACHE_SIZE - 1) >>
- PAGE_CACHE_SHIFT;
+ start_index = (offset + PAGE_CACHE_SIZE-1) >> PAGE_CACHE_SHIFT;
+ end_index = ((offset + len) >> PAGE_CACHE_SHIFT) - 1;
invalidate_mapping_pages(mapping, start_index, end_index);
break;
default:
ret += invalidate_complete_page(mapping, page);
unlock:
unlock_page(page);
+ if (next > end)
+ break;
}
pagevec_release(&pvec);
cond_resched();