File Index
Files and directories
Sign in
FILE

xfs_types.h

File preview with syntax highlighting.

linux-6.19.14/fs/xfs/libxfs/xfs_types.h C
  1// SPDX-License-Identifier: GPL-2.0
  2/*
  3 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  4 * All Rights Reserved.
  5 */
  6#ifndef __XFS_TYPES_H__
  7#define	__XFS_TYPES_H__
  8
  9typedef uint32_t	prid_t;		/* project ID */
 10
 11typedef uint32_t	xfs_agblock_t;	/* blockno in alloc. group */
 12typedef uint32_t	xfs_rgblock_t;	/* blockno in realtime group */
 13typedef uint32_t	xfs_agino_t;	/* inode # within allocation grp */
 14typedef uint32_t	xfs_extlen_t;	/* extent length in blocks */
 15typedef uint32_t	xfs_rtxlen_t;	/* file extent length in rtextents */
 16typedef uint32_t	xfs_agnumber_t;	/* allocation group number */
 17typedef uint32_t	xfs_rgnumber_t;	/* realtime group number */
 18typedef uint64_t	xfs_extnum_t;	/* # of extents in a file */
 19typedef uint32_t	xfs_aextnum_t;	/* # extents in an attribute fork */
 20typedef int64_t		xfs_fsize_t;	/* bytes in a file */
 21typedef uint64_t	xfs_ufsize_t;	/* unsigned bytes in a file */
 22
 23typedef int32_t		xfs_suminfo_t;	/* type of bitmap summary info */
 24typedef uint32_t	xfs_rtsumoff_t;	/* offset of an rtsummary info word */
 25typedef uint32_t	xfs_rtword_t;	/* word type for bitmap manipulations */
 26
 27typedef int64_t		xfs_lsn_t;	/* log sequence number */
 28typedef int64_t		xfs_csn_t;	/* CIL sequence number */
 29
 30typedef uint32_t	xfs_dablk_t;	/* dir/attr block number (in file) */
 31typedef uint32_t	xfs_dahash_t;	/* dir/attr hash value */
 32
 33typedef uint64_t	xfs_fsblock_t;	/* blockno in filesystem (agno|agbno) */
 34typedef uint64_t	xfs_rfsblock_t;	/* blockno in filesystem (raw) */
 35typedef uint64_t	xfs_rtblock_t;	/* extent (block) in realtime area */
 36typedef uint64_t	xfs_fileoff_t;	/* block number in a file */
 37typedef uint64_t	xfs_filblks_t;	/* number of blocks in a file */
 38typedef uint64_t	xfs_rtxnum_t;	/* rtextent number */
 39typedef uint64_t	xfs_rtbxlen_t;	/* rtbitmap extent length in rtextents */
 40
 41typedef int64_t		xfs_srtblock_t;	/* signed version of xfs_rtblock_t */
 42
 43/*
 44 * New verifiers will return the instruction address of the failing check.
 45 * NULL means everything is ok.
 46 */
 47typedef void *		xfs_failaddr_t;
 48
 49/*
 50 * Null values for the types.
 51 */
 52#define	NULLFSBLOCK	((xfs_fsblock_t)-1)
 53#define	NULLRFSBLOCK	((xfs_rfsblock_t)-1)
 54#define	NULLRTBLOCK	((xfs_rtblock_t)-1)
 55#define	NULLFILEOFF	((xfs_fileoff_t)-1)
 56
 57#define	NULLAGBLOCK	((xfs_agblock_t)-1)
 58#define NULLRGBLOCK	((xfs_rgblock_t)-1)
 59#define	NULLAGNUMBER	((xfs_agnumber_t)-1)
 60#define	NULLRGNUMBER	((xfs_rgnumber_t)-1)
 61
 62#define NULLCOMMITLSN	((xfs_lsn_t)-1)
 63
 64#define	NULLFSINO	((xfs_ino_t)-1)
 65#define	NULLAGINO	((xfs_agino_t)-1)
 66
 67/*
 68 * Minimum and maximum blocksize and sectorsize.
 69 * The blocksize upper limit is pretty much arbitrary.
 70 * The sectorsize upper limit is due to sizeof(sb_sectsize).
 71 * CRC enable filesystems use 512 byte inodes, meaning 512 byte block sizes
 72 * cannot be used.
 73 */
 74#define XFS_MIN_BLOCKSIZE_LOG	9	/* i.e. 512 bytes */
 75#define XFS_MAX_BLOCKSIZE_LOG	16	/* i.e. 65536 bytes */
 76#define XFS_MIN_BLOCKSIZE	(1 << XFS_MIN_BLOCKSIZE_LOG)
 77#define XFS_MAX_BLOCKSIZE	(1 << XFS_MAX_BLOCKSIZE_LOG)
 78#define XFS_MIN_CRC_BLOCKSIZE	(1 << (XFS_MIN_BLOCKSIZE_LOG + 1))
 79#define XFS_MIN_SECTORSIZE_LOG	9	/* i.e. 512 bytes */
 80#define XFS_MAX_SECTORSIZE_LOG	15	/* i.e. 32768 bytes */
 81#define XFS_MIN_SECTORSIZE	(1 << XFS_MIN_SECTORSIZE_LOG)
 82#define XFS_MAX_SECTORSIZE	(1 << XFS_MAX_SECTORSIZE_LOG)
 83
 84/*
 85 * Inode fork identifiers.
 86 */
 87#define XFS_STAGING_FORK	(-1)	/* fake fork for staging a btree */
 88#define	XFS_DATA_FORK		(0)
 89#define	XFS_ATTR_FORK		(1)
 90#define	XFS_COW_FORK		(2)
 91
 92#define XFS_WHICHFORK_STRINGS \
 93	{ XFS_STAGING_FORK, 	"staging" }, \
 94	{ XFS_DATA_FORK, 	"data" }, \
 95	{ XFS_ATTR_FORK,	"attr" }, \
 96	{ XFS_COW_FORK,		"cow" }
 97
 98/*
 99 * Min numbers of data/attr fork btree root pointers.
100 */
101#define MINDBTPTRS	3
102#define MINABTPTRS	2
103
104/*
105 * MAXNAMELEN is the length (including the terminating null) of
106 * the longest permissible file (component) name.
107 */
108#define MAXNAMELEN	256
109
110/*
111 * This enum is used in string mapping in xfs_trace.h; please keep the
112 * TRACE_DEFINE_ENUMs for it up to date.
113 */
114typedef enum {
115	XFS_LOOKUP_EQi, XFS_LOOKUP_LEi, XFS_LOOKUP_GEi
116} xfs_lookup_t;
117
118#define XFS_AG_BTREE_CMP_FORMAT_STR \
119	{ XFS_LOOKUP_EQi,	"eq" }, \
120	{ XFS_LOOKUP_LEi,	"le" }, \
121	{ XFS_LOOKUP_GEi,	"ge" }
122
123struct xfs_name {
124	const unsigned char	*name;
125	int			len;
126	int			type;
127};
128
129/*
130 * uid_t and gid_t are hard-coded to 32 bits in the inode.
131 * Hence, an 'id' in a dquot is 32 bits..
132 */
133typedef uint32_t	xfs_dqid_t;
134
135/*
136 * Constants for bit manipulations.
137 */
138#define	XFS_NBBYLOG	3		/* log2(NBBY) */
139#define	XFS_WORDLOG	2		/* log2(sizeof(xfs_rtword_t)) */
140#define	XFS_SUMINFOLOG	2		/* log2(sizeof(xfs_suminfo_t)) */
141#define	XFS_NBWORDLOG	(XFS_NBBYLOG + XFS_WORDLOG)
142#define	XFS_NBWORD	(1 << XFS_NBWORDLOG)
143#define	XFS_WORDMASK	((1 << XFS_WORDLOG) - 1)
144
145struct xfs_iext_cursor {
146	struct xfs_iext_leaf	*leaf;
147	int			pos;
148};
149
150typedef enum {
151	XFS_EXT_NORM, XFS_EXT_UNWRITTEN,
152} xfs_exntst_t;
153
154typedef struct xfs_bmbt_irec
155{
156	xfs_fileoff_t	br_startoff;	/* starting file offset */
157	xfs_fsblock_t	br_startblock;	/* starting block number */
158	xfs_filblks_t	br_blockcount;	/* number of blocks */
159	xfs_exntst_t	br_state;	/* extent state */
160} xfs_bmbt_irec_t;
161
162enum xfs_refc_domain {
163	XFS_REFC_DOMAIN_SHARED = 0,
164	XFS_REFC_DOMAIN_COW,
165};
166
167#define XFS_REFC_DOMAIN_STRINGS \
168	{ XFS_REFC_DOMAIN_SHARED,	"shared" }, \
169	{ XFS_REFC_DOMAIN_COW,		"cow" }
170
171struct xfs_refcount_irec {
172	xfs_agblock_t	rc_startblock;	/* starting block number */
173	xfs_extlen_t	rc_blockcount;	/* count of free blocks */
174	xfs_nlink_t	rc_refcount;	/* number of inodes linked here */
175	enum xfs_refc_domain	rc_domain; /* shared or cow staging extent? */
176};
177
178#define XFS_RMAP_ATTR_FORK		(1 << 0)
179#define XFS_RMAP_BMBT_BLOCK		(1 << 1)
180#define XFS_RMAP_UNWRITTEN		(1 << 2)
181#define XFS_RMAP_KEY_FLAGS		(XFS_RMAP_ATTR_FORK | \
182					 XFS_RMAP_BMBT_BLOCK)
183#define XFS_RMAP_REC_FLAGS		(XFS_RMAP_UNWRITTEN)
184struct xfs_rmap_irec {
185	xfs_agblock_t	rm_startblock;	/* extent start block */
186	xfs_extlen_t	rm_blockcount;	/* extent length */
187	uint64_t	rm_owner;	/* extent owner */
188	uint64_t	rm_offset;	/* offset within the owner */
189	unsigned int	rm_flags;	/* state flags */
190};
191
192/* per-AG block reservation types */
193enum xfs_ag_resv_type {
194	XFS_AG_RESV_NONE = 0,
195	XFS_AG_RESV_AGFL,
196	XFS_AG_RESV_METADATA,
197	XFS_AG_RESV_RMAPBT,
198
199	/*
200	 * Don't increase fdblocks when freeing extent.  This is a pony for
201	 * the bnobt repair functions to re-free the free space without
202	 * altering fdblocks.  If you think you need this you're wrong.
203	 */
204	XFS_AG_RESV_IGNORE,
205
206	/*
207	 * This allocation activity is being done on behalf of a metadata file.
208	 * These files maintain their own permanent space reservations and are
209	 * required to adjust fdblocks using the xfs_metafile_resv_* helpers.
210	 */
211	XFS_AG_RESV_METAFILE,
212};
213
214/* Results of scanning a btree keyspace to check occupancy. */
215enum xbtree_recpacking {
216	/* None of the keyspace maps to records. */
217	XBTREE_RECPACKING_EMPTY = 0,
218
219	/* Some, but not all, of the keyspace maps to records. */
220	XBTREE_RECPACKING_SPARSE,
221
222	/* The entire keyspace maps to records. */
223	XBTREE_RECPACKING_FULL,
224};
225
226enum xfs_group_type {
227	XG_TYPE_AG,
228	XG_TYPE_RTG,
229	XG_TYPE_MAX,
230} __packed;
231
232#define XG_TYPE_STRINGS \
233	{ XG_TYPE_AG,	"ag" }, \
234	{ XG_TYPE_RTG,	"rtg" }
235
236enum xfs_free_counter {
237	/*
238	 * Number of free blocks on the data device.
239	 */
240	XC_FREE_BLOCKS,
241
242	/*
243	 * Number of free RT extents on the RT device.
244	 */
245	XC_FREE_RTEXTENTS,
246
247	/*
248	 * Number of available for use RT extents.
249	 *
250	 * This counter only exists for zoned RT device and indicates the number
251	 * of RT extents that can be directly used by writes.  XC_FREE_RTEXTENTS
252	 * also includes blocks that have been written previously and freed, but
253	 * sit in a rtgroup that still needs a zone reset.
254	 */
255	XC_FREE_RTAVAILABLE,
256	XC_FREE_NR,
257};
258
259#define XFS_FREECOUNTER_STR \
260	{ XC_FREE_BLOCKS,		"blocks" }, \
261	{ XC_FREE_RTEXTENTS,		"rtextents" }, \
262	{ XC_FREE_RTAVAILABLE,		"rtavailable" }
263
264/*
265 * Type verifier functions
266 */
267struct xfs_mount;
268
269bool xfs_verify_fsbno(struct xfs_mount *mp, xfs_fsblock_t fsbno);
270bool xfs_verify_fsbext(struct xfs_mount *mp, xfs_fsblock_t fsbno,
271		xfs_fsblock_t len);
272
273bool xfs_verify_ino(struct xfs_mount *mp, xfs_ino_t ino);
274bool xfs_is_sb_inum(struct xfs_mount *mp, xfs_ino_t ino);
275bool xfs_verify_dir_ino(struct xfs_mount *mp, xfs_ino_t ino);
276bool xfs_verify_rtbno(struct xfs_mount *mp, xfs_rtblock_t rtbno);
277bool xfs_verify_rtbext(struct xfs_mount *mp, xfs_rtblock_t rtbno,
278		xfs_filblks_t len);
279bool xfs_verify_icount(struct xfs_mount *mp, unsigned long long icount);
280bool xfs_verify_dablk(struct xfs_mount *mp, xfs_fileoff_t off);
281void xfs_icount_range(struct xfs_mount *mp, unsigned long long *min,
282		unsigned long long *max);
283bool xfs_verify_fileoff(struct xfs_mount *mp, xfs_fileoff_t off);
284bool xfs_verify_fileext(struct xfs_mount *mp, xfs_fileoff_t off,
285		xfs_fileoff_t len);
286
287#endif	/* __XFS_TYPES_H__ */
~/ Read-only file preview.