Commit 961caf47 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] vmscan: handle synchronous writepage()

Teach page reclaim to understand synchronous ->writepage implementations.

If ->writepage completed I/O prior to returning we can proceed to reclaim the
page without giving it another trip around the LRU.

This is beneficial for ramdisk-backed S_ISREG files: we can reclaim the file's
pages as fast as the ramdisk driver needs to allocate them and this prevents
I/O errors due to OOM in rd_blkdev_pagecache_IO().
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 2c38ac91
......@@ -374,7 +374,17 @@ shrink_list(struct list_head *page_list, unsigned int gfp_mask,
/* synchronous write or broken a_ops? */
ClearPageReclaim(page);
}
goto keep;
if (PageWriteback(page) || PageDirty(page))
goto keep;
/*
* A synchronous write - probably a ramdisk. Go
* ahead and try to reclaim the page.
*/
if (TestSetPageLocked(page))
goto keep;
if (PageDirty(page) || PageWriteback(page))
goto keep_locked;
mapping = page_mapping(page);
}
}
......@@ -396,7 +406,7 @@ shrink_list(struct list_head *page_list, unsigned int gfp_mask,
* the pages which were not successfully invalidated in
* truncate_complete_page(). We try to drop those buffers here
* and if that worked, and the page is no longer mapped into
* process address space (page_count == 0) it can be freed.
* process address space (page_count == 1) it can be freed.
* Otherwise, leave the page on the LRU so it is swappable.
*/
if (PagePrivate(page)) {
......
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