From: Andrea Arcangeli 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 --- 25-akpm/mm/vmscan.c | 14 +++++++++++++- 1 files changed, 13 insertions(+), 1 deletion(-) diff -puN mm/vmscan.c~orphaned-pagecache-memleak-fix mm/vmscan.c --- 25/mm/vmscan.c~orphaned-pagecache-memleak-fix 2005-03-10 21:34:08.000000000 -0800 +++ 25-akpm/mm/vmscan.c 2005-03-10 21:50:02.000000000 -0800 @@ -313,8 +313,20 @@ static pageout_t pageout(struct page *pa */ 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)) _