aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward Shishkin <edward.shishkin@gmail.com>2009-03-31 18:19:39 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-04-01 11:59:12 -0400
commite3a7cca1ef4c1af9b0acef9bd66eff6582a737b5 (patch)
tree717097ec82ce0de55e44b2fe3e35fa041e5169b2
parentbd2f6199cf9af472aeefa1b642c9f504f19e6008 (diff)
vfs: add/use account_page_dirtied()
Add a helper function account_page_dirtied(). Use that from two callsites. reiser4 adds a function which adds a third callsite. Signed-off-by: Edward Shishkin<edward.shishkin@gmail.com> Cc: Nick Piggin <nickpiggin@yahoo.com.au> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/buffer.c9
-rw-r--r--include/linux/mm.h1
-rw-r--r--mm/page-writeback.c22
3 files changed, 17 insertions, 15 deletions
diff --git a/fs/buffer.c b/fs/buffer.c
index a2fd743d97cb..73abe6d8218c 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -621,14 +621,7 @@ static void __set_page_dirty(struct page *page,
621 spin_lock_irq(&mapping->tree_lock); 621 spin_lock_irq(&mapping->tree_lock);
622 if (page->mapping) { /* Race with truncate? */ 622 if (page->mapping) { /* Race with truncate? */
623 WARN_ON_ONCE(warn && !PageUptodate(page)); 623 WARN_ON_ONCE(warn && !PageUptodate(page));
624 624 account_page_dirtied(page, mapping);
625 if (mapping_cap_account_dirty(mapping)) {
626 __inc_zone_page_state(page, NR_FILE_DIRTY);
627 __inc_bdi_stat(mapping->backing_dev_info,
628 BDI_RECLAIMABLE);
629 task_dirty_inc(current);
630 task_io_account_write(PAGE_CACHE_SIZE);
631 }
632 radix_tree_tag_set(&mapping->page_tree, 625 radix_tree_tag_set(&mapping->page_tree,
633 page_index(page), PAGECACHE_TAG_DIRTY); 626 page_index(page), PAGECACHE_TAG_DIRTY);
634 } 627 }
diff --git a/include/linux/mm.h b/include/linux/mm.h
index b1ea37fc7a24..2223f8dfa568 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -834,6 +834,7 @@ int __set_page_dirty_nobuffers(struct page *page);
834int __set_page_dirty_no_writeback(struct page *page); 834int __set_page_dirty_no_writeback(struct page *page);
835int redirty_page_for_writepage(struct writeback_control *wbc, 835int redirty_page_for_writepage(struct writeback_control *wbc,
836 struct page *page); 836 struct page *page);
837void account_page_dirtied(struct page *page, struct address_space *mapping);
837int set_page_dirty(struct page *page); 838int set_page_dirty(struct page *page);
838int set_page_dirty_lock(struct page *page); 839int set_page_dirty_lock(struct page *page);
839int clear_page_dirty_for_io(struct page *page); 840int clear_page_dirty_for_io(struct page *page);
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index 40ca7cdb653e..6aa92b03c747 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -1198,6 +1198,20 @@ int __set_page_dirty_no_writeback(struct page *page)
1198} 1198}
1199 1199
1200/* 1200/*
1201 * Helper function for set_page_dirty family.
1202 * NOTE: This relies on being atomic wrt interrupts.
1203 */
1204void account_page_dirtied(struct page *page, struct address_space *mapping)
1205{
1206 if (mapping_cap_account_dirty(mapping)) {
1207 __inc_zone_page_state(page, NR_FILE_DIRTY);
1208 __inc_bdi_stat(mapping->backing_dev_info, BDI_RECLAIMABLE);
1209 task_dirty_inc(current);
1210 task_io_account_write(PAGE_CACHE_SIZE);
1211 }
1212}
1213
1214/*
1201 * For address_spaces which do not use buffers. Just tag the page as dirty in 1215 * For address_spaces which do not use buffers. Just tag the page as dirty in
1202 * its radix tree. 1216 * its radix tree.
1203 * 1217 *
@@ -1226,13 +1240,7 @@ int __set_page_dirty_nobuffers(struct page *page)
1226 if (mapping2) { /* Race with truncate? */ 1240 if (mapping2) { /* Race with truncate? */
1227 BUG_ON(mapping2 != mapping); 1241 BUG_ON(mapping2 != mapping);
1228 WARN_ON_ONCE(!PagePrivate(page) && !PageUptodate(page)); 1242 WARN_ON_ONCE(!PagePrivate(page) && !PageUptodate(page));
1229 if (mapping_cap_account_dirty(mapping)) { 1243 account_page_dirtied(page, mapping);
1230 __inc_zone_page_state(page, NR_FILE_DIRTY);
1231 __inc_bdi_stat(mapping->backing_dev_info,
1232 BDI_RECLAIMABLE);
1233 task_dirty_inc(current);
1234 task_io_account_write(PAGE_CACHE_SIZE);
1235 }
1236 radix_tree_tag_set(&mapping->page_tree, 1244 radix_tree_tag_set(&mapping->page_tree,
1237 page_index(page), PAGECACHE_TAG_DIRTY); 1245 page_index(page), PAGECACHE_TAG_DIRTY);
1238 } 1246 }