From 2ab9665b73efda989f04aba596e2d26c1c152e4d Mon Sep 17 00:00:00 2001 From: Andrew Morton Date: Thu, 4 Jul 2002 08:31:36 -0700 Subject: [PATCH] fix a writeback race Fixes a bug in generic_writepages() and its cut-n-paste-cousin, mpage_writepages(). The code was clearing PageDirty and then baling out if it discovered the page was nder writeback. Which would cause the dirty bit to be lost. It's a very small window, but reversing the order so PageDirty is only cleared when we know for-sure that IO will be started fixes it up. --- fs/mpage.c | 4 ++-- mm/page-writeback.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/mpage.c b/fs/mpage.c index 5c1cdc5b8c10..3dfe1187e877 100644 --- a/fs/mpage.c +++ b/fs/mpage.c @@ -515,8 +515,8 @@ mpage_writepages(struct address_space *mapping, lock_page(page); - if (page->mapping && TestClearPageDirty(page) && - !PageWriteback(page)) { + if (page->mapping && !PageWriteback(page) && + TestClearPageDirty(page)) { /* FIXME: batch this up */ if (!PageActive(page) && PageLRU(page)) { spin_lock(&pagemap_lru_lock); diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 18a8af187ccb..b6dd75000b02 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c @@ -383,8 +383,8 @@ int generic_writepages(struct address_space *mapping, int *nr_to_write) lock_page(page); /* It may have been removed from swapcache: check ->mapping */ - if (page->mapping && TestClearPageDirty(page) && - !PageWriteback(page)) { + if (page->mapping && !PageWriteback(page) && + TestClearPageDirty(page)) { /* FIXME: batch this up */ if (!PageActive(page) && PageLRU(page)) { spin_lock(&pagemap_lru_lock); -- cgit v1.2.3