Skip to contentSkip to conversation

fsck.f2fs: reduce mem alloc during read sit block

PATCH New Yunlei He 1 participant 1 message Jan 29, 2018

lore
Share & tools
lore

Yunlei He

author
#0 lore raw

PATCH v3 1/1 fsck.f2fs: reduce mem alloc during read sit block

This patch reduce mem alloc during read sit block

---
 fsck/fsck.c  | 10 +++++++---
 fsck/fsck.h  |  4 ++--
 fsck/mount.c | 47 ++++++++++++++++++++++++++++-------------------
 3 files changed, 37 insertions(+), 24 deletions(-)
fsck/fsck.c +7 -3
index 6c1b9a7..2172886 100644
@@ -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
index d635c5a..648c2db 100644
@@ -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