Commit ce91b575 authored by Andrea Arcangeli's avatar Andrea Arcangeli Committed by Linus Torvalds

[PATCH] orphaned pagecache memleak fix

Chris found that with data journaling a reiserfs pagecache may be truncate
while still pinned.  The truncation removes the page->mapping, but the page
is still listed in the VM queues because it still has buffers.  Then during
the journaling process, a buffer is marked dirty and that sets the PG_dirty
bitflag as well (in mark_buffer_dirty).  After that the page is leaked
because it's both dirty and without a mapping.

So we must allow pages without mapping and dirty to reach the PagePrivate
check.  The page->mapping will be checked again right after the PagePrivate
check.
Signed-off-by: default avatarAndrea Arcangeli <andrea@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 2172436c
......@@ -313,8 +313,20 @@ static pageout_t pageout(struct page *page, struct address_space *mapping)
*/
if (!is_page_cache_freeable(page))
return PAGE_KEEP;
if (!mapping)
if (!mapping) {
/*
* Some data journaling orphaned pages can have
* page->mapping == NULL while being dirty with clean buffers.
*/
if (PageDirty(page) && PagePrivate(page)) {
if (try_to_free_buffers(page)) {
ClearPageDirty(page);
printk("%s: orphaned page\n", __FUNCTION__);
return PAGE_CLEAN;
}
}
return PAGE_KEEP;
}
if (mapping->a_ops->writepage == NULL)
return PAGE_ACTIVATE;
if (!may_write_to_queue(mapping->backing_dev_info))
......
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