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 | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletion(-) diff -puN mm/vmscan.c~orphaned-pagecache-memleak-fix mm/vmscan.c --- 25/mm/vmscan.c~orphaned-pagecache-memleak-fix 2005-01-23 14:46:19.618336112 -0800 +++ 25-akpm/mm/vmscan.c 2005-01-23 14:46:19.622335504 -0800 @@ -306,8 +306,16 @@ 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) && + try_to_free_buffers(page)) + return PAGE_CLEAN; return PAGE_KEEP; + } if (mapping->a_ops->writepage == NULL) return PAGE_ACTIVATE; if (!may_write_to_queue(mapping->backing_dev_info)) _