Lines Matching refs:sbi
14 u32 get_free_segments(struct f2fs_sb_info *sbi) in get_free_segments() argument
18 for (i = 0; i < TOTAL_SEGS(sbi); i++) { in get_free_segments()
19 struct seg_entry *se = get_seg_entry(sbi, i); in get_free_segments()
22 !IS_CUR_SEGNO(sbi, i, NO_CHECK_TYPE)) in get_free_segments()
28 void update_free_segments(struct f2fs_sb_info *sbi) in update_free_segments() argument
33 MSG(0, "\r [ %c ] Free segments: 0x%x", progress[i % 5], get_free_segments(sbi)); in update_free_segments()
190 void print_ckpt_info(struct f2fs_sb_info *sbi) in print_ckpt_info() argument
192 struct f2fs_checkpoint *cp = F2FS_CKPT(sbi); in print_ckpt_info()
421 int validate_super_block(struct f2fs_sb_info *sbi, int block) in validate_super_block() argument
425 sbi->raw_super = malloc(sizeof(struct f2fs_super_block)); in validate_super_block()
432 if (dev_read(sbi->raw_super, offset, sizeof(struct f2fs_super_block))) in validate_super_block()
435 if (!sanity_check_raw_super(sbi->raw_super, offset)) { in validate_super_block()
445 memcpy(c.sb_version, sbi->raw_super->version, VERSION_LEN); in validate_super_block()
447 memcpy(c.init_version, sbi->raw_super->init_version, VERSION_LEN); in validate_super_block()
456 memcpy(sbi->raw_super->version, in validate_super_block()
458 ret = dev_write(sbi->raw_super, offset, in validate_super_block()
465 print_sb_state(sbi->raw_super); in validate_super_block()
469 free(sbi->raw_super); in validate_super_block()
470 sbi->raw_super = NULL; in validate_super_block()
476 int init_sb_info(struct f2fs_sb_info *sbi) in init_sb_info() argument
478 struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi); in init_sb_info()
482 sbi->log_sectors_per_block = get_sb(log_sectors_per_block); in init_sb_info()
483 sbi->log_blocksize = get_sb(log_blocksize); in init_sb_info()
484 sbi->blocksize = 1 << sbi->log_blocksize; in init_sb_info()
485 sbi->log_blocks_per_seg = get_sb(log_blocks_per_seg); in init_sb_info()
486 sbi->blocks_per_seg = 1 << sbi->log_blocks_per_seg; in init_sb_info()
487 sbi->segs_per_sec = get_sb(segs_per_sec); in init_sb_info()
488 sbi->secs_per_zone = get_sb(secs_per_zone); in init_sb_info()
489 sbi->total_sections = get_sb(section_count); in init_sb_info()
490 sbi->total_node_count = (get_sb(segment_count_nat) / 2) * in init_sb_info()
491 sbi->blocks_per_seg * NAT_ENTRY_PER_BLOCK; in init_sb_info()
492 sbi->root_ino_num = get_sb(root_ino); in init_sb_info()
493 sbi->node_ino_num = get_sb(node_ino); in init_sb_info()
494 sbi->meta_ino_num = get_sb(meta_ino); in init_sb_info()
495 sbi->cur_victim_sec = NULL_SEGNO; in init_sb_info()
528 total_sectors = get_sb(block_count) << sbi->log_sectors_per_block; in init_sb_info()
535 void *validate_checkpoint(struct f2fs_sb_info *sbi, block_t cp_addr, in validate_checkpoint() argument
540 unsigned long blk_size = sbi->blocksize; in validate_checkpoint()
592 int get_valid_checkpoint(struct f2fs_sb_info *sbi) in get_valid_checkpoint() argument
594 struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi); in get_valid_checkpoint()
596 unsigned long blk_size = sbi->blocksize; in get_valid_checkpoint()
607 sbi->ckpt = malloc(cp_blks * blk_size); in get_valid_checkpoint()
608 if (!sbi->ckpt) in get_valid_checkpoint()
615 cp1 = validate_checkpoint(sbi, cp_start_blk_no, &cp1_version); in get_valid_checkpoint()
619 cp2 = validate_checkpoint(sbi, cp_start_blk_no, &cp2_version); in get_valid_checkpoint()
624 sbi->cur_cp = 2; in get_valid_checkpoint()
628 sbi->cur_cp = 1; in get_valid_checkpoint()
633 sbi->cur_cp = 1; in get_valid_checkpoint()
637 sbi->cur_cp = 2; in get_valid_checkpoint()
644 memcpy(sbi->ckpt, cur_page, blk_size); in get_valid_checkpoint()
656 unsigned char *ckpt = (unsigned char *)sbi->ckpt; in get_valid_checkpoint()
669 free(sbi->ckpt); in get_valid_checkpoint()
670 sbi->ckpt = NULL; in get_valid_checkpoint()
674 int sanity_check_ckpt(struct f2fs_sb_info *sbi) in sanity_check_ckpt() argument
677 struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi); in sanity_check_ckpt()
678 struct f2fs_checkpoint *cp = F2FS_CKPT(sbi); in sanity_check_ckpt()
693 static pgoff_t current_nat_addr(struct f2fs_sb_info *sbi, nid_t start) in current_nat_addr() argument
695 struct f2fs_nm_info *nm_i = NM_I(sbi); in current_nat_addr()
701 seg_off = block_off >> sbi->log_blocks_per_seg; in current_nat_addr()
704 (seg_off << sbi->log_blocks_per_seg << 1) + in current_nat_addr()
705 (block_off & ((1 << sbi->log_blocks_per_seg) -1))); in current_nat_addr()
708 block_addr += sbi->blocks_per_seg; in current_nat_addr()
713 static int f2fs_init_nid_bitmap(struct f2fs_sb_info *sbi) in f2fs_init_nid_bitmap() argument
715 struct f2fs_nm_info *nm_i = NM_I(sbi); in f2fs_init_nid_bitmap()
717 struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_HOT_DATA); in f2fs_init_nid_bitmap()
741 start_blk = current_nat_addr(sbi, nid); in f2fs_init_nid_bitmap()
779 void write_nat_bits(struct f2fs_sb_info *sbi, in write_nat_bits() argument
782 struct f2fs_nm_info *nm_i = NM_I(sbi); in write_nat_bits()
847 int init_node_manager(struct f2fs_sb_info *sbi) in init_node_manager() argument
849 struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi); in init_node_manager()
850 struct f2fs_checkpoint *cp = F2FS_CKPT(sbi); in init_node_manager()
851 struct f2fs_nm_info *nm_i = NM_I(sbi); in init_node_manager()
866 nm_i->bitmap_size = __bitmap_size(sbi, NAT_BITMAP); in init_node_manager()
871 version_bitmap = __bitmap_ptr(sbi, NAT_BITMAP); in init_node_manager()
877 return f2fs_init_nid_bitmap(sbi); in init_node_manager()
880 int build_node_manager(struct f2fs_sb_info *sbi) in build_node_manager() argument
883 sbi->nm_info = malloc(sizeof(struct f2fs_nm_info)); in build_node_manager()
884 if (!sbi->nm_info) in build_node_manager()
887 err = init_node_manager(sbi); in build_node_manager()
894 int build_sit_info(struct f2fs_sb_info *sbi) in build_sit_info() argument
896 struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi); in build_sit_info()
897 struct f2fs_checkpoint *cp = F2FS_CKPT(sbi); in build_sit_info()
907 SM_I(sbi)->sit_info = sit_i; in build_sit_info()
909 sit_i->sentries = calloc(TOTAL_SEGS(sbi) * sizeof(struct seg_entry), 1); in build_sit_info()
913 for (start = 0; start < TOTAL_SEGS(sbi); start++) { in build_sit_info()
924 bitmap_size = __bitmap_size(sbi, SIT_BITMAP); in build_sit_info()
925 src_bitmap = __bitmap_ptr(sbi, SIT_BITMAP); in build_sit_info()
931 sit_i->sit_blocks = sit_segs << sbi->log_blocks_per_seg; in build_sit_info()
941 void reset_curseg(struct f2fs_sb_info *sbi, int type) in reset_curseg() argument
943 struct curseg_info *curseg = CURSEG_I(sbi, type); in reset_curseg()
953 se = get_seg_entry(sbi, curseg->segno); in reset_curseg()
957 static void read_compacted_summaries(struct f2fs_sb_info *sbi) in read_compacted_summaries() argument
965 start = start_sum_block(sbi); in read_compacted_summaries()
971 curseg = CURSEG_I(sbi, CURSEG_HOT_DATA); in read_compacted_summaries()
974 curseg = CURSEG_I(sbi, CURSEG_COLD_DATA); in read_compacted_summaries()
981 struct curseg_info *curseg = CURSEG_I(sbi, i); in read_compacted_summaries()
983 reset_curseg(sbi, i); in read_compacted_summaries()
986 blk_off = sbi->blocks_per_seg; in read_compacted_summaries()
1009 static void restore_node_summary(struct f2fs_sb_info *sbi, in restore_node_summary() argument
1022 addr = START_BLOCK(sbi, segno); in restore_node_summary()
1025 for (i = 0; i < sbi->blocks_per_seg; i++, sum_entry++) { in restore_node_summary()
1034 static void read_normal_summaries(struct f2fs_sb_info *sbi, int type) in read_normal_summaries() argument
1036 struct f2fs_checkpoint *cp = F2FS_CKPT(sbi); in read_normal_summaries()
1046 blk_addr = sum_blk_addr(sbi, NR_CURSEG_TYPE, type); in read_normal_summaries()
1048 blk_addr = sum_blk_addr(sbi, NR_CURSEG_DATA_TYPE, type); in read_normal_summaries()
1052 blk_addr = sum_blk_addr(sbi, NR_CURSEG_NODE_TYPE, in read_normal_summaries()
1055 blk_addr = GET_SUM_BLKADDR(sbi, segno); in read_normal_summaries()
1063 restore_node_summary(sbi, segno, sum_blk); in read_normal_summaries()
1065 curseg = CURSEG_I(sbi, type); in read_normal_summaries()
1067 reset_curseg(sbi, type); in read_normal_summaries()
1071 void update_sum_entry(struct f2fs_sb_info *sbi, block_t blk_addr, in update_sum_entry() argument
1079 segno = GET_SEGNO(sbi, blk_addr); in update_sum_entry()
1080 offset = OFFSET_IN_SEG(sbi, blk_addr); in update_sum_entry()
1082 se = get_seg_entry(sbi, segno); in update_sum_entry()
1084 sum_blk = get_sum_block(sbi, segno, &type); in update_sum_entry()
1090 ret = dev_write_block(sum_blk, GET_SUM_BLKADDR(sbi, segno)); in update_sum_entry()
1098 static void restore_curseg_summaries(struct f2fs_sb_info *sbi) in restore_curseg_summaries() argument
1102 if (is_set_ckpt_flags(F2FS_CKPT(sbi), CP_COMPACT_SUM_FLAG)) { in restore_curseg_summaries()
1103 read_compacted_summaries(sbi); in restore_curseg_summaries()
1108 read_normal_summaries(sbi, type); in restore_curseg_summaries()
1111 static void build_curseg(struct f2fs_sb_info *sbi) in build_curseg() argument
1113 struct f2fs_checkpoint *cp = F2FS_CKPT(sbi); in build_curseg()
1122 SM_I(sbi)->curseg_array = array; in build_curseg()
1135 ASSERT(segno < TOTAL_SEGS(sbi)); in build_curseg()
1139 array[i].zone = GET_ZONENO_FROM_SEGNO(sbi, segno); in build_curseg()
1144 restore_curseg_summaries(sbi); in build_curseg()
1147 static inline void check_seg_range(struct f2fs_sb_info *sbi, unsigned int segno) in check_seg_range() argument
1149 unsigned int end_segno = SM_I(sbi)->segment_count - 1; in check_seg_range()
1153 struct f2fs_sit_block *get_current_sit_page(struct f2fs_sb_info *sbi, in get_current_sit_page() argument
1156 struct sit_info *sit_i = SIT_I(sbi); in get_current_sit_page()
1164 check_seg_range(sbi, segno); in get_current_sit_page()
1176 void rewrite_current_sit_page(struct f2fs_sb_info *sbi, in rewrite_current_sit_page() argument
1179 struct sit_info *sit_i = SIT_I(sbi); in rewrite_current_sit_page()
1192 void check_block_count(struct f2fs_sb_info *sbi, in check_block_count() argument
1195 struct f2fs_sm_info *sm_info = SM_I(sbi); in check_block_count()
1201 if (GET_SIT_VBLOCKS(raw_sit) > sbi->blocks_per_seg) in check_block_count()
1234 struct seg_entry *get_seg_entry(struct f2fs_sb_info *sbi, in get_seg_entry() argument
1237 struct sit_info *sit_i = SIT_I(sbi); in get_seg_entry()
1241 struct f2fs_summary_block *get_sum_block(struct f2fs_sb_info *sbi, in get_sum_block() argument
1244 struct f2fs_checkpoint *cp = F2FS_CKPT(sbi); in get_sum_block()
1252 ssa_blk = GET_SUM_BLKADDR(sbi, segno); in get_sum_block()
1255 curseg = CURSEG_I(sbi, CURSEG_HOT_NODE + type); in get_sum_block()
1270 curseg = CURSEG_I(sbi, type); in get_sum_block()
1297 int get_sum_entry(struct f2fs_sb_info *sbi, u32 blk_addr, in get_sum_entry() argument
1304 segno = GET_SEGNO(sbi, blk_addr); in get_sum_entry()
1305 offset = OFFSET_IN_SEG(sbi, blk_addr); in get_sum_entry()
1307 sum_blk = get_sum_block(sbi, segno, &type); in get_sum_entry()
1316 static void get_nat_entry(struct f2fs_sb_info *sbi, nid_t nid, in get_nat_entry() argument
1324 if (lookup_nat_in_journal(sbi, nid, raw_nat) >= 0) in get_nat_entry()
1331 block_addr = current_nat_addr(sbi, nid); in get_nat_entry()
1341 void update_data_blkaddr(struct f2fs_sb_info *sbi, nid_t nid, in update_data_blkaddr() argument
1352 get_node_info(sbi, nid, &ni); in update_data_blkaddr()
1372 get_node_info(sbi, le32_to_cpu(node_blk->footer.ino), &ni); in update_data_blkaddr()
1391 void update_nat_blkaddr(struct f2fs_sb_info *sbi, nid_t ino, in update_nat_blkaddr() argument
1403 block_addr = current_nat_addr(sbi, nid); in update_nat_blkaddr()
1417 void get_node_info(struct f2fs_sb_info *sbi, nid_t nid, struct node_info *ni) in get_node_info() argument
1420 get_nat_entry(sbi, nid, &raw_nat); in get_node_info()
1425 void build_sit_entries(struct f2fs_sb_info *sbi) in build_sit_entries() argument
1427 struct sit_info *sit_i = SIT_I(sbi); in build_sit_entries()
1428 struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_COLD_DATA); in build_sit_entries()
1434 for (segno = 0; segno < TOTAL_SEGS(sbi); segno++) { in build_sit_entries()
1438 sit_blk = get_current_sit_page(sbi, segno); in build_sit_entries()
1442 check_block_count(sbi, segno, &sit); in build_sit_entries()
1451 check_block_count(sbi, segno, &sit); in build_sit_entries()
1457 int build_segment_manager(struct f2fs_sb_info *sbi) in build_segment_manager() argument
1459 struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi); in build_segment_manager()
1460 struct f2fs_checkpoint *cp = F2FS_CKPT(sbi); in build_segment_manager()
1468 sbi->sm_info = sm_info; in build_segment_manager()
1477 build_sit_info(sbi); in build_segment_manager()
1479 build_curseg(sbi); in build_segment_manager()
1481 build_sit_entries(sbi); in build_segment_manager()
1486 void build_sit_area_bitmap(struct f2fs_sb_info *sbi) in build_sit_area_bitmap() argument
1488 struct f2fs_fsck *fsck = F2FS_FSCK(sbi); in build_sit_area_bitmap()
1489 struct f2fs_sm_info *sm_i = SM_I(sbi); in build_sit_area_bitmap()
1503 for (segno = 0; segno < TOTAL_SEGS(sbi); segno++) { in build_sit_area_bitmap()
1504 se = get_seg_entry(sbi, segno); in build_sit_area_bitmap()
1510 if (le32_to_cpu(sbi->ckpt->cur_node_segno[0]) == segno || in build_sit_area_bitmap()
1511 le32_to_cpu(sbi->ckpt->cur_data_segno[0]) == segno || in build_sit_area_bitmap()
1512 le32_to_cpu(sbi->ckpt->cur_node_segno[1]) == segno || in build_sit_area_bitmap()
1513 le32_to_cpu(sbi->ckpt->cur_data_segno[1]) == segno || in build_sit_area_bitmap()
1514 le32_to_cpu(sbi->ckpt->cur_node_segno[2]) == segno || in build_sit_area_bitmap()
1515 le32_to_cpu(sbi->ckpt->cur_data_segno[2]) == segno) { in build_sit_area_bitmap()
1532 void rewrite_sit_area_bitmap(struct f2fs_sb_info *sbi) in rewrite_sit_area_bitmap() argument
1534 struct f2fs_fsck *fsck = F2FS_FSCK(sbi); in rewrite_sit_area_bitmap()
1535 struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_COLD_DATA); in rewrite_sit_area_bitmap()
1536 struct sit_info *sit_i = SIT_I(sbi); in rewrite_sit_area_bitmap()
1546 for (segno = 0; segno < TOTAL_SEGS(sbi); segno++) { in rewrite_sit_area_bitmap()
1554 sit_blk = get_current_sit_page(sbi, segno); in rewrite_sit_area_bitmap()
1562 se = get_seg_entry(sbi, segno); in rewrite_sit_area_bitmap()
1573 rewrite_current_sit_page(sbi, segno, sit_blk); in rewrite_sit_area_bitmap()
1580 static int flush_sit_journal_entries(struct f2fs_sb_info *sbi) in flush_sit_journal_entries() argument
1582 struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_COLD_DATA); in flush_sit_journal_entries()
1584 struct sit_info *sit_i = SIT_I(sbi); in flush_sit_journal_entries()
1594 se = get_seg_entry(sbi, segno); in flush_sit_journal_entries()
1596 sit_blk = get_current_sit_page(sbi, segno); in flush_sit_journal_entries()
1604 rewrite_current_sit_page(sbi, segno, sit_blk); in flush_sit_journal_entries()
1612 static int flush_nat_journal_entries(struct f2fs_sb_info *sbi) in flush_nat_journal_entries() argument
1614 struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_HOT_DATA); in flush_nat_journal_entries()
1635 block_addr = current_nat_addr(sbi, nid); in flush_nat_journal_entries()
1649 void flush_journal_entries(struct f2fs_sb_info *sbi) in flush_journal_entries() argument
1651 int n_nats = flush_nat_journal_entries(sbi); in flush_journal_entries()
1652 int n_sits = flush_sit_journal_entries(sbi); in flush_journal_entries()
1655 write_checkpoint(sbi); in flush_journal_entries()
1658 void flush_sit_entries(struct f2fs_sb_info *sbi) in flush_sit_entries() argument
1660 struct f2fs_checkpoint *cp = F2FS_CKPT(sbi); in flush_sit_entries()
1661 struct sit_info *sit_i = SIT_I(sbi); in flush_sit_entries()
1666 for (segno = 0; segno < TOTAL_SEGS(sbi); segno++) { in flush_sit_entries()
1671 se = get_seg_entry(sbi, segno); in flush_sit_entries()
1676 sit_blk = get_current_sit_page(sbi, segno); in flush_sit_entries()
1681 rewrite_current_sit_page(sbi, segno, sit_blk); in flush_sit_entries()
1685 !IS_CUR_SEGNO(sbi, segno, NO_CHECK_TYPE)) in flush_sit_entries()
1692 int find_next_free_block(struct f2fs_sb_info *sbi, u64 *to, int left, int type) in find_next_free_block() argument
1694 struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi); in find_next_free_block()
1702 if (get_free_segments(sbi) <= SM_I(sbi)->reserved_segments + 1) in find_next_free_block()
1705 while (*to >= SM_I(sbi)->main_blkaddr && *to < end_blkaddr) { in find_next_free_block()
1706 segno = GET_SEGNO(sbi, *to); in find_next_free_block()
1707 offset = OFFSET_IN_SEG(sbi, *to); in find_next_free_block()
1709 se = get_seg_entry(sbi, segno); in find_next_free_block()
1711 if (se->valid_blocks == sbi->blocks_per_seg || in find_next_free_block()
1712 IS_CUR_SEGNO(sbi, segno, type)) { in find_next_free_block()
1713 *to = left ? START_BLOCK(sbi, segno) - 1: in find_next_free_block()
1714 START_BLOCK(sbi, segno + 1); in find_next_free_block()
1719 *to = left ? START_BLOCK(sbi, segno) - 1: in find_next_free_block()
1720 START_BLOCK(sbi, segno + 1); in find_next_free_block()
1724 if (se->valid_blocks == 0 && !(segno % sbi->segs_per_sec)) { in find_next_free_block()
1728 for (i = 1; i < sbi->segs_per_sec; i++) { in find_next_free_block()
1729 se2 = get_seg_entry(sbi, segno + i); in find_next_free_block()
1733 if (i == sbi->segs_per_sec) in find_next_free_block()
1746 void move_curseg_info(struct f2fs_sb_info *sbi, u64 from) in move_curseg_info() argument
1752 struct curseg_info *curseg = CURSEG_I(sbi, i); in move_curseg_info()
1758 ssa_blk = GET_SUM_BLKADDR(sbi, curseg->segno); in move_curseg_info()
1763 ret = find_next_free_block(sbi, &to, 0, i); in move_curseg_info()
1767 curseg->segno = GET_SEGNO(sbi, to); in move_curseg_info()
1768 curseg->next_blkoff = OFFSET_IN_SEG(sbi, to); in move_curseg_info()
1772 ssa_blk = GET_SUM_BLKADDR(sbi, curseg->segno); in move_curseg_info()
1779 reset_curseg(sbi, i); in move_curseg_info()
1786 void zero_journal_entries(struct f2fs_sb_info *sbi) in zero_journal_entries() argument
1791 CURSEG_I(sbi, i)->sum_blk->journal.n_nats = 0; in zero_journal_entries()
1794 void write_curseg_info(struct f2fs_sb_info *sbi) in write_curseg_info() argument
1796 struct f2fs_checkpoint *cp = F2FS_CKPT(sbi); in write_curseg_info()
1800 cp->alloc_type[i] = CURSEG_I(sbi, i)->alloc_type; in write_curseg_info()
1802 set_cp(cur_data_segno[i], CURSEG_I(sbi, i)->segno); in write_curseg_info()
1804 CURSEG_I(sbi, i)->next_blkoff); in write_curseg_info()
1808 set_cp(cur_node_segno[n], CURSEG_I(sbi, i)->segno); in write_curseg_info()
1810 CURSEG_I(sbi, i)->next_blkoff); in write_curseg_info()
1815 int lookup_nat_in_journal(struct f2fs_sb_info *sbi, u32 nid, in lookup_nat_in_journal() argument
1818 struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_HOT_DATA); in lookup_nat_in_journal()
1833 void nullify_nat_entry(struct f2fs_sb_info *sbi, u32 nid) in nullify_nat_entry() argument
1835 struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_HOT_DATA); in nullify_nat_entry()
1856 block_addr = current_nat_addr(sbi, nid); in nullify_nat_entry()
1869 void write_checkpoint(struct f2fs_sb_info *sbi) in write_checkpoint() argument
1871 struct f2fs_checkpoint *cp = F2FS_CKPT(sbi); in write_checkpoint()
1872 struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi); in write_checkpoint()
1880 orphan_blks = __start_sum_addr(sbi) - 1; in write_checkpoint()
1884 set_cp(free_segment_count, get_free_segments(sbi)); in write_checkpoint()
1885 set_cp(valid_block_count, sbi->total_valid_block_count); in write_checkpoint()
1895 if (sbi->cur_cp == 2) in write_checkpoint()
1909 struct curseg_info *curseg = CURSEG_I(sbi, i); in write_checkpoint()
1916 ssa_blk = GET_SUM_BLKADDR(sbi, curseg->segno); in write_checkpoint()
1927 write_nat_bits(sbi, sb, cp, sbi->cur_cp); in write_checkpoint()
1930 void build_nat_area_bitmap(struct f2fs_sb_info *sbi) in build_nat_area_bitmap() argument
1932 struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_HOT_DATA); in build_nat_area_bitmap()
1934 struct f2fs_fsck *fsck = F2FS_FSCK(sbi); in build_nat_area_bitmap()
1935 struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi); in build_nat_area_bitmap()
1936 struct f2fs_nm_info *nm_i = NM_I(sbi); in build_nat_area_bitmap()
1951 sbi->log_blocks_per_seg; in build_nat_area_bitmap()
1964 seg_off = block_off >> sbi->log_blocks_per_seg; in build_nat_area_bitmap()
1966 (seg_off << sbi->log_blocks_per_seg << 1) + in build_nat_area_bitmap()
1967 (block_off & ((1 << sbi->log_blocks_per_seg) - 1))); in build_nat_area_bitmap()
1970 block_addr += sbi->blocks_per_seg; in build_nat_area_bitmap()
1979 if ((nid + i) == F2FS_NODE_INO(sbi) || in build_nat_area_bitmap()
1980 (nid + i) == F2FS_META_INO(sbi)) { in build_nat_area_bitmap()
2100 int f2fs_do_mount(struct f2fs_sb_info *sbi) in f2fs_do_mount() argument
2106 sbi->active_logs = NR_CURSEG_TYPE; in f2fs_do_mount()
2107 ret = validate_super_block(sbi, 0); in f2fs_do_mount()
2109 ret = validate_super_block(sbi, 1); in f2fs_do_mount()
2113 sb = F2FS_RAW_SUPER(sbi); in f2fs_do_mount()
2121 init_sb_info(sbi); in f2fs_do_mount()
2123 ret = get_valid_checkpoint(sbi); in f2fs_do_mount()
2129 if (sanity_check_ckpt(sbi)) { in f2fs_do_mount()
2133 cp = F2FS_CKPT(sbi); in f2fs_do_mount()
2135 print_ckpt_info(sbi); in f2fs_do_mount()
2148 sbi->total_valid_node_count = get_cp(valid_node_count); in f2fs_do_mount()
2149 sbi->total_valid_inode_count = get_cp(valid_inode_count); in f2fs_do_mount()
2150 sbi->user_block_count = get_cp(user_block_count); in f2fs_do_mount()
2151 sbi->total_valid_block_count = get_cp(valid_block_count); in f2fs_do_mount()
2152 sbi->last_valid_block_count = sbi->total_valid_block_count; in f2fs_do_mount()
2153 sbi->alloc_valid_block_count = 0; in f2fs_do_mount()
2155 if (build_segment_manager(sbi)) { in f2fs_do_mount()
2160 if (build_node_manager(sbi)) { in f2fs_do_mount()
2172 if (sbi->cur_cp == 2) in f2fs_do_mount()
2184 write_nat_bits(sbi, sb, cp, sbi->cur_cp); in f2fs_do_mount()
2192 void f2fs_do_umount(struct f2fs_sb_info *sbi) in f2fs_do_umount() argument
2194 struct sit_info *sit_i = SIT_I(sbi); in f2fs_do_umount()
2195 struct f2fs_sm_info *sm_i = SM_I(sbi); in f2fs_do_umount()
2196 struct f2fs_nm_info *nm_i = NM_I(sbi); in f2fs_do_umount()
2203 free(sbi->nm_info); in f2fs_do_umount()
2206 for (i = 0; i < TOTAL_SEGS(sbi); i++) { in f2fs_do_umount()
2218 free(sbi->sm_info); in f2fs_do_umount()
2220 free(sbi->ckpt); in f2fs_do_umount()
2221 free(sbi->raw_super); in f2fs_do_umount()