diff options
Diffstat (limited to 'mm/filemap.c')
-rw-r--r-- | mm/filemap.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/mm/filemap.c b/mm/filemap.c index 81fb9bff0d4f..b7a01e927953 100644 --- a/mm/filemap.c +++ b/mm/filemap.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/syscalls.h> | 33 | #include <linux/syscalls.h> |
34 | #include <linux/cpuset.h> | 34 | #include <linux/cpuset.h> |
35 | #include <linux/hardirq.h> /* for BUG_ON(!in_atomic()) only */ | 35 | #include <linux/hardirq.h> /* for BUG_ON(!in_atomic()) only */ |
36 | #include <linux/memcontrol.h> | ||
36 | #include "internal.h" | 37 | #include "internal.h" |
37 | 38 | ||
38 | /* | 39 | /* |
@@ -118,6 +119,7 @@ void __remove_from_page_cache(struct page *page) | |||
118 | { | 119 | { |
119 | struct address_space *mapping = page->mapping; | 120 | struct address_space *mapping = page->mapping; |
120 | 121 | ||
122 | mem_cgroup_uncharge_page(page); | ||
121 | radix_tree_delete(&mapping->page_tree, page->index); | 123 | radix_tree_delete(&mapping->page_tree, page->index); |
122 | page->mapping = NULL; | 124 | page->mapping = NULL; |
123 | mapping->nrpages--; | 125 | mapping->nrpages--; |
@@ -461,6 +463,11 @@ int add_to_page_cache(struct page *page, struct address_space *mapping, | |||
461 | int error = radix_tree_preload(gfp_mask & ~__GFP_HIGHMEM); | 463 | int error = radix_tree_preload(gfp_mask & ~__GFP_HIGHMEM); |
462 | 464 | ||
463 | if (error == 0) { | 465 | if (error == 0) { |
466 | |||
467 | error = mem_cgroup_charge(page, current->mm); | ||
468 | if (error) | ||
469 | goto out; | ||
470 | |||
464 | write_lock_irq(&mapping->tree_lock); | 471 | write_lock_irq(&mapping->tree_lock); |
465 | error = radix_tree_insert(&mapping->page_tree, offset, page); | 472 | error = radix_tree_insert(&mapping->page_tree, offset, page); |
466 | if (!error) { | 473 | if (!error) { |
@@ -470,10 +477,13 @@ int add_to_page_cache(struct page *page, struct address_space *mapping, | |||
470 | page->index = offset; | 477 | page->index = offset; |
471 | mapping->nrpages++; | 478 | mapping->nrpages++; |
472 | __inc_zone_page_state(page, NR_FILE_PAGES); | 479 | __inc_zone_page_state(page, NR_FILE_PAGES); |
473 | } | 480 | } else |
481 | mem_cgroup_uncharge_page(page); | ||
482 | |||
474 | write_unlock_irq(&mapping->tree_lock); | 483 | write_unlock_irq(&mapping->tree_lock); |
475 | radix_tree_preload_end(); | 484 | radix_tree_preload_end(); |
476 | } | 485 | } |
486 | out: | ||
477 | return error; | 487 | return error; |
478 | } | 488 | } |
479 | EXPORT_SYMBOL(add_to_page_cache); | 489 | EXPORT_SYMBOL(add_to_page_cache); |