Commit 3745aa40 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] fadvise(POSIX_FADV_DONTNEED) fixups

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.
parent ddfd8f8d
......@@ -65,9 +65,8 @@ asmlinkage long sys_fadvise64_64(int fd, loff_t offset, loff_t len, int advice)
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:
......
......@@ -219,6 +219,8 @@ unsigned long invalidate_mapping_pages(struct address_space *mapping,
ret += invalidate_complete_page(mapping, page);
unlock:
unlock_page(page);
if (next > end)
break;
}
pagevec_release(&pvec);
cond_resched();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment