• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
15 void dump_sbi_info(struct f2fs_sb_info *);
16 void hex_info_dump(const char *, const unsigned char *,
17 	unsigned int);
18 
total_segments(struct f2fs_sb_info * sbi)19 static 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 
reserved_segments(struct f2fs_sb_info * sbi)26 static 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 
overprov_segments(struct f2fs_sb_info * sbi)31 static 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 
of_valid_block_count(struct f2fs_sb_info * sbi)36 static inline block_t of_valid_block_count(struct f2fs_sb_info *sbi)
37 {
38 	return sbi->total_valid_block_count;
39 }
40 
f2fs_utilization(struct f2fs_sb_info * sbi)41 static 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_ */