dump.f2fs: Retrun directly if blkaddr is not valid
PATCH 1/2 dump.f2fs: Retrun directly if blkaddr is not valid
Retrun directly if blkaddr is not valid.
--- fsck/dump.c | 10 ++++++++++ fsck/mount.c | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-)
fsck/dump.c +10 -0
@@ -586,6 +586,8 @@ int dump_info_from_blkaddr(struct f2fs_sb_info *sbi, u32 blk_addr)int type;struct f2fs_summary sum_entry;struct node_info ni, ino_ni; +struct seg_entry *se; +u32 offset;int ret =0 ;MSG (0 ,"\n== Dump data from block address ==\n\n" );
@@ -617,6 +619,14 @@ int dump_info_from_blkaddr(struct f2fs_sb_info *sbi, u32 blk_addr)return ret; } + se =get_seg_entry (sbi,GET_SEGNO (sbi, blk_addr)); + offset =OFFSET_IN_SEG (sbi, blk_addr); + +if (f2fs_test_bit (offset, (const char *)se->cur_valid_map) ==0 ) { +MSG (0 ,"\nblkaddr is not valid\n" ); +return 0 ; + } + type =get_sum_entry (sbi, blk_addr, &sum_entry); nid =le32_to_cpu (sum_entry.nid);
fsck/mount.c +1 -1
@@ -1869,7 +1869,7 @@ int find_next_free_block(struct f2fs_sb_info *sbi, u64 *to, int left, int type)struct f2fs_super_block *sb =F2FS_RAW_SUPER (sbi);struct seg_entry *se;u32 segno; -u64 offset; +u32 offset;int not_enough =0 ;u64 end_blkaddr = (get_sb (segment_count_main) <<get_sb (log_blocks_per_seg)) +get_sb (main_blkaddr);
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
PATCH 2/2 fsck.f2fs: Remove unused ckpt_valid_map info
Remove unused ckpt_valid_map info.
--- fsck/f2fs.h | 6 ------ fsck/mount.c | 12 +++--------- 2 files changed, 3 insertions(+), 15 deletions(-)
fsck/f2fs.h +0 -6
@@ -65,12 +65,6 @@ struct f2fs_nm_info {struct seg_entry {unsigned short valid_blocks;/* # of valid blocks */ unsigned char *cur_valid_map;/* validity bitmap of blocks */ -/* -* # of valid blocks and the validity bitmap stored in the the last -* checkpoint pack. This information is used by the SSR mode. -*/ -unsigned short ckpt_valid_blocks; -unsigned char *ckpt_valid_map;unsigned char type;/* segment type like CURSEG_XXX_TYPE */ unsigned char orig_type;/* segment type like CURSEG_XXX_TYPE */ unsigned long long mtime;/* modification time of the segment */
fsck/mount.c +3 -9
@@ -1086,10 +1086,7 @@ int build_sit_info(struct f2fs_sb_info *sbi)for (start =0 ; start <TOTAL_SEGS (sbi); start++) { sit_i->sentries[start].cur_valid_map =calloc (SIT_VBLOCK_MAP_SIZE ,1 ); - sit_i->sentries[start].ckpt_valid_map - =calloc (SIT_VBLOCK_MAP_SIZE ,1 ); -if (!sit_i->sentries[start].cur_valid_map - || !sit_i->sentries[start].ckpt_valid_map) +if (!sit_i->sentries[start].cur_valid_map)return -ENOMEM ; }
@@ -1396,9 +1393,7 @@ void seg_info_from_raw_sit(struct seg_entry *se, struct f2fs_sit_entry *raw_sit) { se->valid_blocks =GET_SIT_VBLOCKS (raw_sit); - se->ckpt_valid_blocks =GET_SIT_VBLOCKS (raw_sit);memcpy (se->cur_valid_map, raw_sit->valid_map,SIT_VBLOCK_MAP_SIZE ); -memcpy (se->ckpt_valid_map, raw_sit->valid_map,SIT_VBLOCK_MAP_SIZE ); se->type =GET_SIT_TYPE (raw_sit); se->orig_type =GET_SIT_TYPE (raw_sit); se->mtime =le64_to_cpu (raw_sit->mtime);
@@ -2398,10 +2393,9 @@ void f2fs_do_umount(struct f2fs_sb_info *sbi)free (sbi->nm_info);/* free sit_info */ -for (i =0 ; i <TOTAL_SEGS (sbi); i++) { +for (i =0 ; i <TOTAL_SEGS (sbi); i++)free (sit_i->sentries[i].cur_valid_map); -free (sit_i->sentries[i].ckpt_valid_map); - } +free (sit_i->sit_bitmap);free (sm_i->sit_info);
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
Re: [PATCH 2/2] fsck.f2fs: Remove unused ckpt_valid_map info
Quoted 3 lines · Yunlei He
Remove unused
ckpt_valid_mapinfo.Signed-off-by Yunlei He <[email protected]>
Thanks,
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Quoted 1 line · Yunlei He
Retrun directly if blkaddr is not valid.
SIT info can be wrong, how about just printing that blkaddr is invalid during dumping?
Thanks,
Quoted 41 lines
Signed-off-by Yunlei He <[email protected]>--- fsck/dump.c | 10 ++++++++++ fsck/mount.c | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-)fsck/dump.c +10
-0@@ -586,6 +586,8 @@ int dump_info_from_blkaddr(struct f2fs_sb_info *sbi, u32 blk_addr)int type;struct f2fs_summary sum_entry;struct node_info ni, ino_ni; +struct seg_entry *se; +u32 offset;int ret =0 ;MSG (0 ,"\n== Dump data from block address ==\n\n" );@@ -617,6 +619,14 @@ int dump_info_from_blkaddr(struct f2fs_sb_info *sbi, u32 blk_addr)return ret; } + se =get_seg_entry (sbi,GET_SEGNO (sbi, blk_addr)); + offset =OFFSET_IN_SEG (sbi, blk_addr); + +if (f2fs_test_bit (offset, (const char *)se->cur_valid_map) ==0 ) { +MSG (0 ,"\nblkaddr is not valid\n" ); +return 0 ; + } + type =get_sum_entry (sbi, blk_addr, &sum_entry); nid =le32_to_cpu (sum_entry.nid);fsck/mount.c +0
-0
fsck/mount.c int find_next_free_block(struct f2fs_sb_info *sbi, u64 *to, int left, int type) · line 1875
Quoted 8 lines
fsck/mount.c +1
-1@@ -1869,7 +1869,7 @@ int find_next_free_block(struct f2fs_sb_info *sbi, u64 *to, int left, int type)struct f2fs_super_block *sb =F2FS_RAW_SUPER (sbi);struct seg_entry *se;u32 segno; -u64 offset; +u32 offset;int not_enough =0 ;u64 end_blkaddr = (get_sb (segment_count_main) <<get_sb (log_blocks_per_seg)) +get_sb (main_blkaddr);
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot