diff options
author | Chao Yu <chao2.yu@samsung.com> | 2015-05-19 12:40:04 +0300 |
---|---|---|
committer | Jaegeuk Kim <jaegeuk@kernel.org> | 2015-06-02 02:21:00 +0300 |
commit | 381722d2ac0314f65fd98db9a0eb8bdd1d984925 (patch) | |
tree | 0a3cb996b7c4fcb5479d06ec9cd797785283a250 /fs/f2fs/segment.c | |
parent | cb5c94cf3a825a0b64ae84516e7dd5c8a59befe6 (diff) | |
download | linux-381722d2ac0314f65fd98db9a0eb8bdd1d984925.tar.xz |
f2fs: introduce update_meta_page
Add a help function update_meta_page() to update meta page with specified
buffer.
Signed-off-by: Chao Yu <chao2.yu@samsung.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'fs/f2fs/segment.c')
-rw-r--r-- | fs/f2fs/segment.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 7254c11344be..59566ae3f964 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -517,12 +517,8 @@ void discard_next_dnode(struct f2fs_sb_info *sbi, block_t blkaddr) err = f2fs_issue_discard(sbi, blkaddr, 1); } - if (err) { - struct page *page = grab_meta_page(sbi, blkaddr); - memset(page_address(page), 0, F2FS_BLKSIZE); - set_page_dirty(page); - f2fs_put_page(page, 1); - } + if (err) + update_meta_page(sbi, NULL, blkaddr); } static void __add_discard_entry(struct f2fs_sb_info *sbi, @@ -801,16 +797,25 @@ struct page *get_sum_page(struct f2fs_sb_info *sbi, unsigned int segno) return get_meta_page(sbi, GET_SUM_BLOCK(sbi, segno)); } -static void write_sum_page(struct f2fs_sb_info *sbi, - struct f2fs_summary_block *sum_blk, block_t blk_addr) +void update_meta_page(struct f2fs_sb_info *sbi, void *src, block_t blk_addr) { struct page *page = grab_meta_page(sbi, blk_addr); - void *kaddr = page_address(page); - memcpy(kaddr, sum_blk, PAGE_CACHE_SIZE); + void *dst = page_address(page); + + if (src) + memcpy(dst, src, PAGE_CACHE_SIZE); + else + memset(dst, 0, PAGE_CACHE_SIZE); set_page_dirty(page); f2fs_put_page(page, 1); } +static void write_sum_page(struct f2fs_sb_info *sbi, + struct f2fs_summary_block *sum_blk, block_t blk_addr) +{ + update_meta_page(sbi, (void *)sum_blk, blk_addr); +} + static int is_next_segment_free(struct f2fs_sb_info *sbi, int type) { struct curseg_info *curseg = CURSEG_I(sbi, type); |