xfs_types.h (6608B)
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_agino_t; /* inode # within allocation grp */ 13typedef uint32_t xfs_extlen_t; /* extent length in blocks */ 14typedef uint32_t xfs_agnumber_t; /* allocation group number */ 15typedef uint64_t xfs_extnum_t; /* # of extents in a file */ 16typedef uint32_t xfs_aextnum_t; /* # extents in an attribute fork */ 17typedef int64_t xfs_fsize_t; /* bytes in a file */ 18typedef uint64_t xfs_ufsize_t; /* unsigned bytes in a file */ 19 20typedef int32_t xfs_suminfo_t; /* type of bitmap summary info */ 21typedef uint32_t xfs_rtword_t; /* word type for bitmap manipulations */ 22 23typedef int64_t xfs_lsn_t; /* log sequence number */ 24typedef int64_t xfs_csn_t; /* CIL sequence number */ 25 26typedef uint32_t xfs_dablk_t; /* dir/attr block number (in file) */ 27typedef uint32_t xfs_dahash_t; /* dir/attr hash value */ 28 29typedef uint64_t xfs_fsblock_t; /* blockno in filesystem (agno|agbno) */ 30typedef uint64_t xfs_rfsblock_t; /* blockno in filesystem (raw) */ 31typedef uint64_t xfs_rtblock_t; /* extent (block) in realtime area */ 32typedef uint64_t xfs_fileoff_t; /* block number in a file */ 33typedef uint64_t xfs_filblks_t; /* number of blocks in a file */ 34 35typedef int64_t xfs_srtblock_t; /* signed version of xfs_rtblock_t */ 36 37/* 38 * New verifiers will return the instruction address of the failing check. 39 * NULL means everything is ok. 40 */ 41typedef void * xfs_failaddr_t; 42 43/* 44 * Null values for the types. 45 */ 46#define NULLFSBLOCK ((xfs_fsblock_t)-1) 47#define NULLRFSBLOCK ((xfs_rfsblock_t)-1) 48#define NULLRTBLOCK ((xfs_rtblock_t)-1) 49#define NULLFILEOFF ((xfs_fileoff_t)-1) 50 51#define NULLAGBLOCK ((xfs_agblock_t)-1) 52#define NULLAGNUMBER ((xfs_agnumber_t)-1) 53 54#define NULLCOMMITLSN ((xfs_lsn_t)-1) 55 56#define NULLFSINO ((xfs_ino_t)-1) 57#define NULLAGINO ((xfs_agino_t)-1) 58 59/* 60 * Minimum and maximum blocksize and sectorsize. 61 * The blocksize upper limit is pretty much arbitrary. 62 * The sectorsize upper limit is due to sizeof(sb_sectsize). 63 * CRC enable filesystems use 512 byte inodes, meaning 512 byte block sizes 64 * cannot be used. 65 */ 66#define XFS_MIN_BLOCKSIZE_LOG 9 /* i.e. 512 bytes */ 67#define XFS_MAX_BLOCKSIZE_LOG 16 /* i.e. 65536 bytes */ 68#define XFS_MIN_BLOCKSIZE (1 << XFS_MIN_BLOCKSIZE_LOG) 69#define XFS_MAX_BLOCKSIZE (1 << XFS_MAX_BLOCKSIZE_LOG) 70#define XFS_MIN_CRC_BLOCKSIZE (1 << (XFS_MIN_BLOCKSIZE_LOG + 1)) 71#define XFS_MIN_SECTORSIZE_LOG 9 /* i.e. 512 bytes */ 72#define XFS_MAX_SECTORSIZE_LOG 15 /* i.e. 32768 bytes */ 73#define XFS_MIN_SECTORSIZE (1 << XFS_MIN_SECTORSIZE_LOG) 74#define XFS_MAX_SECTORSIZE (1 << XFS_MAX_SECTORSIZE_LOG) 75 76/* 77 * Inode fork identifiers. 78 */ 79#define XFS_DATA_FORK 0 80#define XFS_ATTR_FORK 1 81#define XFS_COW_FORK 2 82 83#define XFS_WHICHFORK_STRINGS \ 84 { XFS_DATA_FORK, "data" }, \ 85 { XFS_ATTR_FORK, "attr" }, \ 86 { XFS_COW_FORK, "cow" } 87 88/* 89 * Min numbers of data/attr fork btree root pointers. 90 */ 91#define MINDBTPTRS 3 92#define MINABTPTRS 2 93 94/* 95 * MAXNAMELEN is the length (including the terminating null) of 96 * the longest permissible file (component) name. 97 */ 98#define MAXNAMELEN 256 99 100/* 101 * This enum is used in string mapping in xfs_trace.h; please keep the 102 * TRACE_DEFINE_ENUMs for it up to date. 103 */ 104typedef enum { 105 XFS_LOOKUP_EQi, XFS_LOOKUP_LEi, XFS_LOOKUP_GEi 106} xfs_lookup_t; 107 108#define XFS_AG_BTREE_CMP_FORMAT_STR \ 109 { XFS_LOOKUP_EQi, "eq" }, \ 110 { XFS_LOOKUP_LEi, "le" }, \ 111 { XFS_LOOKUP_GEi, "ge" } 112 113/* 114 * This enum is used in string mapping in xfs_trace.h and scrub/trace.h; 115 * please keep the TRACE_DEFINE_ENUMs for it up to date. 116 */ 117typedef enum { 118 XFS_BTNUM_BNOi, XFS_BTNUM_CNTi, XFS_BTNUM_RMAPi, XFS_BTNUM_BMAPi, 119 XFS_BTNUM_INOi, XFS_BTNUM_FINOi, XFS_BTNUM_REFCi, XFS_BTNUM_MAX 120} xfs_btnum_t; 121 122#define XFS_BTNUM_STRINGS \ 123 { XFS_BTNUM_BNOi, "bnobt" }, \ 124 { XFS_BTNUM_CNTi, "cntbt" }, \ 125 { XFS_BTNUM_RMAPi, "rmapbt" }, \ 126 { XFS_BTNUM_BMAPi, "bmbt" }, \ 127 { XFS_BTNUM_INOi, "inobt" }, \ 128 { XFS_BTNUM_FINOi, "finobt" }, \ 129 { XFS_BTNUM_REFCi, "refcbt" } 130 131struct xfs_name { 132 const unsigned char *name; 133 int len; 134 int type; 135}; 136 137/* 138 * uid_t and gid_t are hard-coded to 32 bits in the inode. 139 * Hence, an 'id' in a dquot is 32 bits.. 140 */ 141typedef uint32_t xfs_dqid_t; 142 143/* 144 * Constants for bit manipulations. 145 */ 146#define XFS_NBBYLOG 3 /* log2(NBBY) */ 147#define XFS_WORDLOG 2 /* log2(sizeof(xfs_rtword_t)) */ 148#define XFS_NBWORDLOG (XFS_NBBYLOG + XFS_WORDLOG) 149#define XFS_NBWORD (1 << XFS_NBWORDLOG) 150#define XFS_WORDMASK ((1 << XFS_WORDLOG) - 1) 151 152struct xfs_iext_cursor { 153 struct xfs_iext_leaf *leaf; 154 int pos; 155}; 156 157typedef enum { 158 XFS_EXT_NORM, XFS_EXT_UNWRITTEN, 159} xfs_exntst_t; 160 161typedef struct xfs_bmbt_irec 162{ 163 xfs_fileoff_t br_startoff; /* starting file offset */ 164 xfs_fsblock_t br_startblock; /* starting block number */ 165 xfs_filblks_t br_blockcount; /* number of blocks */ 166 xfs_exntst_t br_state; /* extent state */ 167} xfs_bmbt_irec_t; 168 169/* per-AG block reservation types */ 170enum xfs_ag_resv_type { 171 XFS_AG_RESV_NONE = 0, 172 XFS_AG_RESV_AGFL, 173 XFS_AG_RESV_METADATA, 174 XFS_AG_RESV_RMAPBT, 175}; 176 177/* 178 * Type verifier functions 179 */ 180struct xfs_mount; 181 182xfs_agblock_t xfs_ag_block_count(struct xfs_mount *mp, xfs_agnumber_t agno); 183bool xfs_verify_agbno(struct xfs_mount *mp, xfs_agnumber_t agno, 184 xfs_agblock_t agbno); 185bool xfs_verify_fsbno(struct xfs_mount *mp, xfs_fsblock_t fsbno); 186bool xfs_verify_fsbext(struct xfs_mount *mp, xfs_fsblock_t fsbno, 187 xfs_fsblock_t len); 188 189void xfs_agino_range(struct xfs_mount *mp, xfs_agnumber_t agno, 190 xfs_agino_t *first, xfs_agino_t *last); 191bool xfs_verify_agino(struct xfs_mount *mp, xfs_agnumber_t agno, 192 xfs_agino_t agino); 193bool xfs_verify_agino_or_null(struct xfs_mount *mp, xfs_agnumber_t agno, 194 xfs_agino_t agino); 195bool xfs_verify_ino(struct xfs_mount *mp, xfs_ino_t ino); 196bool xfs_internal_inum(struct xfs_mount *mp, xfs_ino_t ino); 197bool xfs_verify_dir_ino(struct xfs_mount *mp, xfs_ino_t ino); 198bool xfs_verify_rtbno(struct xfs_mount *mp, xfs_rtblock_t rtbno); 199bool xfs_verify_rtext(struct xfs_mount *mp, xfs_rtblock_t rtbno, 200 xfs_rtblock_t len); 201bool xfs_verify_icount(struct xfs_mount *mp, unsigned long long icount); 202bool xfs_verify_dablk(struct xfs_mount *mp, xfs_fileoff_t off); 203void xfs_icount_range(struct xfs_mount *mp, unsigned long long *min, 204 unsigned long long *max); 205bool xfs_verify_fileoff(struct xfs_mount *mp, xfs_fileoff_t off); 206bool xfs_verify_fileext(struct xfs_mount *mp, xfs_fileoff_t off, 207 xfs_fileoff_t len); 208 209#endif /* __XFS_TYPES_H__ */