233 lines · c
1// SPDX-License-Identifier: GPL-2.02/*3 * Copyright (c) 2000-2005 Silicon Graphics, Inc.4 * Copyright (c) 2013 Red Hat, Inc.5 * All Rights Reserved.6 */7#ifndef __XFS_SHARED_H__8#define __XFS_SHARED_H__9 10/*11 * Definitions shared between kernel and userspace that don't fit into any other12 * header file that is shared with userspace.13 */14struct xfs_ifork;15struct xfs_buf;16struct xfs_buf_ops;17struct xfs_mount;18struct xfs_trans;19struct xfs_inode;20 21/*22 * Buffer verifier operations are widely used, including userspace tools23 */24extern const struct xfs_buf_ops xfs_agf_buf_ops;25extern const struct xfs_buf_ops xfs_agfl_buf_ops;26extern const struct xfs_buf_ops xfs_agi_buf_ops;27extern const struct xfs_buf_ops xfs_attr3_leaf_buf_ops;28extern const struct xfs_buf_ops xfs_attr3_rmt_buf_ops;29extern const struct xfs_buf_ops xfs_bmbt_buf_ops;30extern const struct xfs_buf_ops xfs_bnobt_buf_ops;31extern const struct xfs_buf_ops xfs_cntbt_buf_ops;32extern const struct xfs_buf_ops xfs_da3_node_buf_ops;33extern const struct xfs_buf_ops xfs_dquot_buf_ops;34extern const struct xfs_buf_ops xfs_dquot_buf_ra_ops;35extern const struct xfs_buf_ops xfs_finobt_buf_ops;36extern const struct xfs_buf_ops xfs_inobt_buf_ops;37extern const struct xfs_buf_ops xfs_inode_buf_ops;38extern const struct xfs_buf_ops xfs_inode_buf_ra_ops;39extern const struct xfs_buf_ops xfs_refcountbt_buf_ops;40extern const struct xfs_buf_ops xfs_rmapbt_buf_ops;41extern const struct xfs_buf_ops xfs_rtbuf_ops;42extern const struct xfs_buf_ops xfs_sb_buf_ops;43extern const struct xfs_buf_ops xfs_sb_quiet_buf_ops;44extern const struct xfs_buf_ops xfs_symlink_buf_ops;45 46/* btree ops */47extern const struct xfs_btree_ops xfs_bnobt_ops;48extern const struct xfs_btree_ops xfs_cntbt_ops;49extern const struct xfs_btree_ops xfs_inobt_ops;50extern const struct xfs_btree_ops xfs_finobt_ops;51extern const struct xfs_btree_ops xfs_bmbt_ops;52extern const struct xfs_btree_ops xfs_refcountbt_ops;53extern const struct xfs_btree_ops xfs_rmapbt_ops;54extern const struct xfs_btree_ops xfs_rmapbt_mem_ops;55 56static inline bool xfs_btree_is_bno(const struct xfs_btree_ops *ops)57{58 return ops == &xfs_bnobt_ops;59}60 61static inline bool xfs_btree_is_cnt(const struct xfs_btree_ops *ops)62{63 return ops == &xfs_cntbt_ops;64}65 66static inline bool xfs_btree_is_bmap(const struct xfs_btree_ops *ops)67{68 return ops == &xfs_bmbt_ops;69}70 71static inline bool xfs_btree_is_ino(const struct xfs_btree_ops *ops)72{73 return ops == &xfs_inobt_ops;74}75 76static inline bool xfs_btree_is_fino(const struct xfs_btree_ops *ops)77{78 return ops == &xfs_finobt_ops;79}80 81static inline bool xfs_btree_is_refcount(const struct xfs_btree_ops *ops)82{83 return ops == &xfs_refcountbt_ops;84}85 86static inline bool xfs_btree_is_rmap(const struct xfs_btree_ops *ops)87{88 return ops == &xfs_rmapbt_ops;89}90 91#ifdef CONFIG_XFS_BTREE_IN_MEM92static inline bool xfs_btree_is_mem_rmap(const struct xfs_btree_ops *ops)93{94 return ops == &xfs_rmapbt_mem_ops;95}96#else97# define xfs_btree_is_mem_rmap(...) (false)98#endif99 100/* log size calculation functions */101int xfs_log_calc_unit_res(struct xfs_mount *mp, int unit_bytes);102int xfs_log_calc_minimum_size(struct xfs_mount *);103 104struct xfs_trans_res;105void xfs_log_get_max_trans_res(struct xfs_mount *mp,106 struct xfs_trans_res *max_resp);107 108/*109 * Values for t_flags.110 */111/* Transaction needs to be logged */112#define XFS_TRANS_DIRTY (1u << 0)113/* Superblock is dirty and needs to be logged */114#define XFS_TRANS_SB_DIRTY (1u << 1)115/* Transaction took a permanent log reservation */116#define XFS_TRANS_PERM_LOG_RES (1u << 2)117/* Synchronous transaction commit needed */118#define XFS_TRANS_SYNC (1u << 3)119/* Transaction can use reserve block pool */120#define XFS_TRANS_RESERVE (1u << 4)121/* Transaction should avoid VFS level superblock write accounting */122#define XFS_TRANS_NO_WRITECOUNT (1u << 5)123/* Transaction has freed blocks returned to it's reservation */124#define XFS_TRANS_RES_FDBLKS (1u << 6)125/* Transaction contains an intent done log item */126#define XFS_TRANS_HAS_INTENT_DONE (1u << 7)127/*128 * LOWMODE is used by the allocator to activate the lowspace algorithm - when129 * free space is running low the extent allocator may choose to allocate an130 * extent from an AG without leaving sufficient space for a btree split when131 * inserting the new extent. In this case the allocator will enable the132 * lowspace algorithm which is supposed to allow further allocations (such as133 * btree splits and newroots) to allocate from sequential AGs. In order to134 * avoid locking AGs out of order the lowspace algorithm will start searching135 * for free space from AG 0. If the correct transaction reservations have been136 * made then this algorithm will eventually find all the space it needs.137 */138#define XFS_TRANS_LOWMODE (1u << 8)139 140/* Transaction has locked the rtbitmap and rtsum inodes */141#define XFS_TRANS_RTBITMAP_LOCKED (1u << 9)142 143/*144 * Field values for xfs_trans_mod_sb.145 */146#define XFS_TRANS_SB_ICOUNT 0x00000001147#define XFS_TRANS_SB_IFREE 0x00000002148#define XFS_TRANS_SB_FDBLOCKS 0x00000004149#define XFS_TRANS_SB_RES_FDBLOCKS 0x00000008150#define XFS_TRANS_SB_FREXTENTS 0x00000010151#define XFS_TRANS_SB_RES_FREXTENTS 0x00000020152#define XFS_TRANS_SB_DBLOCKS 0x00000040153#define XFS_TRANS_SB_AGCOUNT 0x00000080154#define XFS_TRANS_SB_IMAXPCT 0x00000100155#define XFS_TRANS_SB_REXTSIZE 0x00000200156#define XFS_TRANS_SB_RBMBLOCKS 0x00000400157#define XFS_TRANS_SB_RBLOCKS 0x00000800158#define XFS_TRANS_SB_REXTENTS 0x00001000159#define XFS_TRANS_SB_REXTSLOG 0x00002000160 161/*162 * Here we centralize the specification of XFS meta-data buffer reference count163 * values. This determines how hard the buffer cache tries to hold onto the164 * buffer.165 */166#define XFS_AGF_REF 4167#define XFS_AGI_REF 4168#define XFS_AGFL_REF 3169#define XFS_INO_BTREE_REF 3170#define XFS_ALLOC_BTREE_REF 2171#define XFS_BMAP_BTREE_REF 2172#define XFS_RMAP_BTREE_REF 2173#define XFS_DIR_BTREE_REF 2174#define XFS_INO_REF 2175#define XFS_ATTR_BTREE_REF 1176#define XFS_DQUOT_REF 1177#define XFS_REFC_BTREE_REF 1178#define XFS_SSB_REF 0179 180/* Computed inode geometry for the filesystem. */181struct xfs_ino_geometry {182 /* Maximum inode count in this filesystem. */183 uint64_t maxicount;184 185 /* Actual inode cluster buffer size, in bytes. */186 unsigned int inode_cluster_size;187 188 /*189 * Desired inode cluster buffer size, in bytes. This value is not190 * rounded up to at least one filesystem block, which is necessary for191 * the sole purpose of validating sb_spino_align. Runtime code must192 * only ever use inode_cluster_size.193 */194 unsigned int inode_cluster_size_raw;195 196 /* Inode cluster sizes, adjusted to be at least 1 fsb. */197 unsigned int inodes_per_cluster;198 unsigned int blocks_per_cluster;199 200 /* Inode cluster alignment. */201 unsigned int cluster_align;202 unsigned int cluster_align_inodes;203 unsigned int inoalign_mask; /* mask sb_inoalignmt if used */204 205 unsigned int inobt_mxr[2]; /* max inobt btree records */206 unsigned int inobt_mnr[2]; /* min inobt btree records */207 unsigned int inobt_maxlevels; /* max inobt btree levels. */208 209 /* Size of inode allocations under normal operation. */210 unsigned int ialloc_inos;211 unsigned int ialloc_blks;212 213 /* Minimum inode blocks for a sparse allocation. */214 unsigned int ialloc_min_blks;215 216 /* stripe unit inode alignment */217 unsigned int ialloc_align;218 219 unsigned int agino_log; /* #bits for agino in inum */220 221 /* precomputed default inode attribute fork offset */222 unsigned int attr_fork_offset;223 224 /* precomputed value for di_flags2 */225 uint64_t new_diflags2;226 227 /* minimum folio order of a page cache allocation */228 unsigned int min_folio_order;229 230};231 232#endif /* __XFS_SHARED_H__ */233