Skip to content

Commit

Permalink
mm: write_cache_pages optimise page cleaning
Browse files Browse the repository at this point in the history
In write_cache_pages, if we get stuck behind another process that is
cleaning pages, we will be forced to wait for them to finish, then perform
our own writeout (if it was redirtied during the long wait), then wait for
that.

If a page under writeout is still clean, we can skip waiting for it (if
we're part of a data integrity sync, we'll be waiting for all writeout
pages afterwards, so we'll still be waiting for the other guy's write
that's cleaned the page).

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>
  • Loading branch information
Nick Piggin authored and torvalds committed Jan 6, 2009
1 parent 5a3d5c9 commit 515f4a0
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions mm/page-writeback.c
Original file line number Diff line number Diff line change
Expand Up @@ -945,11 +945,20 @@ int write_cache_pages(struct address_space *mapping,
goto continue_unlock;
}

if (wbc->sync_mode != WB_SYNC_NONE)
wait_on_page_writeback(page);
if (!PageDirty(page)) {
/* someone wrote it for us */
goto continue_unlock;
}

if (PageWriteback(page)) {
if (wbc->sync_mode != WB_SYNC_NONE)
wait_on_page_writeback(page);
else
goto continue_unlock;
}

if (PageWriteback(page) ||
!clear_page_dirty_for_io(page))
BUG_ON(PageWriteback(page));
if (!clear_page_dirty_for_io(page))
goto continue_unlock;

ret = (*writepage)(page, wbc, data);
Expand Down

0 comments on commit 515f4a0

Please sign in to comment.