]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] vmscan: handle synchronous writepage()
authorAndrew Morton <akpm@osdl.org>
Sat, 12 Jun 2004 23:39:11 +0000 (16:39 -0700)
committerLinus Torvalds <torvalds@evo.osdl.org>
Sat, 12 Jun 2004 23:39:11 +0000 (16:39 -0700)
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: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
mm/vmscan.c

index f0ec7d2c67d31659b786ff0a4b83574aed03890d..1be7851a22a880bf15f1d636e0107dc06f7d27dd 100644 (file)
@@ -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)) {