Lines Matching refs:info
129 static void dbg_print_info_struct(struct f2fs_info *info) in dbg_print_info_struct() argument
135 SLOGD("blocks_per_segment: %" PRIu64, info->blocks_per_segment); in dbg_print_info_struct()
136 SLOGD("block_size: %d", info->block_size); in dbg_print_info_struct()
137 SLOGD("sit_bmp loc: %p", info->sit_bmp); in dbg_print_info_struct()
138 SLOGD("sit_bmp_size: %d", info->sit_bmp_size); in dbg_print_info_struct()
139 SLOGD("blocks_per_sit: %" PRIu64, info->blocks_per_sit); in dbg_print_info_struct()
140 SLOGD("sit_blocks loc: %p", info->sit_blocks); in dbg_print_info_struct()
141 SLOGD("sit_sums loc: %p", info->sit_sums); in dbg_print_info_struct()
142 SLOGD("sit_sums num: %d", le16_to_cpu(info->sit_sums->journal.n_sits)); in dbg_print_info_struct()
144 for(i = 0; i < (le16_to_cpu(info->sit_sums->journal.n_sits)); i++) { in dbg_print_info_struct()
146 le32_to_cpu(segno_in_journal(&info->sit_sums->journal, i))); in dbg_print_info_struct()
149 SLOGD("cp_blkaddr: %" PRIu64, info->cp_blkaddr); in dbg_print_info_struct()
150 SLOGD("cp_valid_cp_blkaddr: %" PRIu64, info->cp_valid_cp_blkaddr); in dbg_print_info_struct()
151 SLOGD("sit_blkaddr: %" PRIu64, info->sit_blkaddr); in dbg_print_info_struct()
152 SLOGD("nat_blkaddr: %" PRIu64, info->nat_blkaddr); in dbg_print_info_struct()
153 SLOGD("ssa_blkaddr: %" PRIu64, info->ssa_blkaddr); in dbg_print_info_struct()
154 SLOGD("main_blkaddr: %" PRIu64, info->main_blkaddr); in dbg_print_info_struct()
155 SLOGD("total_user_used: %" PRIu64, info->total_user_used); in dbg_print_info_struct()
156 SLOGD("total_blocks: %" PRIu64, info->total_blocks); in dbg_print_info_struct()
262 …int_info(int fd, struct f2fs_super_block *sb, struct f2fs_checkpoint **cp, struct f2fs_info *info) in get_valid_checkpoint_info() argument
289 info->cp_valid_cp_blkaddr = cp2_start_blk_no; in get_valid_checkpoint_info()
293 info->cp_valid_cp_blkaddr = cp1_start_blk_no; in get_valid_checkpoint_info()
298 info->cp_valid_cp_blkaddr = cp1_start_blk_no; in get_valid_checkpoint_info()
301 info->cp_valid_cp_blkaddr = cp2_start_blk_no; in get_valid_checkpoint_info()
315 static int gather_sit_info(int fd, struct f2fs_info *info) in gather_sit_info() argument
317 u64 num_segments = (info->total_blocks - info->main_blkaddr in gather_sit_info()
318 + info->blocks_per_segment - 1) / info->blocks_per_segment; in gather_sit_info()
322 info->sit_blocks = malloc(num_sit_blocks * sizeof(struct f2fs_sit_block)); in gather_sit_info()
323 if (!info->sit_blocks) in gather_sit_info()
327 off64_t address = info->sit_blkaddr + sit_block; in gather_sit_info()
329 if (f2fs_test_bit(sit_block, info->sit_bmp)) in gather_sit_info()
330 address += info->blocks_per_sit; in gather_sit_info()
333 …if (read_structure(fd, address * F2FS_BLKSIZE, &info->sit_blocks[sit_block], sizeof(struct f2fs_si… in gather_sit_info()
335 free(info->sit_blocks); in gather_sit_info()
348 static inline u64 sum_blk_addr(struct f2fs_checkpoint *cp, struct f2fs_info *info, int base, int ty… in sum_blk_addr() argument
350 return info->cp_valid_cp_blkaddr + le32_to_cpu(cp->cp_pack_total_block_count) in sum_blk_addr()
354 static int get_sit_summary(int fd, struct f2fs_info *info, struct f2fs_checkpoint *cp) in get_sit_summary() argument
358 info->sit_sums = calloc(1, sizeof(struct f2fs_summary_block)); in get_sit_summary()
359 if (!info->sit_sums) in get_sit_summary()
364 …if (read_structure_blk(fd, info->cp_valid_cp_blkaddr + le32_to_cpu(cp->cp_pack_start_sum), buffer,… in get_sit_summary()
366 memcpy(&info->sit_sums->journal.n_sits, &buffer[SUM_JOURNAL_SIZE], SUM_JOURNAL_SIZE); in get_sit_summary()
370 blk_addr = sum_blk_addr(cp, info, NR_CURSEG_TYPE, CURSEG_COLD_DATA); in get_sit_summary()
372 blk_addr = sum_blk_addr(cp, info, NR_CURSEG_DATA_TYPE, CURSEG_COLD_DATA); in get_sit_summary()
377 memcpy(info->sit_sums, buffer, sizeof(struct f2fs_summary_block)); in get_sit_summary()
386 struct f2fs_info *info; in generate_f2fs_info() local
388 info = calloc(1, sizeof(*info)); in generate_f2fs_info()
389 if (!info) { in generate_f2fs_info()
397 free(info); in generate_f2fs_info()
402 free(info); in generate_f2fs_info()
408 info->cp_blkaddr = le32_to_cpu(sb->cp_blkaddr); in generate_f2fs_info()
409 info->sit_blkaddr = le32_to_cpu(sb->sit_blkaddr); in generate_f2fs_info()
410 info->nat_blkaddr = le32_to_cpu(sb->nat_blkaddr); in generate_f2fs_info()
411 info->ssa_blkaddr = le32_to_cpu(sb->ssa_blkaddr); in generate_f2fs_info()
412 info->main_blkaddr = le32_to_cpu(sb->main_blkaddr); in generate_f2fs_info()
413 info->block_size = F2FS_BLKSIZE; in generate_f2fs_info()
414 info->total_blocks = sb->block_count; in generate_f2fs_info()
415 …info->blocks_per_sit = (le32_to_cpu(sb->segment_count_sit) >> 1) << le32_to_cpu(sb->log_blocks_per… in generate_f2fs_info()
416 info->blocks_per_segment = 1U << le32_to_cpu(sb->log_blocks_per_seg); in generate_f2fs_info()
418 if (get_valid_checkpoint_info(fd, sb, &cp, info)) in generate_f2fs_info()
422 info->total_user_used = le32_to_cpu(cp->valid_block_count); in generate_f2fs_info()
427 info->sit_bmp = malloc(bmp_size); in generate_f2fs_info()
428 if(!info->sit_bmp) { in generate_f2fs_info()
433 info->sit_bmp_size = bmp_size; in generate_f2fs_info()
434 if (read_structure(fd, info->cp_valid_cp_blkaddr * F2FS_BLKSIZE in generate_f2fs_info()
436 info->sit_bmp, bmp_size)) { in generate_f2fs_info()
441 if (gather_sit_info(fd , info)) { in generate_f2fs_info()
445 if (get_sit_summary(fd, info, cp)) { in generate_f2fs_info()
449 dbg_print_info_struct(info); in generate_f2fs_info()
450 return info; in generate_f2fs_info()
454 free_f2fs_info(info); in generate_f2fs_info()
458 void free_f2fs_info(struct f2fs_info *info) in free_f2fs_info() argument
460 if (info) { in free_f2fs_info()
461 free(info->sit_blocks); in free_f2fs_info()
462 info->sit_blocks = NULL; in free_f2fs_info()
464 free(info->sit_bmp); in free_f2fs_info()
465 info->sit_bmp = NULL; in free_f2fs_info()
467 free(info->sit_sums); in free_f2fs_info()
468 info->sit_sums = NULL; in free_f2fs_info()
470 free(info); in free_f2fs_info()
473 u64 get_num_blocks_used(struct f2fs_info *info) in get_num_blocks_used() argument
475 return info->main_blkaddr + info->total_user_used; in get_num_blocks_used()
488 int run_on_used_blocks(u64 startblock, struct f2fs_info *info, int (*func)(u64 pos, void *data), vo… in run_on_used_blocks() argument
496 while (block < info->total_blocks) { in run_on_used_blocks()
498 if (block < info->main_blkaddr) { in run_on_used_blocks()
505 segnum = (block - info->main_blkaddr)/info->blocks_per_segment; in run_on_used_blocks()
509 for(i = 0; i < le16_to_cpu(info->sit_sums->journal.n_sits); i++) { in run_on_used_blocks()
510 if (le32_to_cpu(segno_in_journal(&info->sit_sums->journal, i)) == segnum) { in run_on_used_blocks()
511 sit_entry = &sit_in_journal(&info->sit_sums->journal, i); in run_on_used_blocks()
520 … sit_entry = &info->sit_blocks[sit_block_num_cur].entries[segnum % SIT_ENTRY_PER_BLOCK]; in run_on_used_blocks()
523 block_offset = (block - info->main_blkaddr) % info->blocks_per_segment; in run_on_used_blocks()
526 block += info->blocks_per_segment; in run_on_used_blocks()
549 struct f2fs_info *info; member
562 int pdone = (pos * 100) / d->info->total_blocks; in copy_used()
615 struct f2fs_info *info = generate_f2fs_info(infd); in main() local
616 if (!info) { in main()
625 d.info = info; in main()
626 int expected_count = get_num_blocks_used(info); in main()
627 run_on_used_blocks(0, info, ©_used, &d); in main()
629 ftruncate64(outfd, info->total_blocks * F2FS_BLKSIZE); in main()
630 free_f2fs_info(info); in main()