mm: reclaim invalidated page ASAP
[linux-2.6-block.git] / mm / page-writeback.c
index 2cb01f6ec5d019e7e431d9f18cdba6f3bde573e4..b437fe6257b02adb5520e377c5af045c8a397487 100644 (file)
@@ -1211,6 +1211,17 @@ int set_page_dirty(struct page *page)
 
        if (likely(mapping)) {
                int (*spd)(struct page *) = mapping->a_ops->set_page_dirty;
+               /*
+                * readahead/lru_deactivate_page could remain
+                * PG_readahead/PG_reclaim due to race with end_page_writeback
+                * About readahead, if the page is written, the flags would be
+                * reset. So no problem.
+                * About lru_deactivate_page, if the page is redirty, the flag
+                * will be reset. So no problem. but if the page is used by readahead
+                * it will confuse readahead and make it restart the size rampup
+                * process. But it's a trivial problem.
+                */
+               ClearPageReclaim(page);
 #ifdef CONFIG_BLOCK
                if (!spd)
                        spd = __set_page_dirty_buffers;
@@ -1266,7 +1277,6 @@ int clear_page_dirty_for_io(struct page *page)
 
        BUG_ON(!PageLocked(page));
 
-       ClearPageReclaim(page);
        if (mapping && mapping_cap_account_dirty(mapping)) {
                /*
                 * Yes, Virginia, this is indeed insane.