mm: memcg/slab: cache page number in memcg_(un)charge_slab()
[linux-2.6-microblaze.git] / mm / page-writeback.c
index 2caf780..7326b54 100644 (file)
@@ -2182,12 +2182,12 @@ int write_cache_pages(struct address_space *mapping,
                if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
                        range_whole = 1;
        }
-       if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)
+       if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages) {
+               tag_pages_for_writeback(mapping, index, end);
                tag = PAGECACHE_TAG_TOWRITE;
-       else
+       } else {
                tag = PAGECACHE_TAG_DIRTY;
-       if (wbc->sync_mode == WB_SYNC_ALL || wbc->tagged_writepages)
-               tag_pages_for_writeback(mapping, index, end);
+       }
        done_index = index;
        while (!done && (index <= end)) {
                int i;
@@ -2655,7 +2655,7 @@ int clear_page_dirty_for_io(struct page *page)
        struct address_space *mapping = page_mapping(page);
        int ret = 0;
 
-       BUG_ON(!PageLocked(page));
+       VM_BUG_ON_PAGE(!PageLocked(page), page);
 
        if (mapping && mapping_cap_account_dirty(mapping)) {
                struct inode *inode = mapping->host;
@@ -2764,7 +2764,7 @@ int test_clear_page_writeback(struct page *page)
 int __test_set_page_writeback(struct page *page, bool keep_write)
 {
        struct address_space *mapping = page_mapping(page);
-       int ret;
+       int ret, access_ret;
 
        lock_page_memcg(page);
        if (mapping && mapping_use_writeback_tags(mapping)) {
@@ -2807,6 +2807,13 @@ int __test_set_page_writeback(struct page *page, bool keep_write)
                inc_zone_page_state(page, NR_ZONE_WRITE_PENDING);
        }
        unlock_page_memcg(page);
+       access_ret = arch_make_page_accessible(page);
+       /*
+        * If writeback has been triggered on a page that cannot be made
+        * accessible, it is too late to recover here.
+        */
+       VM_BUG_ON_PAGE(access_ret != 0, page);
+
        return ret;
 
 }