aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorNamjae Jeon <namjae.jeon@samsung.com>2014-05-12 08:12:25 -0400
committerTheodore Ts'o <tytso@mit.edu>2014-05-12 08:12:25 -0400
commit1c8349a17137b93f0a83f276c764a6df1b9a116e (patch)
tree27a59d4a8ba3ce8cf426a3c55b07d259eb356598 /mm
parent236f5ecb4a5876977837376729a7599cc1ab2cc3 (diff)
ext4: fix data integrity sync in ordered mode
When we perform a data integrity sync we tag all the dirty pages with PAGECACHE_TAG_TOWRITE at start of ext4_da_writepages. Later we check for this tag in write_cache_pages_da and creates a struct mpage_da_data containing contiguously indexed pages tagged with this tag and sync these pages with a call to mpage_da_map_and_submit. This process is done in while loop until all the PAGECACHE_TAG_TOWRITE pages are synced. We also do journal start and stop in each iteration. journal_stop could initiate journal commit which would call ext4_writepage which in turn will call ext4_bio_write_page even for delayed OR unwritten buffers. When ext4_bio_write_page is called for such buffers, even though it does not sync them but it clears the PAGECACHE_TAG_TOWRITE of the corresponding page and hence these pages are also not synced by the currently running data integrity sync. We will end up with dirty pages although sync is completed. This could cause a potential data loss when the sync call is followed by a truncate_pagecache call, which is exactly the case in collapse_range. (It will cause generic/127 failure in xfstests) To avoid this issue, we can use set_page_writeback_keepwrite instead of set_page_writeback, which doesn't clear TOWRITE tag. Cc: stable@vger.kernel.org Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com> Signed-off-by: Ashish Sangwan <a.sangwan@samsung.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> Reviewed-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'mm')
-rw-r--r--mm/page-writeback.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/mm/page-writeback.c b/mm/page-writeback.c
index ef413492a149..d8691d9de3c4 100644
--- a/mm/page-writeback.c
+++ b/mm/page-writeback.c
@@ -2398,7 +2398,7 @@ int test_clear_page_writeback(struct page *page)
2398 return ret; 2398 return ret;
2399} 2399}
2400 2400
2401int test_set_page_writeback(struct page *page) 2401int __test_set_page_writeback(struct page *page, bool keep_write)
2402{ 2402{
2403 struct address_space *mapping = page_mapping(page); 2403 struct address_space *mapping = page_mapping(page);
2404 int ret; 2404 int ret;
@@ -2423,9 +2423,10 @@ int test_set_page_writeback(struct page *page)
2423 radix_tree_tag_clear(&mapping->page_tree, 2423 radix_tree_tag_clear(&mapping->page_tree,
2424 page_index(page), 2424 page_index(page),
2425 PAGECACHE_TAG_DIRTY); 2425 PAGECACHE_TAG_DIRTY);
2426 radix_tree_tag_clear(&mapping->page_tree, 2426 if (!keep_write)
2427 page_index(page), 2427 radix_tree_tag_clear(&mapping->page_tree,
2428 PAGECACHE_TAG_TOWRITE); 2428 page_index(page),
2429 PAGECACHE_TAG_TOWRITE);
2429 spin_unlock_irqrestore(&mapping->tree_lock, flags); 2430 spin_unlock_irqrestore(&mapping->tree_lock, flags);
2430 } else { 2431 } else {
2431 ret = TestSetPageWriteback(page); 2432 ret = TestSetPageWriteback(page);
@@ -2436,7 +2437,7 @@ int test_set_page_writeback(struct page *page)
2436 return ret; 2437 return ret;
2437 2438
2438} 2439}
2439EXPORT_SYMBOL(test_set_page_writeback); 2440EXPORT_SYMBOL(__test_set_page_writeback);
2440 2441
2441/* 2442/*
2442 * Return true if any of the pages in the mapping are marked with the 2443 * Return true if any of the pages in the mapping are marked with the