fsck.f2fs: reduce mem alloc during read sit block
PATCH v3 1/1 fsck.f2fs: reduce mem alloc during read sit block
This patch reduce mem alloc during read sit block
Signed-off-by Yunlei He <[email protected]>
Reviewed-by Chao Yu <[email protected]>
--- fsck/fsck.c | 10 +++++++--- fsck/fsck.h | 4 ++-- fsck/mount.c | 47 ++++++++++++++++++++++++++++------------------- 3 files changed, 37 insertions(+), 24 deletions(-)
fsck/fsck.c +7 -3
@@ -1895,25 +1895,29 @@ static void fix_nat_entries(struct f2fs_sb_info *sbi)static void flush_curseg_sit_entries (struct f2fs_sb_info *sbi) {struct sit_info *sit_i =SIT_I (sbi); +struct f2fs_sit_block *sit_blk;int i; + sit_blk =calloc (BLOCK_SZ ,1 ); +ASSERT (sit_blk); +/* update curseg sit entries, since we may change * a segment type in move_curseg_info */ for (i =0 ; i <NO_CHECK_TYPE ; i++) {struct curseg_info *curseg =CURSEG_I (sbi, i); -struct f2fs_sit_block *sit_blk;struct f2fs_sit_entry *sit;struct seg_entry *se; se =get_seg_entry (sbi, curseg->segno); - sit_blk =get_current_sit_page (sbi, curseg->segno); +get_current_sit_page (sbi, curseg->segno, sit_blk); sit = &sit_blk->entries[SIT_ENTRY_OFFSET (sit_i, curseg->segno)]; sit->vblocks =cpu_to_le16 ((se->type <<SIT_VBLOCKS_SHIFT ) | se->valid_blocks);rewrite_current_sit_page (sbi, curseg->segno, sit_blk); -free (sit_blk); } + +free (sit_blk); }static void fix_checkpoint (struct f2fs_sb_info *sbi)
fsck/fsck.h +2 -2
@@ -182,8 +182,8 @@ extern void update_nat_blkaddr(struct f2fs_sb_info *, nid_t, nid_t, block_t);extern void print_raw_sb_info (struct f2fs_super_block *);extern u32 get_free_segments (struct f2fs_sb_info *); -extern struct f2fs_sit_block *get_current_sit_page (struct f2fs_sb_info *, -unsigned int ); +extern void get_current_sit_page (struct f2fs_sb_info *, +unsigned int ,struct f2fs_sit_block *);extern void rewrite_current_sit_page (struct f2fs_sb_info *,unsigned int ,struct f2fs_sit_block *);
fsck/mount.c +28 -19
167 lines not on this page · raw message
Signature · 6 lines
1.9.1 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot