]>
Commit | Line | Data |
---|---|---|
37b3b4d6 | 1 | // SPDX-License-Identifier: GPL-2.0 |
2bd0ea18 | 2 | /* |
f302e9e4 NS |
3 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
4 | * All Rights Reserved. | |
2bd0ea18 NS |
5 | */ |
6 | #ifndef __XFS_TYPES_H__ | |
dfc130f3 | 7 | #define __XFS_TYPES_H__ |
2bd0ea18 | 8 | |
4a492e72 | 9 | typedef uint32_t prid_t; /* project ID */ |
a2ceac1f | 10 | |
4a492e72 DW |
11 | typedef uint32_t xfs_agblock_t; /* blockno in alloc. group */ |
12 | typedef uint32_t xfs_agino_t; /* inode # within allocation grp */ | |
13 | typedef uint32_t xfs_extlen_t; /* extent length in blocks */ | |
73b5e770 | 14 | typedef uint32_t xfs_rtxlen_t; /* file extent length in rtextents */ |
4a492e72 | 15 | typedef uint32_t xfs_agnumber_t; /* allocation group number */ |
4b85994a CB |
16 | typedef uint64_t xfs_extnum_t; /* # of extents in a file */ |
17 | typedef uint32_t xfs_aextnum_t; /* # extents in an attribute fork */ | |
4a492e72 DW |
18 | typedef int64_t xfs_fsize_t; /* bytes in a file */ |
19 | typedef uint64_t xfs_ufsize_t; /* unsigned bytes in a file */ | |
2bd0ea18 | 20 | |
4a492e72 | 21 | typedef int32_t xfs_suminfo_t; /* type of bitmap summary info */ |
ccffd2f9 | 22 | typedef uint32_t xfs_rtsumoff_t; /* offset of an rtsummary info word */ |
a531149e | 23 | typedef uint32_t xfs_rtword_t; /* word type for bitmap manipulations */ |
2bd0ea18 | 24 | |
4a492e72 | 25 | typedef int64_t xfs_lsn_t; /* log sequence number */ |
08602f16 | 26 | typedef int64_t xfs_csn_t; /* CIL sequence number */ |
2bd0ea18 | 27 | |
4a492e72 DW |
28 | typedef uint32_t xfs_dablk_t; /* dir/attr block number (in file) */ |
29 | typedef uint32_t xfs_dahash_t; /* dir/attr hash value */ | |
2bd0ea18 | 30 | |
4a492e72 DW |
31 | typedef uint64_t xfs_fsblock_t; /* blockno in filesystem (agno|agbno) */ |
32 | typedef uint64_t xfs_rfsblock_t; /* blockno in filesystem (raw) */ | |
33 | typedef uint64_t xfs_rtblock_t; /* extent (block) in realtime area */ | |
34 | typedef uint64_t xfs_fileoff_t; /* block number in a file */ | |
35 | typedef uint64_t xfs_filblks_t; /* number of blocks in a file */ | |
817e9237 | 36 | typedef uint64_t xfs_rtxnum_t; /* rtextent number */ |
3fb28b11 | 37 | typedef uint64_t xfs_rtbxlen_t; /* rtbitmap extent length in rtextents */ |
2bd0ea18 | 38 | |
4a492e72 | 39 | typedef int64_t xfs_srtblock_t; /* signed version of xfs_rtblock_t */ |
a2ceac1f | 40 | |
b47beff8 DW |
41 | /* |
42 | * New verifiers will return the instruction address of the failing check. | |
43 | * NULL means everything is ok. | |
44 | */ | |
45 | typedef void * xfs_failaddr_t; | |
46 | ||
2bd0ea18 NS |
47 | /* |
48 | * Null values for the types. | |
49 | */ | |
dfc130f3 RC |
50 | #define NULLFSBLOCK ((xfs_fsblock_t)-1) |
51 | #define NULLRFSBLOCK ((xfs_rfsblock_t)-1) | |
52 | #define NULLRTBLOCK ((xfs_rtblock_t)-1) | |
53 | #define NULLFILEOFF ((xfs_fileoff_t)-1) | |
817e9237 | 54 | #define NULLRTEXTNO ((xfs_rtxnum_t)-1) |
2bd0ea18 | 55 | |
dfc130f3 RC |
56 | #define NULLAGBLOCK ((xfs_agblock_t)-1) |
57 | #define NULLAGNUMBER ((xfs_agnumber_t)-1) | |
2bd0ea18 NS |
58 | |
59 | #define NULLCOMMITLSN ((xfs_lsn_t)-1) | |
60 | ||
a2ceac1f DC |
61 | #define NULLFSINO ((xfs_ino_t)-1) |
62 | #define NULLAGINO ((xfs_agino_t)-1) | |
63 | ||
a2ceac1f DC |
64 | /* |
65 | * Minimum and maximum blocksize and sectorsize. | |
66 | * The blocksize upper limit is pretty much arbitrary. | |
67 | * The sectorsize upper limit is due to sizeof(sb_sectsize). | |
e24ee60b DC |
68 | * CRC enable filesystems use 512 byte inodes, meaning 512 byte block sizes |
69 | * cannot be used. | |
a2ceac1f DC |
70 | */ |
71 | #define XFS_MIN_BLOCKSIZE_LOG 9 /* i.e. 512 bytes */ | |
72 | #define XFS_MAX_BLOCKSIZE_LOG 16 /* i.e. 65536 bytes */ | |
73 | #define XFS_MIN_BLOCKSIZE (1 << XFS_MIN_BLOCKSIZE_LOG) | |
74 | #define XFS_MAX_BLOCKSIZE (1 << XFS_MAX_BLOCKSIZE_LOG) | |
e24ee60b | 75 | #define XFS_MIN_CRC_BLOCKSIZE (1 << (XFS_MIN_BLOCKSIZE_LOG + 1)) |
a2ceac1f DC |
76 | #define XFS_MIN_SECTORSIZE_LOG 9 /* i.e. 512 bytes */ |
77 | #define XFS_MAX_SECTORSIZE_LOG 15 /* i.e. 32768 bytes */ | |
78 | #define XFS_MIN_SECTORSIZE (1 << XFS_MIN_SECTORSIZE_LOG) | |
79 | #define XFS_MAX_SECTORSIZE (1 << XFS_MAX_SECTORSIZE_LOG) | |
80 | ||
2d4bfb91 DC |
81 | /* |
82 | * Inode fork identifiers. | |
83 | */ | |
84 | #define XFS_DATA_FORK 0 | |
85 | #define XFS_ATTR_FORK 1 | |
cb8a004a | 86 | #define XFS_COW_FORK 2 |
2d4bfb91 | 87 | |
b4751eea DW |
88 | #define XFS_WHICHFORK_STRINGS \ |
89 | { XFS_DATA_FORK, "data" }, \ | |
90 | { XFS_ATTR_FORK, "attr" }, \ | |
91 | { XFS_COW_FORK, "cow" } | |
92 | ||
ca86e759 NS |
93 | /* |
94 | * Min numbers of data/attr fork btree root pointers. | |
95 | */ | |
96 | #define MINDBTPTRS 3 | |
97 | #define MINABTPTRS 2 | |
98 | ||
2bd0ea18 NS |
99 | /* |
100 | * MAXNAMELEN is the length (including the terminating null) of | |
101 | * the longest permissible file (component) name. | |
102 | */ | |
103 | #define MAXNAMELEN 256 | |
104 | ||
3eb6b563 DW |
105 | /* |
106 | * This enum is used in string mapping in xfs_trace.h; please keep the | |
107 | * TRACE_DEFINE_ENUMs for it up to date. | |
108 | */ | |
2bd0ea18 NS |
109 | typedef enum { |
110 | XFS_LOOKUP_EQi, XFS_LOOKUP_LEi, XFS_LOOKUP_GEi | |
111 | } xfs_lookup_t; | |
112 | ||
a47d8371 DW |
113 | #define XFS_AG_BTREE_CMP_FORMAT_STR \ |
114 | { XFS_LOOKUP_EQi, "eq" }, \ | |
115 | { XFS_LOOKUP_LEi, "le" }, \ | |
116 | { XFS_LOOKUP_GEi, "ge" } | |
117 | ||
6823e536 | 118 | /* |
7c3bcec7 DW |
119 | * This enum is used in string mapping in xfs_trace.h and scrub/trace.h; |
120 | * please keep the TRACE_DEFINE_ENUMs for it up to date. | |
6823e536 | 121 | */ |
2bd0ea18 | 122 | typedef enum { |
e37838e5 | 123 | XFS_BTNUM_BNOi, XFS_BTNUM_CNTi, XFS_BTNUM_RMAPi, XFS_BTNUM_BMAPi, |
88ce0792 | 124 | XFS_BTNUM_INOi, XFS_BTNUM_FINOi, XFS_BTNUM_REFCi, XFS_BTNUM_MAX |
2bd0ea18 NS |
125 | } xfs_btnum_t; |
126 | ||
6823e536 DW |
127 | #define XFS_BTNUM_STRINGS \ |
128 | { XFS_BTNUM_BNOi, "bnobt" }, \ | |
129 | { XFS_BTNUM_CNTi, "cntbt" }, \ | |
130 | { XFS_BTNUM_RMAPi, "rmapbt" }, \ | |
131 | { XFS_BTNUM_BMAPi, "bmbt" }, \ | |
132 | { XFS_BTNUM_INOi, "inobt" }, \ | |
133 | { XFS_BTNUM_FINOi, "finobt" }, \ | |
134 | { XFS_BTNUM_REFCi, "refcbt" } | |
135 | ||
5e656dbb | 136 | struct xfs_name { |
56b2de80 DC |
137 | const unsigned char *name; |
138 | int len; | |
494434d7 | 139 | int type; |
5e656dbb BN |
140 | }; |
141 | ||
dcbc51df DC |
142 | /* |
143 | * uid_t and gid_t are hard-coded to 32 bits in the inode. | |
144 | * Hence, an 'id' in a dquot is 32 bits.. | |
145 | */ | |
4a492e72 | 146 | typedef uint32_t xfs_dqid_t; |
dcbc51df | 147 | |
4c51838c DC |
148 | /* |
149 | * Constants for bit manipulations. | |
150 | */ | |
151 | #define XFS_NBBYLOG 3 /* log2(NBBY) */ | |
152 | #define XFS_WORDLOG 2 /* log2(sizeof(xfs_rtword_t)) */ | |
ccffd2f9 | 153 | #define XFS_SUMINFOLOG 2 /* log2(sizeof(xfs_suminfo_t)) */ |
4c51838c DC |
154 | #define XFS_NBWORDLOG (XFS_NBBYLOG + XFS_WORDLOG) |
155 | #define XFS_NBWORD (1 << XFS_NBWORDLOG) | |
156 | #define XFS_WORDMASK ((1 << XFS_WORDLOG) - 1) | |
157 | ||
9788e059 | 158 | struct xfs_iext_cursor { |
b37d753d CH |
159 | struct xfs_iext_leaf *leaf; |
160 | int pos; | |
9788e059 | 161 | }; |
4c51838c | 162 | |
5837f99a CH |
163 | typedef enum { |
164 | XFS_EXT_NORM, XFS_EXT_UNWRITTEN, | |
165 | } xfs_exntst_t; | |
166 | ||
167 | typedef struct xfs_bmbt_irec | |
168 | { | |
169 | xfs_fileoff_t br_startoff; /* starting file offset */ | |
170 | xfs_fsblock_t br_startblock; /* starting block number */ | |
171 | xfs_filblks_t br_blockcount; /* number of blocks */ | |
172 | xfs_exntst_t br_state; /* extent state */ | |
173 | } xfs_bmbt_irec_t; | |
174 | ||
6b2f464d DW |
175 | enum xfs_refc_domain { |
176 | XFS_REFC_DOMAIN_SHARED = 0, | |
177 | XFS_REFC_DOMAIN_COW, | |
178 | }; | |
179 | ||
8160aeff DW |
180 | #define XFS_REFC_DOMAIN_STRINGS \ |
181 | { XFS_REFC_DOMAIN_SHARED, "shared" }, \ | |
182 | { XFS_REFC_DOMAIN_COW, "cow" } | |
183 | ||
bec88ec7 DW |
184 | struct xfs_refcount_irec { |
185 | xfs_agblock_t rc_startblock; /* starting block number */ | |
186 | xfs_extlen_t rc_blockcount; /* count of free blocks */ | |
187 | xfs_nlink_t rc_refcount; /* number of inodes linked here */ | |
6b2f464d | 188 | enum xfs_refc_domain rc_domain; /* shared or cow staging extent? */ |
bec88ec7 DW |
189 | }; |
190 | ||
191 | #define XFS_RMAP_ATTR_FORK (1 << 0) | |
192 | #define XFS_RMAP_BMBT_BLOCK (1 << 1) | |
193 | #define XFS_RMAP_UNWRITTEN (1 << 2) | |
194 | #define XFS_RMAP_KEY_FLAGS (XFS_RMAP_ATTR_FORK | \ | |
195 | XFS_RMAP_BMBT_BLOCK) | |
196 | #define XFS_RMAP_REC_FLAGS (XFS_RMAP_UNWRITTEN) | |
197 | struct xfs_rmap_irec { | |
198 | xfs_agblock_t rm_startblock; /* extent start block */ | |
199 | xfs_extlen_t rm_blockcount; /* extent length */ | |
200 | uint64_t rm_owner; /* extent owner */ | |
201 | uint64_t rm_offset; /* offset within the owner */ | |
202 | unsigned int rm_flags; /* state flags */ | |
203 | }; | |
204 | ||
74945501 DC |
205 | /* per-AG block reservation types */ |
206 | enum xfs_ag_resv_type { | |
207 | XFS_AG_RESV_NONE = 0, | |
208 | XFS_AG_RESV_AGFL, | |
209 | XFS_AG_RESV_METADATA, | |
210 | XFS_AG_RESV_RMAPBT, | |
211 | }; | |
212 | ||
9ba4dc82 DW |
213 | /* Results of scanning a btree keyspace to check occupancy. */ |
214 | enum xbtree_recpacking { | |
215 | /* None of the keyspace maps to records. */ | |
216 | XBTREE_RECPACKING_EMPTY = 0, | |
217 | ||
218 | /* Some, but not all, of the keyspace maps to records. */ | |
219 | XBTREE_RECPACKING_SPARSE, | |
220 | ||
221 | /* The entire keyspace maps to records. */ | |
222 | XBTREE_RECPACKING_FULL, | |
223 | }; | |
224 | ||
1727fd17 DC |
225 | /* |
226 | * Type verifier functions | |
227 | */ | |
228 | struct xfs_mount; | |
229 | ||
1727fd17 | 230 | bool xfs_verify_fsbno(struct xfs_mount *mp, xfs_fsblock_t fsbno); |
f28f7e4a DW |
231 | bool xfs_verify_fsbext(struct xfs_mount *mp, xfs_fsblock_t fsbno, |
232 | xfs_fsblock_t len); | |
1727fd17 | 233 | |
1727fd17 DC |
234 | bool xfs_verify_ino(struct xfs_mount *mp, xfs_ino_t ino); |
235 | bool xfs_internal_inum(struct xfs_mount *mp, xfs_ino_t ino); | |
236 | bool xfs_verify_dir_ino(struct xfs_mount *mp, xfs_ino_t ino); | |
237 | bool xfs_verify_rtbno(struct xfs_mount *mp, xfs_rtblock_t rtbno); | |
95bc0a4d DW |
238 | bool xfs_verify_rtbext(struct xfs_mount *mp, xfs_rtblock_t rtbno, |
239 | xfs_filblks_t len); | |
751d83bc | 240 | bool xfs_verify_icount(struct xfs_mount *mp, unsigned long long icount); |
95a8c918 | 241 | bool xfs_verify_dablk(struct xfs_mount *mp, xfs_fileoff_t off); |
e9caede6 DW |
242 | void xfs_icount_range(struct xfs_mount *mp, unsigned long long *min, |
243 | unsigned long long *max); | |
7626c690 DW |
244 | bool xfs_verify_fileoff(struct xfs_mount *mp, xfs_fileoff_t off); |
245 | bool xfs_verify_fileext(struct xfs_mount *mp, xfs_fileoff_t off, | |
246 | xfs_fileoff_t len); | |
1727fd17 | 247 | |
2b288ccf | 248 | #endif /* __XFS_TYPES_H__ */ |