Lines Matching refs:sbi

166 static void migrate_main(struct f2fs_sb_info *sbi, unsigned int offset)  in migrate_main()  argument
176 for (i = TOTAL_SEGS(sbi) - 1; i >= 0; i--) { in migrate_main()
177 se = get_seg_entry(sbi, i); in migrate_main()
181 for (j = sbi->blocks_per_seg - 1; j >= 0; j--) { in migrate_main()
185 from = START_BLOCK(sbi, i) + j; in migrate_main()
193 get_sum_entry(sbi, from, &sum); in migrate_main()
196 update_data_blkaddr(sbi, le32_to_cpu(sum.nid), in migrate_main()
199 update_nat_blkaddr(sbi, 0, in migrate_main()
205 START_BLOCK(sbi, 0), in migrate_main()
206 START_BLOCK(sbi, 0) + offset); in migrate_main()
209 static void move_ssa(struct f2fs_sb_info *sbi, unsigned int segno, in move_ssa() argument
215 sum_blk = get_sum_block(sbi, segno, &type); in move_ssa()
222 type, segno, GET_SUM_BLKADDR(sbi, segno), in move_ssa()
233 static void migrate_ssa(struct f2fs_sb_info *sbi, in migrate_ssa() argument
236 struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi); in migrate_ssa()
241 TOTAL_SEGS(sbi) - offset; in migrate_ssa()
251 move_ssa(sbi, offset++, blkaddr++); in migrate_ssa()
259 offset = TOTAL_SEGS(sbi) - 1; in migrate_ssa()
265 move_ssa(sbi, offset--, blkaddr--); in migrate_ssa()
275 static int shrink_nats(struct f2fs_sb_info *sbi, in shrink_nats() argument
278 struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi); in shrink_nats()
279 struct f2fs_nm_info *nm_i = NM_I(sbi); in shrink_nats()
299 seg_off = block_off >> sbi->log_blocks_per_seg; in shrink_nats()
301 (seg_off << sbi->log_blocks_per_seg << 1) + in shrink_nats()
302 (block_off & ((1 << sbi->log_blocks_per_seg) - 1))); in shrink_nats()
305 block_addr += sbi->blocks_per_seg; in shrink_nats()
323 static void migrate_nat(struct f2fs_sb_info *sbi, in migrate_nat() argument
326 struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi); in migrate_nat()
327 struct f2fs_nm_info *nm_i = NM_I(sbi); in migrate_nat()
342 seg_off = block_off >> sbi->log_blocks_per_seg; in migrate_nat()
344 (seg_off << sbi->log_blocks_per_seg << 1) + in migrate_nat()
345 (block_off & ((1 << sbi->log_blocks_per_seg) - 1))); in migrate_nat()
349 block_addr += sbi->blocks_per_seg; in migrate_nat()
357 (seg_off << sbi->log_blocks_per_seg << 1) + in migrate_nat()
358 (block_off & ((1 << sbi->log_blocks_per_seg) - 1))); in migrate_nat()
378 seg_off = block_off >> sbi->log_blocks_per_seg; in migrate_nat()
380 (seg_off << sbi->log_blocks_per_seg << 1) + in migrate_nat()
381 (block_off & ((1 << sbi->log_blocks_per_seg) - 1))); in migrate_nat()
390 static void migrate_sit(struct f2fs_sb_info *sbi, in migrate_sit() argument
393 struct sit_info *sit_i = SIT_I(sbi); in migrate_sit()
398 (sbi->log_blocks_per_seg - 1); in migrate_sit()
412 for (segno = 0; segno < TOTAL_SEGS(sbi); segno++) { in migrate_sit()
415 se = get_seg_entry(sbi, segno); in migrate_sit()
448 static void rebuild_checkpoint(struct f2fs_sb_info *sbi, in rebuild_checkpoint() argument
451 struct f2fs_checkpoint *cp = F2FS_CKPT(sbi); in rebuild_checkpoint()
454 struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi); in rebuild_checkpoint()
478 free_segment_count = get_free_segments(sbi); in rebuild_checkpoint()
487 orphan_blks = __start_sum_addr(sbi) - 1; in rebuild_checkpoint()
496 CURSEG_I(sbi, i)->segno - offset); in rebuild_checkpoint()
501 CURSEG_I(sbi, i)->segno - offset); in rebuild_checkpoint()
529 if (sbi->cur_cp == 2) in rebuild_checkpoint()
556 struct curseg_info *curseg = CURSEG_I(sbi, i); in rebuild_checkpoint()
568 write_nat_bits(sbi, new_sb, new_cp, sbi->cur_cp == 1 ? 2 : 1); in rebuild_checkpoint()
580 static int f2fs_resize_grow(struct f2fs_sb_info *sbi) in f2fs_resize_grow() argument
582 struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi); in f2fs_resize_grow()
591 flush_journal_entries(sbi); in f2fs_resize_grow()
593 memcpy(new_sb, F2FS_RAW_SUPER(sbi), sizeof(*new_sb)); in f2fs_resize_grow()
599 err = shrink_nats(sbi, new_sb); in f2fs_resize_grow()
614 err = f2fs_defragment(sbi, old_main_blkaddr, offset, in f2fs_resize_grow()
622 migrate_main(sbi, offset); in f2fs_resize_grow()
624 migrate_ssa(sbi, new_sb, offset_seg); in f2fs_resize_grow()
625 migrate_nat(sbi, new_sb); in f2fs_resize_grow()
626 migrate_sit(sbi, new_sb, offset_seg); in f2fs_resize_grow()
627 rebuild_checkpoint(sbi, new_sb, offset_seg); in f2fs_resize_grow()
635 static int f2fs_resize_shrink(struct f2fs_sb_info *sbi) in f2fs_resize_shrink() argument
637 struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi); in f2fs_resize_shrink()
646 flush_journal_entries(sbi); in f2fs_resize_shrink()
648 memcpy(new_sb, F2FS_RAW_SUPER(sbi), sizeof(*new_sb)); in f2fs_resize_shrink()
654 err = shrink_nats(sbi, new_sb); in f2fs_resize_shrink()
670 err = f2fs_defragment(sbi, tmp_end_blkaddr, in f2fs_resize_shrink()
680 rebuild_checkpoint(sbi, new_sb, 0); in f2fs_resize_shrink()
696 int f2fs_resize(struct f2fs_sb_info *sbi) in f2fs_resize() argument
698 struct f2fs_super_block *sb = F2FS_RAW_SUPER(sbi); in f2fs_resize()
707 return f2fs_resize_shrink(sbi); in f2fs_resize()
711 return f2fs_resize_grow(sbi); in f2fs_resize()