# This is a BitKeeper generated diff -Nru style patch. # # ChangeSet # 2005/03/13 16:15:58-08:00 andrea@suse.de # [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: Andrea Arcangeli # Signed-off-by: Andrew Morton # Signed-off-by: Linus Torvalds # # mm/vmscan.c # 2005/03/13 15:29:39-08:00 andrea@suse.de +13 -1 # orphaned pagecache memleak fix # diff -Nru a/mm/vmscan.c b/mm/vmscan.c --- a/mm/vmscan.c 2005-03-24 16:12:42 +01:00 +++ b/mm/vmscan.c 2005-03-24 16:12:42 +01:00 @@ -313,8 +313,20 @@ */ 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))