]> git.hungrycats.org Git - linux/commitdiff
[PATCH] fix a writeback race
authorAndrew Morton <akpm@zip.com.au>
Thu, 4 Jul 2002 15:31:36 +0000 (08:31 -0700)
committerLinus Torvalds <torvalds@home.transmeta.com>
Thu, 4 Jul 2002 15:31:36 +0000 (08:31 -0700)
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
mm/page-writeback.c

index 5c1cdc5b8c10038bf28a15a1eccca00427500aad..3dfe1187e877283a23a453bc2edec036689f8dc5 100644 (file)
@@ -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);
index 18a8af187ccbd1b1c5abccfce86e08eaf0f7d5e0..b6dd75000b021d789890f5573b231a33f8174496 100644 (file)
@@ -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);