xref: /freebsd/sys/contrib/openzfs/include/libzdb.h (revision 2f9966ff63d65bd474478888c9088eeae3f9c669)
1 #define	ZDB_COMPRESS_NAME(idx) ((idx) < ZIO_COMPRESS_FUNCTIONS ?	\
2 	zio_compress_table[(idx)].ci_name : "UNKNOWN")
3 #define	ZDB_CHECKSUM_NAME(idx) ((idx) < ZIO_CHECKSUM_FUNCTIONS ?	\
4 	zio_checksum_table[(idx)].ci_name : "UNKNOWN")
5 #define	ZDB_OT_TYPE(idx) ((idx) < DMU_OT_NUMTYPES ? (idx) :		\
6 	(idx) == DMU_OTN_ZAP_DATA || (idx) == DMU_OTN_ZAP_METADATA ?	\
7 	DMU_OT_ZAP_OTHER : \
8 	(idx) == DMU_OTN_UINT64_DATA || (idx) == DMU_OTN_UINT64_METADATA ? \
9 	DMU_OT_UINT64_OTHER : DMU_OT_NUMTYPES)
10 
11 /* Some platforms require part of inode IDs to be remapped */
12 #ifdef __APPLE__
13 #define	ZDB_MAP_OBJECT_ID(obj) INO_XNUTOZFS(obj, 2)
14 #else
15 #define	ZDB_MAP_OBJECT_ID(obj) (obj)
16 #endif
17 
18 #define	ZOR_FLAG_PLAIN_FILE	0x0001
19 #define	ZOR_FLAG_DIRECTORY	0x0002
20 #define	ZOR_FLAG_SPACE_MAP	0x0004
21 #define	ZOR_FLAG_ZAP		0x0008
22 #define	ZOR_FLAG_ALL_TYPES	-1
23 #define	ZOR_SUPPORTED_FLAGS	(ZOR_FLAG_PLAIN_FILE	| \
24 				ZOR_FLAG_DIRECTORY	| \
25 				ZOR_FLAG_SPACE_MAP	| \
26 				ZOR_FLAG_ZAP)
27 
28 #define	ZDB_FLAG_CHECKSUM	0x0001
29 #define	ZDB_FLAG_DECOMPRESS	0x0002
30 #define	ZDB_FLAG_BSWAP		0x0004
31 #define	ZDB_FLAG_GBH		0x0008
32 #define	ZDB_FLAG_INDIRECT	0x0010
33 #define	ZDB_FLAG_RAW		0x0020
34 #define	ZDB_FLAG_PRINT_BLKPTR	0x0040
35 #define	ZDB_FLAG_VERBOSE	0x0080
36 
37 
38 typedef struct zdb_ctx {
39 } zdb_ctx_t;
40 
41 typedef struct zopt_object_range {
42 	uint64_t zor_obj_start;
43 	uint64_t zor_obj_end;
44 	uint64_t zor_flags;
45 } zopt_object_range_t;
46 
47 
48 typedef struct sublivelist_verify {
49 	/* FREE's that haven't yet matched to an ALLOC, in one sub-livelist */
50 	zfs_btree_t sv_pair;
51 
52 	/* ALLOC's without a matching FREE, accumulates across sub-livelists */
53 	zfs_btree_t sv_leftover;
54 } sublivelist_verify_t;
55 
56 typedef struct sublivelist_verify_block {
57 	dva_t svb_dva;
58 
59 	/*
60 	 * We need this to check if the block marked as allocated
61 	 * in the livelist was freed (and potentially reallocated)
62 	 * in the metaslab spacemaps at a later TXG.
63 	 */
64 	uint64_t svb_allocated_txg;
65 } sublivelist_verify_block_t;
66 
67 const char *zdb_ot_name(dmu_object_type_t type);
68 int livelist_compare(const void *larg, const void *rarg);
69