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
285 info->cp_valid_cp_blkaddr = cp2_start_blk_no; in get_valid_checkpoint_info()
289 info->cp_valid_cp_blkaddr = cp1_start_blk_no; in get_valid_checkpoint_info()
294 info->cp_valid_cp_blkaddr = cp1_start_blk_no; in get_valid_checkpoint_info()
297 info->cp_valid_cp_blkaddr = cp2_start_blk_no; in get_valid_checkpoint_info()
311 static int gather_sit_info(int fd, struct f2fs_info *info) in gather_sit_info() argument
313 uint64_t num_segments = (info->total_blocks - info->main_blkaddr in gather_sit_info()
314 + info->blocks_per_segment - 1) / info->blocks_per_segment; in gather_sit_info()
318 info->sit_blocks = malloc(num_sit_blocks * sizeof(struct f2fs_sit_block)); in gather_sit_info()
319 if (!info->sit_blocks) in gather_sit_info()
323 off64_t address = info->sit_blkaddr + sit_block; in gather_sit_info()
325 if (f2fs_test_bit(sit_block, info->sit_bmp)) in gather_sit_info()
326 address += info->blocks_per_sit; in gather_sit_info()
329 …if (read_structure(fd, address * F2FS_BLKSIZE, &info->sit_blocks[sit_block], sizeof(struct f2fs_si… in gather_sit_info()
331 free(info->sit_blocks); in gather_sit_info()
332 info->sit_blocks = NULL; in gather_sit_info()
345 static inline uint64_t sum_blk_addr(struct f2fs_checkpoint *cp, struct f2fs_info *info, int base, i… in sum_blk_addr() argument
347 return info->cp_valid_cp_blkaddr + le32_to_cpu(cp->cp_pack_total_block_count) in sum_blk_addr()
351 static int get_sit_summary(int fd, struct f2fs_info *info, struct f2fs_checkpoint *cp) in get_sit_summary() argument
355 info->sit_sums = calloc(1, sizeof(struct f2fs_summary_block)); in get_sit_summary()
356 if (!info->sit_sums) in get_sit_summary()
361 …if (read_structure_blk(fd, info->cp_valid_cp_blkaddr + le32_to_cpu(cp->cp_pack_start_sum), buffer,… in get_sit_summary()
363 memcpy(&info->sit_sums->journal.n_sits, &buffer[SUM_JOURNAL_SIZE], SUM_JOURNAL_SIZE); in get_sit_summary()
367 blk_addr = sum_blk_addr(cp, info, NR_CURSEG_TYPE, CURSEG_COLD_DATA); in get_sit_summary()
369 blk_addr = sum_blk_addr(cp, info, NR_CURSEG_DATA_TYPE, CURSEG_COLD_DATA); in get_sit_summary()
374 memcpy(info->sit_sums, buffer, sizeof(struct f2fs_summary_block)); in get_sit_summary()
383 struct f2fs_info *info; in generate_f2fs_info() local
385 info = calloc(1, sizeof(*info)); in generate_f2fs_info()
386 if (!info) { in generate_f2fs_info()
394 free(info); in generate_f2fs_info()
399 free(info); in generate_f2fs_info()
405 info->cp_blkaddr = le32_to_cpu(sb->cp_blkaddr); in generate_f2fs_info()
406 info->sit_blkaddr = le32_to_cpu(sb->sit_blkaddr); in generate_f2fs_info()
407 info->nat_blkaddr = le32_to_cpu(sb->nat_blkaddr); in generate_f2fs_info()
408 info->ssa_blkaddr = le32_to_cpu(sb->ssa_blkaddr); in generate_f2fs_info()
409 info->main_blkaddr = le32_to_cpu(sb->main_blkaddr); in generate_f2fs_info()
410 info->block_size = F2FS_BLKSIZE; in generate_f2fs_info()
411 info->total_blocks = sb->block_count; in generate_f2fs_info()
412info->blocks_per_sit = (le32_to_cpu(sb->segment_count_sit) >> 1) << le32_to_cpu(sb->log_blocks_per… in generate_f2fs_info()
413 info->blocks_per_segment = 1U << le32_to_cpu(sb->log_blocks_per_seg); in generate_f2fs_info()
415 if (get_valid_checkpoint_info(fd, sb, &cp, info)) in generate_f2fs_info()
419 info->total_user_used = le32_to_cpu(cp->valid_block_count); in generate_f2fs_info()
424 info->sit_bmp = malloc(bmp_size); in generate_f2fs_info()
425 if(!info->sit_bmp) { in generate_f2fs_info()
430 info->sit_bmp_size = bmp_size; in generate_f2fs_info()
431 if (read_structure(fd, info->cp_valid_cp_blkaddr * F2FS_BLKSIZE in generate_f2fs_info()
433 info->sit_bmp, bmp_size)) { in generate_f2fs_info()
438 if (gather_sit_info(fd , info)) { in generate_f2fs_info()
442 if (get_sit_summary(fd, info, cp)) { in generate_f2fs_info()
446 dbg_print_info_struct(info); in generate_f2fs_info()
447 return info; in generate_f2fs_info()
451 free_f2fs_info(info); in generate_f2fs_info()
455 void free_f2fs_info(struct f2fs_info *info) in free_f2fs_info() argument
457 if (info) { in free_f2fs_info()
458 free(info->sit_blocks); in free_f2fs_info()
459 info->sit_blocks = NULL; in free_f2fs_info()
461 free(info->sit_bmp); in free_f2fs_info()
462 info->sit_bmp = NULL; in free_f2fs_info()
464 free(info->sit_sums); in free_f2fs_info()
465 info->sit_sums = NULL; in free_f2fs_info()
467 free(info); in free_f2fs_info()
470 uint64_t get_num_blocks_used(struct f2fs_info *info) in get_num_blocks_used() argument
472 return info->main_blkaddr + info->total_user_used; in get_num_blocks_used()
485 int run_on_used_blocks(uint64_t startblock, struct f2fs_info *info, int (*func)(uint64_t pos, void … in run_on_used_blocks() argument
492 while (block < info->total_blocks) { in run_on_used_blocks()
494 if (block < info->main_blkaddr) { in run_on_used_blocks()
501 segnum = (block - info->main_blkaddr)/info->blocks_per_segment; in run_on_used_blocks()
505 for(i = 0; i < le16_to_cpu(info->sit_sums->journal.n_sits); i++) { in run_on_used_blocks()
506 if (le32_to_cpu(segno_in_journal(&info->sit_sums->journal, i)) == segnum) { in run_on_used_blocks()
507 sit_entry = &sit_in_journal(&info->sit_sums->journal, i); in run_on_used_blocks()
516 … sit_entry = &info->sit_blocks[sit_block_num_cur].entries[segnum % SIT_ENTRY_PER_BLOCK]; in run_on_used_blocks()
519 block_offset = (block - info->main_blkaddr) % info->blocks_per_segment; in run_on_used_blocks()
522 block += info->blocks_per_segment; in run_on_used_blocks()
545 struct f2fs_info *info; member
558 int pdone = (pos * 100) / d->info->total_blocks; in copy_used()
611 struct f2fs_info *info = generate_f2fs_info(infd); in main() local
612 if (!info) { in main()
621 d.info = info; in main()
622 int expected_count = get_num_blocks_used(info); in main()
623 run_on_used_blocks(0, info, &copy_used, &d); in main()
625 ftruncate64(outfd, info->total_blocks * F2FS_BLKSIZE); in main()
626 free_f2fs_info(info); in main()