Lines Matching refs:sbi
168 static void migrate_main(struct f2fs_sb_info *sbi, unsigned int offset) in migrate_main() argument
178 for (i = MAIN_SEGS(sbi) - 1; i >= 0; i--) { in migrate_main()
179 se = get_seg_entry(sbi, i); in migrate_main()
183 for (j = sbi->blocks_per_seg - 1; j >= 0; j--) { in migrate_main()
187 from = START_BLOCK(sbi, i) + j; in migrate_main()
195 get_sum_entry(sbi, from, &sum); in migrate_main()
198 update_data_blkaddr(sbi, le32_to_cpu(sum.nid), in migrate_main()
201 update_nat_blkaddr(sbi, 0, in migrate_main()
207 START_BLOCK(sbi, 0), in migrate_main()
208 START_BLOCK(sbi, 0) + offset); in migrate_main()
211 static void move_ssa(struct f2fs_sb_info *sbi, unsigned int segno, in move_ssa() argument
217 sum_blk = get_sum_block(sbi, segno, &type); in move_ssa()
224 type, segno, GET_SUM_BLKADDR(sbi, segno), in move_ssa()
235 static void migrate_ssa(struct f2fs_sb_info *sbi, in migrate_ssa() argument
238 struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi); in migrate_ssa()
243 MAIN_SEGS(sbi) - offset; in migrate_ssa()
253 move_ssa(sbi, offset++, blkaddr++); in migrate_ssa()
261 offset = MAIN_SEGS(sbi) - 1; in migrate_ssa()
267 move_ssa(sbi, offset--, blkaddr--); in migrate_ssa()
277 static int shrink_nats(struct f2fs_sb_info *sbi, in shrink_nats() argument
280 struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi); in shrink_nats()
281 struct f2fs_nm_info *nm_i = NM_I(sbi); in shrink_nats()
301 seg_off = block_off >> sbi->log_blocks_per_seg; in shrink_nats()
303 (seg_off << sbi->log_blocks_per_seg << 1) + in shrink_nats()
304 (block_off & ((1 << sbi->log_blocks_per_seg) - 1))); in shrink_nats()
307 block_addr += sbi->blocks_per_seg; in shrink_nats()
325 static void migrate_nat(struct f2fs_sb_info *sbi, in migrate_nat() argument
328 struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi); in migrate_nat()
329 struct f2fs_nm_info *nm_i = NM_I(sbi); in migrate_nat()
344 seg_off = block_off >> sbi->log_blocks_per_seg; in migrate_nat()
346 (seg_off << sbi->log_blocks_per_seg << 1) + in migrate_nat()
347 (block_off & ((1 << sbi->log_blocks_per_seg) - 1))); in migrate_nat()
351 block_addr += sbi->blocks_per_seg; in migrate_nat()
359 (seg_off << sbi->log_blocks_per_seg << 1) + in migrate_nat()
360 (block_off & ((1 << sbi->log_blocks_per_seg) - 1))); in migrate_nat()
380 seg_off = block_off >> sbi->log_blocks_per_seg; in migrate_nat()
382 (seg_off << sbi->log_blocks_per_seg << 1) + in migrate_nat()
383 (block_off & ((1 << sbi->log_blocks_per_seg) - 1))); in migrate_nat()
393 static void migrate_sit(struct f2fs_sb_info *sbi, in migrate_sit() argument
396 struct sit_info *sit_i = SIT_I(sbi); in migrate_sit()
401 (sbi->log_blocks_per_seg - 1); in migrate_sit()
415 for (segno = 0; segno < MAIN_SEGS(sbi); segno++) { in migrate_sit()
418 se = get_seg_entry(sbi, segno); in migrate_sit()
451 static void rebuild_checkpoint(struct f2fs_sb_info *sbi, in rebuild_checkpoint() argument
454 struct f2fs_checkpoint *cp = F2FS_CKPT(sbi); in rebuild_checkpoint()
457 struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi); in rebuild_checkpoint()
491 free_segment_count = get_free_segments(sbi); in rebuild_checkpoint()
500 orphan_blks = __start_sum_addr(sbi) - 1; in rebuild_checkpoint()
509 CURSEG_I(sbi, i)->segno - offset); in rebuild_checkpoint()
514 CURSEG_I(sbi, i)->segno - offset); in rebuild_checkpoint()
555 if (sbi->cur_cp == 2) in rebuild_checkpoint()
582 struct curseg_info *curseg = CURSEG_I(sbi, i); in rebuild_checkpoint()
594 write_nat_bits(sbi, new_sb, new_cp, sbi->cur_cp == 1 ? 2 : 1); in rebuild_checkpoint()
606 static int f2fs_resize_check(struct f2fs_sb_info *sbi, struct f2fs_super_block *new_sb) in f2fs_resize_check() argument
608 struct f2fs_checkpoint *cp = F2FS_CKPT(sbi); in f2fs_resize_check()
627 static int f2fs_resize_grow(struct f2fs_sb_info *sbi) in f2fs_resize_grow() argument
629 struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi); in f2fs_resize_grow()
638 flush_journal_entries(sbi); in f2fs_resize_grow()
640 memcpy(new_sb, F2FS_RAW_SUPER(sbi), sizeof(*new_sb)); in f2fs_resize_grow()
644 if (f2fs_resize_check(sbi, new_sb) < 0) in f2fs_resize_grow()
649 err = shrink_nats(sbi, new_sb); in f2fs_resize_grow()
664 err = f2fs_defragment(sbi, old_main_blkaddr, offset, in f2fs_resize_grow()
672 migrate_main(sbi, offset); in f2fs_resize_grow()
674 migrate_ssa(sbi, new_sb, offset_seg); in f2fs_resize_grow()
675 migrate_nat(sbi, new_sb); in f2fs_resize_grow()
676 migrate_sit(sbi, new_sb, offset_seg); in f2fs_resize_grow()
677 rebuild_checkpoint(sbi, new_sb, offset_seg); in f2fs_resize_grow()
685 static int f2fs_resize_shrink(struct f2fs_sb_info *sbi) in f2fs_resize_shrink() argument
687 struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi); in f2fs_resize_shrink()
696 flush_journal_entries(sbi); in f2fs_resize_shrink()
698 memcpy(new_sb, F2FS_RAW_SUPER(sbi), sizeof(*new_sb)); in f2fs_resize_shrink()
702 if (f2fs_resize_check(sbi, new_sb) < 0) in f2fs_resize_shrink()
707 err = shrink_nats(sbi, new_sb); in f2fs_resize_shrink()
723 err = f2fs_defragment(sbi, tmp_end_blkaddr, in f2fs_resize_shrink()
733 rebuild_checkpoint(sbi, new_sb, 0); in f2fs_resize_shrink()
749 int f2fs_resize(struct f2fs_sb_info *sbi) in f2fs_resize() argument
751 struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi); in f2fs_resize()
760 return f2fs_resize_shrink(sbi); in f2fs_resize()
765 return f2fs_resize_grow(sbi); in f2fs_resize()