Lines Matching refs:sbi
16 static inline int f2fs_set_main_bitmap(struct f2fs_sb_info *sbi, u32 blk, in f2fs_set_main_bitmap() argument
19 struct f2fs_fsck *fsck = F2FS_FSCK(sbi); in f2fs_set_main_bitmap()
22 se = get_seg_entry(sbi, GET_SEGNO(sbi, blk)); in f2fs_set_main_bitmap()
27 GET_SEGNO(sbi, blk), se->type, in f2fs_set_main_bitmap()
33 GET_SEGNO(sbi, blk), se->type, type); in f2fs_set_main_bitmap()
37 return f2fs_set_bit(BLKOFF_FROM_MAIN(sbi, blk), fsck->main_area_bitmap); in f2fs_set_main_bitmap()
40 static inline int f2fs_test_main_bitmap(struct f2fs_sb_info *sbi, u32 blk) in f2fs_test_main_bitmap() argument
42 struct f2fs_fsck *fsck = F2FS_FSCK(sbi); in f2fs_test_main_bitmap()
44 return f2fs_test_bit(BLKOFF_FROM_MAIN(sbi, blk), in f2fs_test_main_bitmap()
48 static inline int f2fs_test_sit_bitmap(struct f2fs_sb_info *sbi, u32 blk) in f2fs_test_sit_bitmap() argument
50 struct f2fs_fsck *fsck = F2FS_FSCK(sbi); in f2fs_test_sit_bitmap()
52 return f2fs_test_bit(BLKOFF_FROM_MAIN(sbi, blk), fsck->sit_area_bitmap); in f2fs_test_sit_bitmap()
55 static int add_into_hard_link_list(struct f2fs_sb_info *sbi, in add_into_hard_link_list() argument
58 struct f2fs_fsck *fsck = F2FS_FSCK(sbi); in add_into_hard_link_list()
95 static int find_and_dec_hard_link_list(struct f2fs_sb_info *sbi, u32 nid) in find_and_dec_hard_link_list() argument
97 struct f2fs_fsck *fsck = F2FS_FSCK(sbi); in find_and_dec_hard_link_list()
127 static int is_valid_ssa_node_blk(struct f2fs_sb_info *sbi, u32 nid, in is_valid_ssa_node_blk() argument
133 ret = get_sum_entry(sbi, blk_addr, &sum_entry); in is_valid_ssa_node_blk()
144 GET_SUM_BLKADDR(sbi, in is_valid_ssa_node_blk()
145 GET_SEGNO(sbi, blk_addr))); in is_valid_ssa_node_blk()
147 GET_SEGNO(sbi, blk_addr), in is_valid_ssa_node_blk()
148 OFFSET_IN_SEG(sbi, blk_addr)); in is_valid_ssa_node_blk()
158 static int is_valid_ssa_data_blk(struct f2fs_sb_info *sbi, u32 blk_addr, in is_valid_ssa_data_blk() argument
164 ret = get_sum_entry(sbi, blk_addr, &sum_entry); in is_valid_ssa_data_blk()
192 static int sanity_check_nid(struct f2fs_sb_info *sbi, u32 nid, in sanity_check_nid() argument
197 struct f2fs_fsck *fsck = F2FS_FSCK(sbi); in sanity_check_nid()
200 if (!IS_VALID_NID(sbi, nid)) { in sanity_check_nid()
205 get_node_info(sbi, nid, ni); in sanity_check_nid()
211 if (!IS_VALID_BLK_ADDR(sbi, ni->blk_addr)) { in sanity_check_nid()
216 if (is_valid_ssa_node_blk(sbi, nid, ni->blk_addr)) { in sanity_check_nid()
259 if (f2fs_test_main_bitmap(sbi, ni->blk_addr) != 0) { in sanity_check_nid()
274 if (f2fs_test_sit_bitmap(sbi, ni->blk_addr) == 0) in sanity_check_nid()
278 if (f2fs_test_main_bitmap(sbi, ni->blk_addr) == 0) { in sanity_check_nid()
285 static int fsck_chk_xattr_blk(struct f2fs_sb_info *sbi, u32 ino, in fsck_chk_xattr_blk() argument
299 if (sanity_check_nid(sbi, x_nid, node_blk, in fsck_chk_xattr_blk()
306 f2fs_set_main_bitmap(sbi, ni.blk_addr, CURSEG_COLD_NODE); in fsck_chk_xattr_blk()
313 int fsck_chk_node_blk(struct f2fs_sb_info *sbi, struct f2fs_inode *inode, in fsck_chk_node_blk() argument
323 if (sanity_check_nid(sbi, nid, node_blk, ftype, ntype, &ni)) in fsck_chk_node_blk()
327 fsck_chk_inode_blk(sbi, nid, ftype, node_blk, blk_cnt, &ni); in fsck_chk_node_blk()
331 f2fs_set_main_bitmap(sbi, ni.blk_addr, in fsck_chk_node_blk()
333 fsck_chk_dnode_blk(sbi, inode, nid, ftype, node_blk, in fsck_chk_node_blk()
337 f2fs_set_main_bitmap(sbi, ni.blk_addr, in fsck_chk_node_blk()
339 fsck_chk_idnode_blk(sbi, inode, ftype, node_blk, in fsck_chk_node_blk()
343 f2fs_set_main_bitmap(sbi, ni.blk_addr, in fsck_chk_node_blk()
345 fsck_chk_didnode_blk(sbi, inode, ftype, node_blk, in fsck_chk_node_blk()
360 void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid, in fsck_chk_inode_blk() argument
364 struct f2fs_fsck *fsck = F2FS_FSCK(sbi); in fsck_chk_inode_blk()
373 if (f2fs_test_main_bitmap(sbi, ni->blk_addr) == 0) in fsck_chk_inode_blk()
377 f2fs_set_main_bitmap(sbi, ni->blk_addr, CURSEG_HOT_NODE); in fsck_chk_inode_blk()
379 if (f2fs_test_main_bitmap(sbi, ni->blk_addr) == 0) { in fsck_chk_inode_blk()
380 f2fs_set_main_bitmap(sbi, ni->blk_addr, in fsck_chk_inode_blk()
384 add_into_hard_link_list(sbi, nid, i_links); in fsck_chk_inode_blk()
389 if (find_and_dec_hard_link_list(sbi, nid)) { in fsck_chk_inode_blk()
407 if (fsck_chk_xattr_blk(sbi, nid, in fsck_chk_inode_blk()
445 ret = fsck_chk_inline_dentries(sbi, node_blk, in fsck_chk_inode_blk()
461 get_node_info(sbi, nid, &ni); in fsck_chk_inode_blk()
462 if (IS_VALID_BLK_ADDR(sbi, ni.blk_addr)) in fsck_chk_inode_blk()
470 ret = fsck_chk_data_blk(sbi, in fsck_chk_inode_blk()
497 ret = fsck_chk_node_blk(sbi, &node_blk->i, in fsck_chk_inode_blk()
553 int fsck_chk_dnode_blk(struct f2fs_sb_info *sbi, struct f2fs_inode *inode, in fsck_chk_dnode_blk() argument
564 ret = fsck_chk_data_blk(sbi, in fsck_chk_dnode_blk()
584 int fsck_chk_idnode_blk(struct f2fs_sb_info *sbi, struct f2fs_inode *inode, in fsck_chk_idnode_blk() argument
593 ret = fsck_chk_node_blk(sbi, inode, in fsck_chk_idnode_blk()
604 int fsck_chk_didnode_blk(struct f2fs_sb_info *sbi, struct f2fs_inode *inode, in fsck_chk_didnode_blk() argument
613 ret = fsck_chk_node_blk(sbi, inode, in fsck_chk_didnode_blk()
665 static int __chk_dentries(struct f2fs_sb_info *sbi, u32 *child_cnt, in __chk_dentries() argument
672 struct f2fs_fsck *fsck = F2FS_FSCK(sbi); in __chk_dentries()
691 if (IS_VALID_NID(sbi, ino)) { in __chk_dentries()
694 get_node_info(sbi, ino, &ni); in __chk_dentries()
695 if (IS_VALID_BLK_ADDR(sbi, ni.blk_addr)) in __chk_dentries()
707 if (!IS_VALID_NID(sbi, le32_to_cpu(dentry[i].ino))) { in __chk_dentries()
766 ret = fsck_chk_node_blk(sbi, in __chk_dentries()
794 int fsck_chk_inline_dentries(struct f2fs_sb_info *sbi, in fsck_chk_inline_dentries() argument
797 struct f2fs_fsck *fsck = F2FS_FSCK(sbi); in fsck_chk_inline_dentries()
805 dentries = __chk_dentries(sbi, child_cnt, child_files, in fsck_chk_inline_dentries()
822 int fsck_chk_dentry_blk(struct f2fs_sb_info *sbi, u32 blk_addr, in fsck_chk_dentry_blk() argument
825 struct f2fs_fsck *fsck = F2FS_FSCK(sbi); in fsck_chk_dentry_blk()
836 dentries = __chk_dentries(sbi, child_cnt, child_files, in fsck_chk_dentry_blk()
857 int fsck_chk_data_blk(struct f2fs_sb_info *sbi, u32 blk_addr, in fsck_chk_data_blk() argument
861 struct f2fs_fsck *fsck = F2FS_FSCK(sbi); in fsck_chk_data_blk()
869 if (!IS_VALID_BLK_ADDR(sbi, blk_addr)) { in fsck_chk_data_blk()
874 if (is_valid_ssa_data_blk(sbi, blk_addr, parent_nid, in fsck_chk_data_blk()
881 if (f2fs_test_sit_bitmap(sbi, blk_addr) == 0) in fsck_chk_data_blk()
884 if (f2fs_test_main_bitmap(sbi, blk_addr) != 0) in fsck_chk_data_blk()
892 f2fs_set_main_bitmap(sbi, blk_addr, CURSEG_HOT_DATA); in fsck_chk_data_blk()
893 return fsck_chk_dentry_blk(sbi, blk_addr, child_cnt, in fsck_chk_data_blk()
896 f2fs_set_main_bitmap(sbi, blk_addr, CURSEG_WARM_DATA); in fsck_chk_data_blk()
901 void fsck_chk_orphan_node(struct f2fs_sb_info *sbi) in fsck_chk_orphan_node() argument
906 struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi); in fsck_chk_orphan_node()
911 start_blk = __start_cp_addr(sbi) + 1 + in fsck_chk_orphan_node()
912 le32_to_cpu(F2FS_RAW_SUPER(sbi)->cp_payload); in fsck_chk_orphan_node()
913 orphan_blkaddr = __start_sum_addr(sbi) - 1; in fsck_chk_orphan_node()
930 fsck_chk_node_blk(sbi, NULL, ino, in fsck_chk_orphan_node()
938 void fsck_init(struct f2fs_sb_info *sbi) in fsck_init() argument
940 struct f2fs_fsck *fsck = F2FS_FSCK(sbi); in fsck_init()
941 struct f2fs_sm_info *sm_i = SM_I(sbi); in fsck_init()
952 fsck->nr_main_blks = sm_i->main_segments << sbi->log_blocks_per_seg; in fsck_init()
957 build_nat_area_bitmap(sbi); in fsck_init()
959 build_sit_area_bitmap(sbi); in fsck_init()
965 static void fix_nat_entries(struct f2fs_sb_info *sbi) in fix_nat_entries() argument
967 struct f2fs_fsck *fsck = F2FS_FSCK(sbi); in fix_nat_entries()
972 nullify_nat_entry(sbi, i); in fix_nat_entries()
975 static void fix_checkpoint(struct f2fs_sb_info *sbi) in fix_checkpoint() argument
977 struct f2fs_fsck *fsck = F2FS_FSCK(sbi); in fix_checkpoint()
978 struct f2fs_super_block *raw_sb = sbi->raw_super; in fix_checkpoint()
979 struct f2fs_checkpoint *ckp = F2FS_CKPT(sbi); in fix_checkpoint()
1001 if (sbi->cur_cp == 2) in fix_checkpoint()
1014 struct curseg_info *curseg = CURSEG_I(sbi, i); in fix_checkpoint()
1024 int check_curseg_offset(struct f2fs_sb_info *sbi) in check_curseg_offset() argument
1029 struct curseg_info *curseg = CURSEG_I(sbi, i); in check_curseg_offset()
1032 se = get_seg_entry(sbi, curseg->segno); in check_curseg_offset()
1042 int check_sit_types(struct f2fs_sb_info *sbi) in check_sit_types() argument
1047 for (i = 0; i < TOTAL_SEGS(sbi); i++) { in check_sit_types()
1050 se = get_seg_entry(sbi, i); in check_sit_types()
1064 int fsck_verify(struct f2fs_sb_info *sbi) in fsck_verify() argument
1070 struct f2fs_fsck *fsck = F2FS_FSCK(sbi); in fsck_verify()
1121 if (sbi->total_valid_block_count == fsck->chk.valid_blk_cnt) { in fsck_verify()
1130 if (sbi->total_valid_node_count == fsck->chk.valid_node_cnt) { in fsck_verify()
1139 if (sbi->total_valid_node_count == fsck->chk.valid_nat_entry_cnt) { in fsck_verify()
1148 if (sbi->total_valid_inode_count == fsck->chk.valid_inode_cnt) { in fsck_verify()
1157 if (le32_to_cpu(F2FS_CKPT(sbi)->free_segment_count) == in fsck_verify()
1167 if (check_curseg_offset(sbi) == 0) { in fsck_verify()
1176 if (check_sit_types(sbi) != 0) in fsck_verify()
1189 fix_nat_entries(sbi); in fsck_verify()
1190 rewrite_sit_area_bitmap(sbi); in fsck_verify()
1191 fix_checkpoint(sbi); in fsck_verify()
1196 void fsck_free(struct f2fs_sb_info *sbi) in fsck_free() argument
1198 struct f2fs_fsck *fsck = F2FS_FSCK(sbi); in fsck_free()