1/** 2 * fsck_debug.h 3 * 4 * Copyright (C) 2024 Huawei Ltd. 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License version 2 as 8 * published by the Free Software Foundation. 9 */ 10#ifndef _FSCK_DEBUG_H_ 11#define _FSCK_DEBUG_H_ 12 13#include "f2fs.h" 14 15void dump_sbi_info(struct f2fs_sb_info *); 16void hex_info_dump(const char *, const unsigned char *, 17 unsigned int); 18 19static inline unsigned int total_segments(struct f2fs_sb_info *sbi) 20{ 21 return sbi->blocks_per_seg == 0 ? 22 0 : ((unsigned int)sbi->user_block_count) / 23 ((unsigned int)sbi->blocks_per_seg); 24} 25 26static inline unsigned int reserved_segments(struct f2fs_sb_info *sbi) 27{ 28 return sbi->sm_info == NULL ? 0 : sbi->sm_info->reserved_segments; 29} 30 31static inline unsigned int overprov_segments(struct f2fs_sb_info *sbi) 32{ 33 return sbi->sm_info == NULL ? 0 : sbi->sm_info->ovp_segments; 34} 35 36static inline block_t of_valid_block_count(struct f2fs_sb_info *sbi) 37{ 38 return sbi->total_valid_block_count; 39} 40 41static inline unsigned int f2fs_utilization(struct f2fs_sb_info *sbi) 42{ 43 /* valid block percentage of sbi */ 44 return sbi->user_block_count == 0 ? 45 0 : (of_valid_block_count(sbi) * 100) / sbi->user_block_count; 46} 47 48#endif /* _FSCK_DEBUG_H_ */