fsck.f2fs: avoid false alarm on SIT type fix
PATCH 1/1 fsck.f2fs: avoid false alarm on SIT type fix
This patch removed a false alarm when detecting any inconsistency in SIT types.
Signed-off-by Jaegeuk Kim <[email protected]>
--- fsck/f2fs.h | 1 + fsck/fsck.c | 35 ++++++++++++++++++++++++++++++----- fsck/mount.c | 1 + 3 files changed, 32 insertions(+), 5 deletions(-)
fsck/f2fs.h +1 -0
@@ -72,6 +72,7 @@ struct seg_entry {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/fsck.c +30 -5
@@ -23,17 +23,15 @@ static inline int f2fs_set_main_bitmap(struct f2fs_sb_info *sbi, u32 blk,if (se->type != type) {if (type ==CURSEG_WARM_DATA ) {if (se->type !=CURSEG_COLD_DATA ) { -FIX_MSG ("Wrong segment type [0x%x] %x -> %x" , +DBG (1 ,"Wrong segment type [0x%x] %x -> %x" ,GET_SEGNO (sbi, blk), se->type,CURSEG_WARM_DATA ); se->type =CURSEG_WARM_DATA ; - config.bug_on =1 ; } }else { -FIX_MSG ("Wrong segment type [0x%x] %x -> %x" , +DBG (1 ,"Wrong segment type [0x%x] %x -> %x" ,GET_SEGNO (sbi, blk), se->type, type); se->type = type; - config.bug_on =1 ; } }return f2fs_set_bit (BLKOFF_FROM_MAIN (sbi, blk), fsck->main_area_bitmap);
@@ -998,6 +996,25 @@ int check_curseg_offset(struct f2fs_sb_info *sbi)return 0 ; } +int check_sit_types (struct f2fs_sb_info *sbi) +{ +struct seg_entry *se; +unsigned int i; +int err =0 ; + +for (i =0 ; i <TOTAL_SEGS (sbi); i++) { +struct seg_entry *se; + + se =get_seg_entry (sbi, i); +if (se->orig_type != se->type) { +FIX_MSG ("Wrong segment type [0x%x] %x -> %x" , + i, se->orig_type, se->type); + err = -EINVAL ; + } + } +return err; +} +int fsck_verify (struct f2fs_sb_info *sbi) {unsigned int i =0 ;
@@ -1108,13 +1125,21 @@ int fsck_verify(struct f2fs_sb_info *sbi) config.bug_on =1 ; } +printf ("[FSCK] SIT types " ); +if (check_sit_types (sbi) ==0 ) { +printf (" [Ok..]\n" ); + }else { +printf (" [Fail]\n" ); + ret =EXIT_ERR_CODE ; + config.bug_on =1 ; + } +printf ("[FSCK] other corrupted bugs " );if (config.bug_on ==0 ) {printf (" [Ok..]\n" ); }else {printf (" [Fail]\n" ); ret =EXIT_ERR_CODE ; - config.bug_on =1 ; }/* fix global metadata */
fsck/mount.c +1 -0
@@ -795,6 +795,7 @@ void seg_info_from_raw_sit(struct seg_entry *se,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); }
Signature · 9 lines
2.1.1 ------------------------------------------------------------------------------ Comprehensive Server Monitoring with Site24x7. Monitor 10 servers for $9/Month. Get alerted through email, SMS, voice calls or mobile push notifications. Take corrective actions from your mobile device. http://pubads.g.doubleclick.net/gampad/clk?id=154624111&iu=/4140/ostg.clktrk