diff options
author | Nick Piggin <npiggin@suse.de> | 2009-01-06 14:39:11 -0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-01-24 16:36:27 -0800 |
commit | e55e8f16723d5017aff16547e259e2c35766e4ad (patch) | |
tree | af78dedd810f767a1d5c8e8e56800bcfa94f82c4 /mm | |
parent | 65cdf4090b2a70726bed638e7c41bb3f952d0076 (diff) |
mm: write_cache_pages terminate quickly
commit d5482cdf8a0aacb1e6468a97d5544f5829c8d8c4 upstream.
Terminate the write_cache_pages loop upon encountering the first page past
end, without locking the page. Pages cannot have their index change when
we have a reference on them (truncate, eg truncate_inode_pages_range
performs the same check without the page lock).
Signed-off-by: Nick Piggin <npiggin@suse.de>
Cc: Chris Mason <chris.mason@oracle.com>
Cc: Dave Chinner <david@fromorbit.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'mm')
-rw-r--r-- | mm/page-writeback.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/mm/page-writeback.c b/mm/page-writeback.c index d69548daf3b..0f225bf6b8e 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -914,15 +914,24 @@ retry: for (i = 0; i < nr_pages; i++) { struct page *page = pvec.pages[i]; - done_index = page->index + 1; - /* - * At this point we hold neither mapping->tree_lock nor - * lock on the page itself: the page may be truncated or - * invalidated (changing page->mapping to NULL), or even - * swizzled back from swapper_space to tmpfs file - * mapping + * At this point, the page may be truncated or + * invalidated (changing page->mapping to NULL), or + * even swizzled back from swapper_space to tmpfs file + * mapping. However, page->index will not change + * because we have a reference on the page. */ + if (page->index > end) { + /* + * can't be range_cyclic (1st pass) because + * end == -1 in that case. + */ + done = 1; + break; + } + + done_index = page->index + 1; + lock_page(page); /* @@ -939,15 +948,6 @@ continue_unlock: continue; } - if (page->index > end) { - /* - * can't be range_cyclic (1st pass) because - * end == -1 in that case. - */ - done = 1; - goto continue_unlock; - } - if (!PageDirty(page)) { /* someone wrote it for us */ goto continue_unlock; |