lkml.org 
[lkml]   [2015]   [Mar]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 4/8] truncate: swap the order of conditionals in cancel_dirty_page()
Date
cancel_dirty_page() currently performs TestClearPageDirty() and then
tests whether the mapping exists and has cap_account_dirty. This
patch swaps the order so that it performs the mapping tests first.

If the mapping tests fail, the dirty is cleared with ClearPageDirty().
The order or the conditionals is swapped but the end result is the
same. This will help inode foreign cgroup wb switching.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Jan Kara <jack@suse.cz>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Cc: Greg Thelen <gthelen@google.com>
---
mm/truncate.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/mm/truncate.c b/mm/truncate.c
index fe2d769..9d40cd4 100644
--- a/mm/truncate.c
+++ b/mm/truncate.c
@@ -108,13 +108,13 @@ void do_invalidatepage(struct page *page, unsigned int offset,
*/
void cancel_dirty_page(struct page *page, unsigned int account_size)
{
- struct mem_cgroup *memcg;
+ struct address_space *mapping = page->mapping;

- memcg = mem_cgroup_begin_page_stat(page);
- if (TestClearPageDirty(page)) {
- struct address_space *mapping = page->mapping;
+ if (mapping && mapping_cap_account_dirty(mapping)) {
+ struct mem_cgroup *memcg;

- if (mapping && mapping_cap_account_dirty(mapping)) {
+ memcg = mem_cgroup_begin_page_stat(page);
+ if (TestClearPageDirty(page)) {
struct bdi_writeback *wb = inode_to_wb(mapping->host);

mem_cgroup_dec_page_stat(memcg, MEM_CGROUP_STAT_DIRTY);
@@ -123,8 +123,10 @@ void cancel_dirty_page(struct page *page, unsigned int account_size)
if (account_size)
task_io_account_cancelled_write(account_size);
}
+ mem_cgroup_end_page_stat(memcg);
+ } else {
+ ClearPageDirty(page);
}
- mem_cgroup_end_page_stat(memcg);
}
EXPORT_SYMBOL(cancel_dirty_page);

--
2.1.0


\
 
 \ /
  Last update: 2015-03-23 06:41    [W:0.071 / U:1.072 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site