From: npiggin@suse.de Subject: [patch 6/7] mm: write_cache_pages optimise page cleaning Date: Tue, 21 Oct 2008 19:09:53 +1100 Message-ID: <20081021081139.306270000@nick.local0.net> References: <20081021080947.032757000@suse.de> Cc: linux-fsdevel@vger.kernel.org To: akpm@linux-foundation.org Return-path: Received: from cantor.suse.de ([195.135.220.2]:54012 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751594AbYJUIP1 (ORCPT ); Tue, 21 Oct 2008 04:15:27 -0400 Content-Disposition: inline; filename=mm-wcp-writeback-clean-opt.patch Sender: linux-fsdevel-owner@vger.kernel.org List-ID: 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 --- Index: linux-2.6/mm/page-writeback.c =================================================================== --- linux-2.6.orig/mm/page-writeback.c +++ linux-2.6/mm/page-writeback.c @@ -938,11 +938,20 @@ continue_unlock: 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); --