aboutsummaryrefslogtreecommitdiffstats
path: root/mm/truncate.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-04-14 19:49:17 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-04-14 19:49:17 -0400
commit1dcf58d6e6e6eb7ec10e9abc56887b040205b06f (patch)
treec03e7a25ef13eea62f1547914a76e5c68f3f4c28 /mm/truncate.c
parent80dcc31fbe55932ac9204daee5f2ebc0c49b6da3 (diff)
parente4b0db72be2487bae0e3251c22f82c104f7c1cfd (diff)
Merge branch 'akpm' (patches from Andrew)
Merge first patchbomb from Andrew Morton: - arch/sh updates - ocfs2 updates - kernel/watchdog feature - about half of mm/ * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (122 commits) Documentation: update arch list in the 'memtest' entry Kconfig: memtest: update number of test patterns up to 17 arm: add support for memtest arm64: add support for memtest memtest: use phys_addr_t for physical addresses mm: move memtest under mm mm, hugetlb: abort __get_user_pages if current has been oom killed mm, mempool: do not allow atomic resizing memcg: print cgroup information when system panics due to panic_on_oom mm: numa: remove migrate_ratelimited mm: fold arch_randomize_brk into ARCH_HAS_ELF_RANDOMIZE mm: split ET_DYN ASLR from mmap ASLR s390: redefine randomize_et_dyn for ELF_ET_DYN_BASE mm: expose arch_mmap_rnd when available s390: standardize mmap_rnd() usage powerpc: standardize mmap_rnd() usage mips: extract logic for mmap_rnd() arm64: standardize mmap_rnd() usage x86: standardize mmap_rnd() usage arm: factor out mmap ASLR into mmap_rnd ...
Diffstat (limited to 'mm/truncate.c')
-rw-r--r--mm/truncate.c37
1 files changed, 7 insertions, 30 deletions
diff --git a/mm/truncate.c b/mm/truncate.c
index ddec5a5966d7..7a9d8a3cb143 100644
--- a/mm/truncate.c
+++ b/mm/truncate.c
@@ -93,35 +93,6 @@ void do_invalidatepage(struct page *page, unsigned int offset,
93} 93}
94 94
95/* 95/*
96 * This cancels just the dirty bit on the kernel page itself, it
97 * does NOT actually remove dirty bits on any mmap's that may be
98 * around. It also leaves the page tagged dirty, so any sync
99 * activity will still find it on the dirty lists, and in particular,
100 * clear_page_dirty_for_io() will still look at the dirty bits in
101 * the VM.
102 *
103 * Doing this should *normally* only ever be done when a page
104 * is truncated, and is not actually mapped anywhere at all. However,
105 * fs/buffer.c does this when it notices that somebody has cleaned
106 * out all the buffers on a page without actually doing it through
107 * the VM. Can you say "ext3 is horribly ugly"? Tought you could.
108 */
109void cancel_dirty_page(struct page *page, unsigned int account_size)
110{
111 if (TestClearPageDirty(page)) {
112 struct address_space *mapping = page->mapping;
113 if (mapping && mapping_cap_account_dirty(mapping)) {
114 dec_zone_page_state(page, NR_FILE_DIRTY);
115 dec_bdi_stat(inode_to_bdi(mapping->host),
116 BDI_RECLAIMABLE);
117 if (account_size)
118 task_io_account_cancelled_write(account_size);
119 }
120 }
121}
122EXPORT_SYMBOL(cancel_dirty_page);
123
124/*
125 * If truncate cannot remove the fs-private metadata from the page, the page 96 * If truncate cannot remove the fs-private metadata from the page, the page
126 * becomes orphaned. It will be left on the LRU and may even be mapped into 97 * becomes orphaned. It will be left on the LRU and may even be mapped into
127 * user pagetables if we're racing with filemap_fault(). 98 * user pagetables if we're racing with filemap_fault().
@@ -140,7 +111,13 @@ truncate_complete_page(struct address_space *mapping, struct page *page)
140 if (page_has_private(page)) 111 if (page_has_private(page))
141 do_invalidatepage(page, 0, PAGE_CACHE_SIZE); 112 do_invalidatepage(page, 0, PAGE_CACHE_SIZE);
142 113
143 cancel_dirty_page(page, PAGE_CACHE_SIZE); 114 /*
115 * Some filesystems seem to re-dirty the page even after
116 * the VM has canceled the dirty bit (eg ext3 journaling).
117 * Hence dirty accounting check is placed after invalidation.
118 */
119 if (TestClearPageDirty(page))
120 account_page_cleaned(page, mapping);
144 121
145 ClearPageMappedToDisk(page); 122 ClearPageMappedToDisk(page);
146 delete_from_page_cache(page); 123 delete_from_page_cache(page);