diff options
author | Hugh Dickins <hughd@google.com> | 2011-07-25 20:12:25 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-07-25 23:57:10 -0400 |
commit | b85e0effd3dcbf9118b896232f59526ab1a39a74 (patch) | |
tree | 32200b2e4052d50d4eb1771e555eaf66d7c4cfc8 /mm/filemap.c | |
parent | 8a549bea51138be2126a2cc6aabe8f17ef66b79b (diff) |
mm: consistent truncate and invalidate loops
Make the pagevec_lookup loops in truncate_inode_pages_range(),
invalidate_mapping_pages() and invalidate_inode_pages2_range() more
consistent with each other.
They were relying upon page->index of an unlocked page, but apologizing
for it: accept it, embrace it, add comments and WARN_ONs, and simplify the
index handling.
invalidate_inode_pages2_range() had special handling for a wrapped
page->index + 1 = 0 case; but MAX_LFS_FILESIZE doesn't let us anywhere
near there, and a corrupt page->index in the radix_tree could cause more
trouble than that would catch. Remove that wrapped handling.
invalidate_inode_pages2_range() uses min() to limit the pagevec_lookup
when near the end of the range: copy that into the other two, although
it's less useful than you might think (it limits the use of the buffer,
rather than the indices looked up).
Signed-off-by: Hugh Dickins <hughd@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/filemap.c')
-rw-r--r-- | mm/filemap.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/mm/filemap.c b/mm/filemap.c index 2780be4bd493..10a171113273 100644 --- a/mm/filemap.c +++ b/mm/filemap.c | |||
@@ -128,6 +128,7 @@ void __delete_from_page_cache(struct page *page) | |||
128 | 128 | ||
129 | radix_tree_delete(&mapping->page_tree, page->index); | 129 | radix_tree_delete(&mapping->page_tree, page->index); |
130 | page->mapping = NULL; | 130 | page->mapping = NULL; |
131 | /* Leave page->index set: truncation lookup relies upon it */ | ||
131 | mapping->nrpages--; | 132 | mapping->nrpages--; |
132 | __dec_zone_page_state(page, NR_FILE_PAGES); | 133 | __dec_zone_page_state(page, NR_FILE_PAGES); |
133 | if (PageSwapBacked(page)) | 134 | if (PageSwapBacked(page)) |
@@ -483,6 +484,7 @@ int add_to_page_cache_locked(struct page *page, struct address_space *mapping, | |||
483 | spin_unlock_irq(&mapping->tree_lock); | 484 | spin_unlock_irq(&mapping->tree_lock); |
484 | } else { | 485 | } else { |
485 | page->mapping = NULL; | 486 | page->mapping = NULL; |
487 | /* Leave page->index set: truncation relies upon it */ | ||
486 | spin_unlock_irq(&mapping->tree_lock); | 488 | spin_unlock_irq(&mapping->tree_lock); |
487 | mem_cgroup_uncharge_cache_page(page); | 489 | mem_cgroup_uncharge_cache_page(page); |
488 | page_cache_release(page); | 490 | page_cache_release(page); |