diff options
author | Jaegeuk Kim <jaegeuk@kernel.org> | 2015-05-01 02:00:33 +0200 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2015-05-29 00:41:37 +0200 |
commit | 43f3eae1d3b1de6a4f7e39ef9c363ec6f8b9c8d4 (patch) | |
tree | 32f273bfd14351cf7350a79d080483db76a7cf31 /fs/f2fs/file.c | |
parent | f2fs: fix counting the number of inline_data inodes (diff) | |
download | linux-43f3eae1d3b1de6a4f7e39ef9c363ec6f8b9c8d4.tar.xz linux-43f3eae1d3b1de6a4f7e39ef9c363ec6f8b9c8d4.zip |
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.c | 26 |
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; } |