[PATCH] truncate: clear page dirtiness before running try_to_free_buffers()
[linux-2.6.git] / mm / truncate.c
index bf9e296..89a5c35 100644 (file)
@@ -60,11 +60,12 @@ void cancel_dirty_page(struct page *page, unsigned int account_size)
                WARN_ON(++warncount < 5);
        }
                
-       if (TestClearPageDirty(page) && account_size)
+       if (TestClearPageDirty(page) && account_size) {
+               dec_zone_page_state(page, NR_FILE_DIRTY);
                task_io_account_cancelled_write(account_size);
+       }
 }
 
-
 /*
  * If truncate cannot remove the fs-private metadata from the page, the page
  * becomes anonymous.  It will be left on the LRU and may even be mapped into
@@ -81,11 +82,11 @@ truncate_complete_page(struct address_space *mapping, struct page *page)
        if (page->mapping != mapping)
                return;
 
+       cancel_dirty_page(page, PAGE_CACHE_SIZE);
+
        if (PagePrivate(page))
                do_invalidatepage(page, 0);
 
-       cancel_dirty_page(page, PAGE_CACHE_SIZE);
-
        ClearPageUptodate(page);
        ClearPageMappedToDisk(page);
        remove_from_page_cache(page);