shmem: get_unmapped_area align huge page
[cascardo/linux.git] / mm / page-writeback.c
index e248194..8195eb4 100644 (file)
@@ -2747,6 +2747,11 @@ int test_clear_page_writeback(struct page *page)
                                __wb_writeout_inc(wb);
                        }
                }
+
+               if (mapping->host && !mapping_tagged(mapping,
+                                                    PAGECACHE_TAG_WRITEBACK))
+                       sb_clear_inode_writeback(mapping->host);
+
                spin_unlock_irqrestore(&mapping->tree_lock, flags);
        } else {
                ret = TestClearPageWriteback(page);
@@ -2774,11 +2779,24 @@ int __test_set_page_writeback(struct page *page, bool keep_write)
                spin_lock_irqsave(&mapping->tree_lock, flags);
                ret = TestSetPageWriteback(page);
                if (!ret) {
+                       bool on_wblist;
+
+                       on_wblist = mapping_tagged(mapping,
+                                                  PAGECACHE_TAG_WRITEBACK);
+
                        radix_tree_tag_set(&mapping->page_tree,
                                                page_index(page),
                                                PAGECACHE_TAG_WRITEBACK);
                        if (bdi_cap_account_writeback(bdi))
                                __inc_wb_stat(inode_to_wb(inode), WB_WRITEBACK);
+
+                       /*
+                        * We can come through here when swapping anonymous
+                        * pages, so we don't necessarily have an inode to track
+                        * for sync.
+                        */
+                       if (mapping->host && !on_wblist)
+                               sb_mark_inode_writeback(mapping->host);
                }
                if (!PageDirty(page))
                        radix_tree_tag_clear(&mapping->page_tree,