summaryrefslogtreecommitdiff
path: root/fs/f2fs/file.c
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk@kernel.org>2015-04-30 17:00:33 -0700
committerJaegeuk Kim <jaegeuk@kernel.org>2015-05-28 15:41:37 -0700
commit43f3eae1d3b1de6a4f7e39ef9c363ec6f8b9c8d4 (patch)
tree32f273bfd14351cf7350a79d080483db76a7cf31 /fs/f2fs/file.c
parent2fb2c954968bedddfeb3895969fbdf2ae0679ed3 (diff)
f2fs: split find_data_page according to specific purposes
This patch splits find_data_page as follows. 1. f2fs_gc - use get_read_data_page() with read only 2. find_in_level - use find_data_page without locked page 3. truncate_partial_page - In the case cache_only mode, just drop cached page. - Ohterwise, use get_lock_data_page() and guarantee to truncate Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/file.c')
-rw-r--r--fs/f2fs/file.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 0e58f021bf49..cb002c067630 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -461,28 +461,32 @@ void truncate_data_blocks(struct dnode_of_data *dn)
}
static int truncate_partial_data_page(struct inode *inode, u64 from,
- bool force)
+ bool cache_only)
{
unsigned offset = from & (PAGE_CACHE_SIZE - 1);
+ pgoff_t index = from >> PAGE_CACHE_SHIFT;
+ struct address_space *mapping = inode->i_mapping;
struct page *page;
- if (!offset && !force)
+ if (!offset && !cache_only)
return 0;
- page = find_data_page(inode, from >> PAGE_CACHE_SHIFT, force);
- if (IS_ERR(page))
+ if (cache_only) {
+ page = grab_cache_page(mapping, index);
+ if (page && PageUptodate(page))
+ goto truncate_out;
+ f2fs_put_page(page, 1);
return 0;
+ }
- lock_page(page);
- if (unlikely(!PageUptodate(page) ||
- page->mapping != inode->i_mapping))
- goto out;
-
+ page = get_lock_data_page(inode, index);
+ if (IS_ERR(page))
+ return 0;
+truncate_out:
f2fs_wait_on_page_writeback(page, DATA);
zero_user(page, offset, PAGE_CACHE_SIZE - offset);
- if (!force)
+ if (!cache_only)
set_page_dirty(page);
-out:
f2fs_put_page(page, 1);
return 0;
}