Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932268AbbESJk6 (ORCPT ); Tue, 19 May 2015 05:40:58 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:16619 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932168AbbESJkv (ORCPT ); Tue, 19 May 2015 05:40:51 -0400 X-AuditID: cbfee61a-f79516d000006302-d3-555b0522bb46 From: Chao Yu To: Jaegeuk Kim , Changman Lee Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] f2fs: introduce update_meta_page Date: Tue, 19 May 2015 17:40:04 +0800 Message-id: <006201d09217$e27a18a0$a76e49e0$@samsung.com> MIME-version: 1.0 Content-type: text/plain; charset=us-ascii Content-transfer-encoding: 7bit X-Mailer: Microsoft Outlook 14.0 Thread-index: AdCSDNsl3E/FludvQK2FYQya18UYjQ== Content-language: zh-cn X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrELMWRmVeSWpSXmKPExsVy+t9jQV0l1uhQg5ntYhbX9jUyWTxZP4vZ 4tIid4vLu+awObB4bFrVyeaxe8FnJo++LasYPT5vkgtgieKySUnNySxLLdK3S+DK2Dn5H2PB eaWKn7/+MjcwPpfpYuTkkBAwkZj9eQEbhC0mceHeeiCbi0NIYDqjxJm3T9khnFeMEk0z+xlB qtgEVCSWd/xnArFFBLwkJu0/wQJiMwt4SDR2fGcFsYUFTCUevJvCDGKzCKhKvD31Faieg4NX wFLi66YIkDCvgKDEj8n3oFq1JNbvPM4EYctLbF7zlhniIAWJHWdfM0Ks0pPoWP0AqkZcYuOR WywTGAVmIRk1C8moWUhGzULSsoCRZRWjaGpBckFxUnquoV5xYm5xaV66XnJ+7iZGcEg/k9rB uLLB4hCjAAejEg9vRH1UqBBrYllxZe4hRgkOZiURXsnPQCHelMTKqtSi/Pii0pzU4kOM0hws SuK8J/N9QoUE0hNLUrNTUwtSi2CyTBycUg2M4jyav0X0eH/MCWI9sjz/dOiNtVyTt7HIPlj/ nuOIA3cLU9NM771HFCbpbdy7Lf1arK1SWxmbk3+GZRuni9afd37djwt9na5qyU6vadea18lr 1Bl0kCvKe9LOq1e2SBzY+HyCRtcST44pCkkTzFf8Ewpa7XP6mMGt/9+YOM+cnlI1mUGmNVBK iaU4I9FQi7moOBEAGzhGwmUCAAA= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4547 Lines: 134 Add a help function update_meta_page() to update meta page with specified buffer. Signed-off-by: Chao Yu --- fs/f2fs/checkpoint.c | 26 ++++++-------------------- fs/f2fs/f2fs.h | 1 + fs/f2fs/segment.c | 26 ++++++++++++++++---------- 3 files changed, 23 insertions(+), 30 deletions(-) diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c index 7b7a9d8..b70bbe1 100644 --- a/fs/f2fs/checkpoint.c +++ b/fs/f2fs/checkpoint.c @@ -888,10 +888,8 @@ static void do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc) unsigned long orphan_num = sbi->im[ORPHAN_INO].ino_num; nid_t last_nid = nm_i->next_scan_nid; block_t start_blk; - struct page *cp_page; unsigned int data_sum_blocks, orphan_blocks; __u32 crc32 = 0; - void *kaddr; int i; int cp_payload_blks = __cp_payload(sbi); @@ -988,19 +986,11 @@ static void do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc) start_blk = __start_cp_addr(sbi); /* write out checkpoint buffer at block 0 */ - cp_page = grab_meta_page(sbi, start_blk++); - kaddr = page_address(cp_page); - memcpy(kaddr, ckpt, F2FS_BLKSIZE); - set_page_dirty(cp_page); - f2fs_put_page(cp_page, 1); - - for (i = 1; i < 1 + cp_payload_blks; i++) { - cp_page = grab_meta_page(sbi, start_blk++); - kaddr = page_address(cp_page); - memcpy(kaddr, (char *)ckpt + i * F2FS_BLKSIZE, F2FS_BLKSIZE); - set_page_dirty(cp_page); - f2fs_put_page(cp_page, 1); - } + update_meta_page(sbi, ckpt, start_blk++); + + for (i = 1; i < 1 + cp_payload_blks; i++) + update_meta_page(sbi, (char *)ckpt + i * F2FS_BLKSIZE, + start_blk++); if (orphan_num) { write_orphan_inodes(sbi, start_blk); @@ -1015,11 +1005,7 @@ static void do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc) } /* writeout checkpoint block */ - cp_page = grab_meta_page(sbi, start_blk); - kaddr = page_address(cp_page); - memcpy(kaddr, ckpt, F2FS_BLKSIZE); - set_page_dirty(cp_page); - f2fs_put_page(cp_page, 1); + update_meta_page(sbi, ckpt, start_blk); /* wait for previous submitted node/meta pages writeback */ wait_on_all_pages_writeback(sbi); diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 5119167..7e93fcf 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -1690,6 +1690,7 @@ int npages_for_summary_flush(struct f2fs_sb_info *, bool); void allocate_new_segments(struct f2fs_sb_info *); int f2fs_trim_fs(struct f2fs_sb_info *, struct fstrim_range *); struct page *get_sum_page(struct f2fs_sb_info *, unsigned int); +void update_meta_page(struct f2fs_sb_info *, void *, block_t); void write_meta_page(struct f2fs_sb_info *, struct page *); void write_node_page(unsigned int, struct f2fs_io_info *); void write_data_page(struct dnode_of_data *, struct f2fs_io_info *); diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index bdf874a..0b2bdd2 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -502,12 +502,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, @@ -788,16 +784,26 @@ 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); -- 2.3.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/