Lines Matching refs:sbi
31 u32 get_free_segments(struct f2fs_sb_info *sbi) in get_free_segments() argument
35 for (i = 0; i < TOTAL_SEGS(sbi); i++) { in get_free_segments()
36 struct seg_entry *se = get_seg_entry(sbi, i); in get_free_segments()
38 if (se->valid_blocks == 0x0 && !IS_CUR_SEGNO(sbi, i)) in get_free_segments()
44 void update_free_segments(struct f2fs_sb_info *sbi) in update_free_segments() argument
52 MSG(0, "\r [ %c ] Free segments: 0x%x", progress[i % 5], get_free_segments(sbi)); in update_free_segments()
170 void print_inode_info(struct f2fs_sb_info *sbi, in print_inode_info() argument
259 xattr_addr = read_all_xattrs(sbi, node); in print_inode_info()
268 void print_node_info(struct f2fs_sb_info *sbi, in print_node_info() argument
276 print_inode_info(sbi, node_block, verbose); in print_node_info()
348 void print_ckpt_info(struct f2fs_sb_info *sbi) in print_ckpt_info() argument
350 struct f2fs_checkpoint *cp = F2FS_CKPT(sbi); in print_ckpt_info()
662 int validate_super_block(struct f2fs_sb_info *sbi, enum SB_ADDR sb_addr) in validate_super_block() argument
666 sbi->raw_super = malloc(sizeof(struct f2fs_super_block)); in validate_super_block()
667 if (!sbi->raw_super) in validate_super_block()
673 memcpy(sbi->raw_super, buf + F2FS_SUPER_OFFSET, in validate_super_block()
676 if (!sanity_check_raw_super(sbi->raw_super, sb_addr)) { in validate_super_block()
686 memcpy(c.sb_version, sbi->raw_super->version, VERSION_LEN); in validate_super_block()
688 memcpy(c.init_version, sbi->raw_super->init_version, VERSION_LEN); in validate_super_block()
695 memcpy(sbi->raw_super->version, in validate_super_block()
697 update_superblock(sbi->raw_super, SB_MASK(sb_addr)); in validate_super_block()
702 print_sb_state(sbi->raw_super); in validate_super_block()
706 free(sbi->raw_super); in validate_super_block()
707 sbi->raw_super = NULL; in validate_super_block()
713 int init_sb_info(struct f2fs_sb_info *sbi) in init_sb_info() argument
715 struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi); in init_sb_info()
719 sbi->log_sectors_per_block = get_sb(log_sectors_per_block); in init_sb_info()
720 sbi->log_blocksize = get_sb(log_blocksize); in init_sb_info()
721 sbi->blocksize = 1 << sbi->log_blocksize; in init_sb_info()
722 sbi->log_blocks_per_seg = get_sb(log_blocks_per_seg); in init_sb_info()
723 sbi->blocks_per_seg = 1 << sbi->log_blocks_per_seg; in init_sb_info()
724 sbi->segs_per_sec = get_sb(segs_per_sec); in init_sb_info()
725 sbi->secs_per_zone = get_sb(secs_per_zone); in init_sb_info()
726 sbi->total_sections = get_sb(section_count); in init_sb_info()
727 sbi->total_node_count = (get_sb(segment_count_nat) / 2) * in init_sb_info()
728 sbi->blocks_per_seg * NAT_ENTRY_PER_BLOCK; in init_sb_info()
729 sbi->root_ino_num = get_sb(root_ino); in init_sb_info()
730 sbi->node_ino_num = get_sb(node_ino); in init_sb_info()
731 sbi->meta_ino_num = get_sb(meta_ino); in init_sb_info()
732 sbi->cur_victim_sec = NULL_SEGNO; in init_sb_info()
765 total_sectors = get_sb(block_count) << sbi->log_sectors_per_block; in init_sb_info()
772 void *validate_checkpoint(struct f2fs_sb_info *sbi, block_t cp_addr, in validate_checkpoint() argument
777 unsigned long blk_size = sbi->blocksize; in validate_checkpoint()
798 if (get_cp(cp_pack_total_block_count) > sbi->blocks_per_seg) in validate_checkpoint()
836 int get_valid_checkpoint(struct f2fs_sb_info *sbi) in get_valid_checkpoint() argument
838 struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi); in get_valid_checkpoint()
840 unsigned long blk_size = sbi->blocksize; in get_valid_checkpoint()
851 sbi->ckpt = malloc(cp_blks * blk_size); in get_valid_checkpoint()
852 if (!sbi->ckpt) in get_valid_checkpoint()
859 cp1 = validate_checkpoint(sbi, cp_start_blk_no, &cp1_version); in get_valid_checkpoint()
863 cp2 = validate_checkpoint(sbi, cp_start_blk_no, &cp2_version); in get_valid_checkpoint()
868 sbi->cur_cp = 2; in get_valid_checkpoint()
872 sbi->cur_cp = 1; in get_valid_checkpoint()
877 sbi->cur_cp = 1; in get_valid_checkpoint()
881 sbi->cur_cp = 2; in get_valid_checkpoint()
888 memcpy(sbi->ckpt, cur_page, blk_size); in get_valid_checkpoint()
900 unsigned char *ckpt = (unsigned char *)sbi->ckpt; in get_valid_checkpoint()
913 free(sbi->ckpt); in get_valid_checkpoint()
914 sbi->ckpt = NULL; in get_valid_checkpoint()
918 int sanity_check_ckpt(struct f2fs_sb_info *sbi) in sanity_check_ckpt() argument
921 struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi); in sanity_check_ckpt()
922 struct f2fs_checkpoint *cp = F2FS_CKPT(sbi); in sanity_check_ckpt()
964 blocks_per_seg = sbi->blocks_per_seg; in sanity_check_ckpt()
987 cp_pack_start_sum = __start_sum_addr(sbi); in sanity_check_ckpt()
988 cp_payload = __cp_payload(sbi); in sanity_check_ckpt()
1003 pgoff_t current_nat_addr(struct f2fs_sb_info *sbi, nid_t start, int *pack) in current_nat_addr() argument
1005 struct f2fs_nm_info *nm_i = NM_I(sbi); in current_nat_addr()
1011 seg_off = block_off >> sbi->log_blocks_per_seg; in current_nat_addr()
1014 (seg_off << sbi->log_blocks_per_seg << 1) + in current_nat_addr()
1015 (block_off & ((1 << sbi->log_blocks_per_seg) -1))); in current_nat_addr()
1020 block_addr += sbi->blocks_per_seg; in current_nat_addr()
1028 static int f2fs_init_nid_bitmap(struct f2fs_sb_info *sbi) in f2fs_init_nid_bitmap() argument
1030 struct f2fs_nm_info *nm_i = NM_I(sbi); in f2fs_init_nid_bitmap()
1032 struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_HOT_DATA); in f2fs_init_nid_bitmap()
1060 start_blk = current_nat_addr(sbi, nid, NULL); in f2fs_init_nid_bitmap()
1080 if (!IS_VALID_BLK_ADDR(sbi, addr)) { in f2fs_init_nid_bitmap()
1087 if (!IS_VALID_NID(sbi, nid)) { in f2fs_init_nid_bitmap()
1117 void write_nat_bits(struct f2fs_sb_info *sbi, in write_nat_bits() argument
1120 struct f2fs_nm_info *nm_i = NM_I(sbi); in write_nat_bits()
1190 static int check_nat_bits(struct f2fs_sb_info *sbi, in check_nat_bits() argument
1193 struct f2fs_nm_info *nm_i = NM_I(sbi); in check_nat_bits()
1200 struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_HOT_DATA); in check_nat_bits()
1212 blkaddr = get_sb(segment0_blkaddr) + (sbi->cur_cp << in check_nat_bits()
1269 int init_node_manager(struct f2fs_sb_info *sbi) in init_node_manager() argument
1271 struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi); in init_node_manager()
1272 struct f2fs_checkpoint *cp = F2FS_CKPT(sbi); in init_node_manager()
1273 struct f2fs_nm_info *nm_i = NM_I(sbi); in init_node_manager()
1288 nm_i->bitmap_size = __bitmap_size(sbi, NAT_BITMAP); in init_node_manager()
1293 version_bitmap = __bitmap_ptr(sbi, NAT_BITMAP); in init_node_manager()
1299 return f2fs_init_nid_bitmap(sbi); in init_node_manager()
1302 int build_node_manager(struct f2fs_sb_info *sbi) in build_node_manager() argument
1305 sbi->nm_info = malloc(sizeof(struct f2fs_nm_info)); in build_node_manager()
1306 if (!sbi->nm_info) in build_node_manager()
1309 err = init_node_manager(sbi); in build_node_manager()
1316 int build_sit_info(struct f2fs_sb_info *sbi) in build_sit_info() argument
1318 struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi); in build_sit_info()
1319 struct f2fs_checkpoint *cp = F2FS_CKPT(sbi); in build_sit_info()
1331 SM_I(sbi)->sit_info = sit_i; in build_sit_info()
1333 sit_i->sentries = calloc(TOTAL_SEGS(sbi) * sizeof(struct seg_entry), 1); in build_sit_info()
1339 for (start = 0; start < TOTAL_SEGS(sbi); start++) { in build_sit_info()
1349 bitmap_size = __bitmap_size(sbi, SIT_BITMAP); in build_sit_info()
1350 src_bitmap = __bitmap_ptr(sbi, SIT_BITMAP); in build_sit_info()
1361 sit_i->sit_blocks = sit_segs << sbi->log_blocks_per_seg; in build_sit_info()
1381 void reset_curseg(struct f2fs_sb_info *sbi, int type) in reset_curseg() argument
1383 struct curseg_info *curseg = CURSEG_I(sbi, type); in reset_curseg()
1393 se = get_seg_entry(sbi, curseg->segno); in reset_curseg()
1398 static void read_compacted_summaries(struct f2fs_sb_info *sbi) in read_compacted_summaries() argument
1406 start = start_sum_block(sbi); in read_compacted_summaries()
1414 curseg = CURSEG_I(sbi, CURSEG_HOT_DATA); in read_compacted_summaries()
1417 curseg = CURSEG_I(sbi, CURSEG_COLD_DATA); in read_compacted_summaries()
1424 struct curseg_info *curseg = CURSEG_I(sbi, i); in read_compacted_summaries()
1426 reset_curseg(sbi, i); in read_compacted_summaries()
1429 blk_off = sbi->blocks_per_seg; in read_compacted_summaries()
1452 static void restore_node_summary(struct f2fs_sb_info *sbi, in restore_node_summary() argument
1465 addr = START_BLOCK(sbi, segno); in restore_node_summary()
1468 for (i = 0; i < sbi->blocks_per_seg; i++, sum_entry++) { in restore_node_summary()
1477 static void read_normal_summaries(struct f2fs_sb_info *sbi, int type) in read_normal_summaries() argument
1479 struct f2fs_checkpoint *cp = F2FS_CKPT(sbi); in read_normal_summaries()
1489 blk_addr = sum_blk_addr(sbi, NR_CURSEG_TYPE, type); in read_normal_summaries()
1491 blk_addr = sum_blk_addr(sbi, NR_CURSEG_DATA_TYPE, type); in read_normal_summaries()
1495 blk_addr = sum_blk_addr(sbi, NR_CURSEG_NODE_TYPE, in read_normal_summaries()
1498 blk_addr = GET_SUM_BLKADDR(sbi, segno); in read_normal_summaries()
1508 restore_node_summary(sbi, segno, sum_blk); in read_normal_summaries()
1510 curseg = CURSEG_I(sbi, type); in read_normal_summaries()
1512 reset_curseg(sbi, type); in read_normal_summaries()
1516 void update_sum_entry(struct f2fs_sb_info *sbi, block_t blk_addr, in update_sum_entry() argument
1524 segno = GET_SEGNO(sbi, blk_addr); in update_sum_entry()
1525 offset = OFFSET_IN_SEG(sbi, blk_addr); in update_sum_entry()
1527 se = get_seg_entry(sbi, segno); in update_sum_entry()
1529 sum_blk = get_sum_block(sbi, segno, &type); in update_sum_entry()
1535 ret = dev_write_block(sum_blk, GET_SUM_BLKADDR(sbi, segno)); in update_sum_entry()
1543 static void restore_curseg_summaries(struct f2fs_sb_info *sbi) in restore_curseg_summaries() argument
1547 if (is_set_ckpt_flags(F2FS_CKPT(sbi), CP_COMPACT_SUM_FLAG)) { in restore_curseg_summaries()
1548 read_compacted_summaries(sbi); in restore_curseg_summaries()
1553 read_normal_summaries(sbi, type); in restore_curseg_summaries()
1556 static int build_curseg(struct f2fs_sb_info *sbi) in build_curseg() argument
1558 struct f2fs_checkpoint *cp = F2FS_CKPT(sbi); in build_curseg()
1570 SM_I(sbi)->curseg_array = array; in build_curseg()
1587 ASSERT(segno < TOTAL_SEGS(sbi)); in build_curseg()
1591 array[i].zone = GET_ZONENO_FROM_SEGNO(sbi, segno); in build_curseg()
1596 restore_curseg_summaries(sbi); in build_curseg()
1607 static inline void check_seg_range(struct f2fs_sb_info *sbi, unsigned int segno) in check_seg_range() argument
1609 unsigned int end_segno = SM_I(sbi)->segment_count - 1; in check_seg_range()
1613 void get_current_sit_page(struct f2fs_sb_info *sbi, in get_current_sit_page() argument
1616 struct sit_info *sit_i = SIT_I(sbi); in get_current_sit_page()
1621 check_seg_range(sbi, segno); in get_current_sit_page()
1631 void rewrite_current_sit_page(struct f2fs_sb_info *sbi, in rewrite_current_sit_page() argument
1634 struct sit_info *sit_i = SIT_I(sbi); in rewrite_current_sit_page()
1647 void check_block_count(struct f2fs_sb_info *sbi, in check_block_count() argument
1650 struct f2fs_sm_info *sm_info = SM_I(sbi); in check_block_count()
1656 if (GET_SIT_VBLOCKS(raw_sit) > sbi->blocks_per_seg) in check_block_count()
1687 struct seg_entry *get_seg_entry(struct f2fs_sb_info *sbi, in get_seg_entry() argument
1690 struct sit_info *sit_i = SIT_I(sbi); in get_seg_entry()
1694 struct f2fs_summary_block *get_sum_block(struct f2fs_sb_info *sbi, in get_sum_block() argument
1697 struct f2fs_checkpoint *cp = F2FS_CKPT(sbi); in get_sum_block()
1705 ssa_blk = GET_SUM_BLKADDR(sbi, segno); in get_sum_block()
1708 curseg = CURSEG_I(sbi, CURSEG_HOT_NODE + type); in get_sum_block()
1723 curseg = CURSEG_I(sbi, type); in get_sum_block()
1750 int get_sum_entry(struct f2fs_sb_info *sbi, u32 blk_addr, in get_sum_entry() argument
1757 segno = GET_SEGNO(sbi, blk_addr); in get_sum_entry()
1758 offset = OFFSET_IN_SEG(sbi, blk_addr); in get_sum_entry()
1760 sum_blk = get_sum_block(sbi, segno, &type); in get_sum_entry()
1769 static void get_nat_entry(struct f2fs_sb_info *sbi, nid_t nid, in get_nat_entry() argument
1777 if (lookup_nat_in_journal(sbi, nid, raw_nat) >= 0) in get_nat_entry()
1784 block_addr = current_nat_addr(sbi, nid, NULL); in get_nat_entry()
1794 void update_data_blkaddr(struct f2fs_sb_info *sbi, nid_t nid, in update_data_blkaddr() argument
1805 get_node_info(sbi, nid, &ni); in update_data_blkaddr()
1827 get_node_info(sbi, le32_to_cpu(node_blk->footer.ino), &ni); in update_data_blkaddr()
1846 void update_nat_blkaddr(struct f2fs_sb_info *sbi, nid_t ino, in update_nat_blkaddr() argument
1858 block_addr = current_nat_addr(sbi, nid, NULL); in update_nat_blkaddr()
1867 F2FS_FSCK(sbi)->entries[nid] = nat_block->entries[entry_off]; in update_nat_blkaddr()
1874 void get_node_info(struct f2fs_sb_info *sbi, nid_t nid, struct node_info *ni) in get_node_info() argument
1880 node_info_from_raw_nat(ni, &(F2FS_FSCK(sbi)->entries[nid])); in get_node_info()
1886 get_nat_entry(sbi, nid, &raw_nat); in get_node_info()
1890 static int build_sit_entries(struct f2fs_sb_info *sbi) in build_sit_entries() argument
1892 struct sit_info *sit_i = SIT_I(sbi); in build_sit_entries()
1893 struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_COLD_DATA); in build_sit_entries()
1906 for (segno = 0; segno < TOTAL_SEGS(sbi); segno++) { in build_sit_entries()
1909 get_current_sit_page(sbi, segno, sit_blk); in build_sit_entries()
1912 check_block_count(sbi, segno, &sit); in build_sit_entries()
1922 check_block_count(sbi, segno, &sit); in build_sit_entries()
1928 static int build_segment_manager(struct f2fs_sb_info *sbi) in build_segment_manager() argument
1930 struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi); in build_segment_manager()
1931 struct f2fs_checkpoint *cp = F2FS_CKPT(sbi); in build_segment_manager()
1941 sbi->sm_info = sm_info; in build_segment_manager()
1950 if (build_sit_info(sbi) || build_curseg(sbi) || build_sit_entries(sbi)) { in build_segment_manager()
1958 void build_sit_area_bitmap(struct f2fs_sb_info *sbi) in build_sit_area_bitmap() argument
1960 struct f2fs_fsck *fsck = F2FS_FSCK(sbi); in build_sit_area_bitmap()
1961 struct f2fs_sm_info *sm_i = SM_I(sbi); in build_sit_area_bitmap()
1975 for (segno = 0; segno < TOTAL_SEGS(sbi); segno++) { in build_sit_area_bitmap()
1976 se = get_seg_entry(sbi, segno); in build_sit_area_bitmap()
1982 if (le32_to_cpu(sbi->ckpt->cur_node_segno[0]) == segno || in build_sit_area_bitmap()
1983 le32_to_cpu(sbi->ckpt->cur_data_segno[0]) == segno || in build_sit_area_bitmap()
1984 le32_to_cpu(sbi->ckpt->cur_node_segno[1]) == segno || in build_sit_area_bitmap()
1985 le32_to_cpu(sbi->ckpt->cur_data_segno[1]) == segno || in build_sit_area_bitmap()
1986 le32_to_cpu(sbi->ckpt->cur_node_segno[2]) == segno || in build_sit_area_bitmap()
1987 le32_to_cpu(sbi->ckpt->cur_data_segno[2]) == segno) { in build_sit_area_bitmap()
2004 void rewrite_sit_area_bitmap(struct f2fs_sb_info *sbi) in rewrite_sit_area_bitmap() argument
2006 struct f2fs_fsck *fsck = F2FS_FSCK(sbi); in rewrite_sit_area_bitmap()
2007 struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_COLD_DATA); in rewrite_sit_area_bitmap()
2008 struct sit_info *sit_i = SIT_I(sbi); in rewrite_sit_area_bitmap()
2021 for (segno = 0; segno < TOTAL_SEGS(sbi); segno++) { in rewrite_sit_area_bitmap()
2028 get_current_sit_page(sbi, segno, sit_blk); in rewrite_sit_area_bitmap()
2036 se = get_seg_entry(sbi, segno); in rewrite_sit_area_bitmap()
2047 rewrite_current_sit_page(sbi, segno, sit_blk); in rewrite_sit_area_bitmap()
2055 static int flush_sit_journal_entries(struct f2fs_sb_info *sbi) in flush_sit_journal_entries() argument
2057 struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_COLD_DATA); in flush_sit_journal_entries()
2059 struct sit_info *sit_i = SIT_I(sbi); in flush_sit_journal_entries()
2071 se = get_seg_entry(sbi, segno); in flush_sit_journal_entries()
2073 get_current_sit_page(sbi, segno, sit_blk); in flush_sit_journal_entries()
2081 rewrite_current_sit_page(sbi, segno, sit_blk); in flush_sit_journal_entries()
2089 static int flush_nat_journal_entries(struct f2fs_sb_info *sbi) in flush_nat_journal_entries() argument
2091 struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_HOT_DATA); in flush_nat_journal_entries()
2112 block_addr = current_nat_addr(sbi, nid, NULL); in flush_nat_journal_entries()
2126 void flush_journal_entries(struct f2fs_sb_info *sbi) in flush_journal_entries() argument
2128 int n_nats = flush_nat_journal_entries(sbi); in flush_journal_entries()
2129 int n_sits = flush_sit_journal_entries(sbi); in flush_journal_entries()
2132 write_checkpoint(sbi); in flush_journal_entries()
2135 void flush_sit_entries(struct f2fs_sb_info *sbi) in flush_sit_entries() argument
2137 struct sit_info *sit_i = SIT_I(sbi); in flush_sit_entries()
2144 for (segno = 0; segno < TOTAL_SEGS(sbi); segno++) { in flush_sit_entries()
2148 se = get_seg_entry(sbi, segno); in flush_sit_entries()
2153 get_current_sit_page(sbi, segno, sit_blk); in flush_sit_entries()
2158 rewrite_current_sit_page(sbi, segno, sit_blk); in flush_sit_entries()
2164 int find_next_free_block(struct f2fs_sb_info *sbi, u64 *to, int left, int type) in find_next_free_block() argument
2166 struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi); in find_next_free_block()
2176 if (get_free_segments(sbi) <= SM_I(sbi)->reserved_segments + 1) in find_next_free_block()
2179 while (*to >= SM_I(sbi)->main_blkaddr && *to < end_blkaddr) { in find_next_free_block()
2180 segno = GET_SEGNO(sbi, *to); in find_next_free_block()
2181 offset = OFFSET_IN_SEG(sbi, *to); in find_next_free_block()
2183 se = get_seg_entry(sbi, segno); in find_next_free_block()
2185 if (se->valid_blocks == sbi->blocks_per_seg || in find_next_free_block()
2186 IS_CUR_SEGNO(sbi, segno)) { in find_next_free_block()
2187 *to = left ? START_BLOCK(sbi, segno) - 1: in find_next_free_block()
2188 START_BLOCK(sbi, segno + 1); in find_next_free_block()
2193 *to = left ? START_BLOCK(sbi, segno) - 1: in find_next_free_block()
2194 START_BLOCK(sbi, segno + 1); in find_next_free_block()
2198 if (se->valid_blocks == 0 && !(segno % sbi->segs_per_sec)) { in find_next_free_block()
2202 for (i = 1; i < sbi->segs_per_sec; i++) { in find_next_free_block()
2203 se2 = get_seg_entry(sbi, segno + i); in find_next_free_block()
2207 if (i == sbi->segs_per_sec) in find_next_free_block()
2220 void move_curseg_info(struct f2fs_sb_info *sbi, u64 from, int left) in move_curseg_info() argument
2226 struct curseg_info *curseg = CURSEG_I(sbi, i); in move_curseg_info()
2232 ssa_blk = GET_SUM_BLKADDR(sbi, curseg->segno); in move_curseg_info()
2237 ret = find_next_free_block(sbi, &to, left, i); in move_curseg_info()
2241 curseg->segno = GET_SEGNO(sbi, to); in move_curseg_info()
2242 curseg->next_blkoff = OFFSET_IN_SEG(sbi, to); in move_curseg_info()
2246 ssa_blk = GET_SUM_BLKADDR(sbi, curseg->segno); in move_curseg_info()
2253 reset_curseg(sbi, i); in move_curseg_info()
2260 void zero_journal_entries(struct f2fs_sb_info *sbi) in zero_journal_entries() argument
2265 CURSEG_I(sbi, i)->sum_blk->journal.n_nats = 0; in zero_journal_entries()
2268 void write_curseg_info(struct f2fs_sb_info *sbi) in write_curseg_info() argument
2270 struct f2fs_checkpoint *cp = F2FS_CKPT(sbi); in write_curseg_info()
2274 cp->alloc_type[i] = CURSEG_I(sbi, i)->alloc_type; in write_curseg_info()
2276 set_cp(cur_data_segno[i], CURSEG_I(sbi, i)->segno); in write_curseg_info()
2278 CURSEG_I(sbi, i)->next_blkoff); in write_curseg_info()
2282 set_cp(cur_node_segno[n], CURSEG_I(sbi, i)->segno); in write_curseg_info()
2284 CURSEG_I(sbi, i)->next_blkoff); in write_curseg_info()
2289 int lookup_nat_in_journal(struct f2fs_sb_info *sbi, u32 nid, in lookup_nat_in_journal() argument
2292 struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_HOT_DATA); in lookup_nat_in_journal()
2307 void nullify_nat_entry(struct f2fs_sb_info *sbi, u32 nid) in nullify_nat_entry() argument
2309 struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_HOT_DATA); in nullify_nat_entry()
2330 block_addr = current_nat_addr(sbi, nid, NULL); in nullify_nat_entry()
2335 if (nid == F2FS_NODE_INO(sbi) || nid == F2FS_META_INO(sbi)) { in nullify_nat_entry()
2350 void write_checkpoint(struct f2fs_sb_info *sbi) in write_checkpoint() argument
2352 struct f2fs_checkpoint *cp = F2FS_CKPT(sbi); in write_checkpoint()
2353 struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi); in write_checkpoint()
2361 orphan_blks = __start_sum_addr(sbi) - 1; in write_checkpoint()
2369 set_cp(free_segment_count, get_free_segments(sbi)); in write_checkpoint()
2370 set_cp(valid_block_count, sbi->total_valid_block_count); in write_checkpoint()
2380 if (sbi->cur_cp == 2) in write_checkpoint()
2394 struct curseg_info *curseg = CURSEG_I(sbi, i); in write_checkpoint()
2401 ssa_blk = GET_SUM_BLKADDR(sbi, curseg->segno); in write_checkpoint()
2408 write_nat_bits(sbi, sb, cp, sbi->cur_cp); in write_checkpoint()
2419 void build_nat_area_bitmap(struct f2fs_sb_info *sbi) in build_nat_area_bitmap() argument
2421 struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_HOT_DATA); in build_nat_area_bitmap()
2423 struct f2fs_fsck *fsck = F2FS_FSCK(sbi); in build_nat_area_bitmap()
2424 struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi); in build_nat_area_bitmap()
2425 struct f2fs_nm_info *nm_i = NM_I(sbi); in build_nat_area_bitmap()
2440 sbi->log_blocks_per_seg; in build_nat_area_bitmap()
2453 seg_off = block_off >> sbi->log_blocks_per_seg; in build_nat_area_bitmap()
2455 (seg_off << sbi->log_blocks_per_seg << 1) + in build_nat_area_bitmap()
2456 (block_off & ((1 << sbi->log_blocks_per_seg) - 1))); in build_nat_area_bitmap()
2459 block_addr += sbi->blocks_per_seg; in build_nat_area_bitmap()
2468 if ((nid + i) == F2FS_NODE_INO(sbi) || in build_nat_area_bitmap()
2469 (nid + i) == F2FS_META_INO(sbi)) { in build_nat_area_bitmap()
2573 static void tune_sb_features(struct f2fs_sb_info *sbi) in tune_sb_features() argument
2576 struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi); in tune_sb_features()
2593 int f2fs_do_mount(struct f2fs_sb_info *sbi) in f2fs_do_mount() argument
2599 sbi->active_logs = NR_CURSEG_TYPE; in f2fs_do_mount()
2600 ret = validate_super_block(sbi, SB0_ADDR); in f2fs_do_mount()
2602 ret = validate_super_block(sbi, SB1_ADDR); in f2fs_do_mount()
2606 sb = F2FS_RAW_SUPER(sbi); in f2fs_do_mount()
2614 init_sb_info(sbi); in f2fs_do_mount()
2616 ret = get_valid_checkpoint(sbi); in f2fs_do_mount()
2622 if (sanity_check_ckpt(sbi)) { in f2fs_do_mount()
2626 cp = F2FS_CKPT(sbi); in f2fs_do_mount()
2628 print_ckpt_info(sbi); in f2fs_do_mount()
2650 tune_sb_features(sbi); in f2fs_do_mount()
2656 sbi->total_valid_node_count = get_cp(valid_node_count); in f2fs_do_mount()
2657 sbi->total_valid_inode_count = get_cp(valid_inode_count); in f2fs_do_mount()
2658 sbi->user_block_count = get_cp(user_block_count); in f2fs_do_mount()
2659 sbi->total_valid_block_count = get_cp(valid_block_count); in f2fs_do_mount()
2660 sbi->last_valid_block_count = sbi->total_valid_block_count; in f2fs_do_mount()
2661 sbi->alloc_valid_block_count = 0; in f2fs_do_mount()
2663 if (build_segment_manager(sbi)) { in f2fs_do_mount()
2668 if (build_node_manager(sbi)) { in f2fs_do_mount()
2675 if (check_nat_bits(sbi, sb, cp) && c.fix_on) in f2fs_do_mount()
2676 write_nat_bits(sbi, sb, cp, sbi->cur_cp); in f2fs_do_mount()
2681 void f2fs_do_umount(struct f2fs_sb_info *sbi) in f2fs_do_umount() argument
2683 struct sit_info *sit_i = SIT_I(sbi); in f2fs_do_umount()
2684 struct f2fs_sm_info *sm_i = SM_I(sbi); in f2fs_do_umount()
2685 struct f2fs_nm_info *nm_i = NM_I(sbi); in f2fs_do_umount()
2692 free(sbi->nm_info); in f2fs_do_umount()
2695 for (i = 0; i < TOTAL_SEGS(sbi); i++) in f2fs_do_umount()
2706 free(sbi->sm_info); in f2fs_do_umount()
2708 free(sbi->ckpt); in f2fs_do_umount()
2709 free(sbi->raw_super); in f2fs_do_umount()