diff options
Diffstat (limited to 'mm/page-writeback.c')
-rw-r--r-- | mm/page-writeback.c | 43 |
1 files changed, 12 insertions, 31 deletions
diff --git a/mm/page-writeback.c b/mm/page-writeback.c index d5d81f5384d1..6f4335238e33 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c | |||
@@ -1541,16 +1541,6 @@ pause: | |||
1541 | bdi_start_background_writeback(bdi); | 1541 | bdi_start_background_writeback(bdi); |
1542 | } | 1542 | } |
1543 | 1543 | ||
1544 | void set_page_dirty_balance(struct page *page) | ||
1545 | { | ||
1546 | if (set_page_dirty(page)) { | ||
1547 | struct address_space *mapping = page_mapping(page); | ||
1548 | |||
1549 | if (mapping) | ||
1550 | balance_dirty_pages_ratelimited(mapping); | ||
1551 | } | ||
1552 | } | ||
1553 | |||
1554 | static DEFINE_PER_CPU(int, bdp_ratelimits); | 1544 | static DEFINE_PER_CPU(int, bdp_ratelimits); |
1555 | 1545 | ||
1556 | /* | 1546 | /* |
@@ -2123,32 +2113,25 @@ EXPORT_SYMBOL(account_page_dirtied); | |||
2123 | * page dirty in that case, but not all the buffers. This is a "bottom-up" | 2113 | * page dirty in that case, but not all the buffers. This is a "bottom-up" |
2124 | * dirtying, whereas __set_page_dirty_buffers() is a "top-down" dirtying. | 2114 | * dirtying, whereas __set_page_dirty_buffers() is a "top-down" dirtying. |
2125 | * | 2115 | * |
2126 | * Most callers have locked the page, which pins the address_space in memory. | 2116 | * The caller must ensure this doesn't race with truncation. Most will simply |
2127 | * But zap_pte_range() does not lock the page, however in that case the | 2117 | * hold the page lock, but e.g. zap_pte_range() calls with the page mapped and |
2128 | * mapping is pinned by the vma's ->vm_file reference. | 2118 | * the pte lock held, which also locks out truncation. |
2129 | * | ||
2130 | * We take care to handle the case where the page was truncated from the | ||
2131 | * mapping by re-checking page_mapping() inside tree_lock. | ||
2132 | */ | 2119 | */ |
2133 | int __set_page_dirty_nobuffers(struct page *page) | 2120 | int __set_page_dirty_nobuffers(struct page *page) |
2134 | { | 2121 | { |
2135 | if (!TestSetPageDirty(page)) { | 2122 | if (!TestSetPageDirty(page)) { |
2136 | struct address_space *mapping = page_mapping(page); | 2123 | struct address_space *mapping = page_mapping(page); |
2137 | struct address_space *mapping2; | ||
2138 | unsigned long flags; | 2124 | unsigned long flags; |
2139 | 2125 | ||
2140 | if (!mapping) | 2126 | if (!mapping) |
2141 | return 1; | 2127 | return 1; |
2142 | 2128 | ||
2143 | spin_lock_irqsave(&mapping->tree_lock, flags); | 2129 | spin_lock_irqsave(&mapping->tree_lock, flags); |
2144 | mapping2 = page_mapping(page); | 2130 | BUG_ON(page_mapping(page) != mapping); |
2145 | if (mapping2) { /* Race with truncate? */ | 2131 | WARN_ON_ONCE(!PagePrivate(page) && !PageUptodate(page)); |
2146 | BUG_ON(mapping2 != mapping); | 2132 | account_page_dirtied(page, mapping); |
2147 | WARN_ON_ONCE(!PagePrivate(page) && !PageUptodate(page)); | 2133 | radix_tree_tag_set(&mapping->page_tree, page_index(page), |
2148 | account_page_dirtied(page, mapping); | 2134 | PAGECACHE_TAG_DIRTY); |
2149 | radix_tree_tag_set(&mapping->page_tree, | ||
2150 | page_index(page), PAGECACHE_TAG_DIRTY); | ||
2151 | } | ||
2152 | spin_unlock_irqrestore(&mapping->tree_lock, flags); | 2135 | spin_unlock_irqrestore(&mapping->tree_lock, flags); |
2153 | if (mapping->host) { | 2136 | if (mapping->host) { |
2154 | /* !PageAnon && !swapper_space */ | 2137 | /* !PageAnon && !swapper_space */ |
@@ -2305,12 +2288,10 @@ int clear_page_dirty_for_io(struct page *page) | |||
2305 | /* | 2288 | /* |
2306 | * We carefully synchronise fault handlers against | 2289 | * We carefully synchronise fault handlers against |
2307 | * installing a dirty pte and marking the page dirty | 2290 | * installing a dirty pte and marking the page dirty |
2308 | * at this point. We do this by having them hold the | 2291 | * at this point. We do this by having them hold the |
2309 | * page lock at some point after installing their | 2292 | * page lock while dirtying the page, and pages are |
2310 | * pte, but before marking the page dirty. | 2293 | * always locked coming in here, so we get the desired |
2311 | * Pages are always locked coming in here, so we get | 2294 | * exclusion. |
2312 | * the desired exclusion. See mm/memory.c:do_wp_page() | ||
2313 | * for more comments. | ||
2314 | */ | 2295 | */ |
2315 | if (TestClearPageDirty(page)) { | 2296 | if (TestClearPageDirty(page)) { |
2316 | dec_zone_page_state(page, NR_FILE_DIRTY); | 2297 | dec_zone_page_state(page, NR_FILE_DIRTY); |