^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (c) 2000-2005 Silicon Graphics, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (c) 2013 Red Hat, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * All Rights Reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #ifndef __XFS_SHARED_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #define __XFS_SHARED_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * Definitions shared between kernel and userspace that don't fit into any other
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * header file that is shared with userspace.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) struct xfs_ifork;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) struct xfs_buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) struct xfs_buf_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) struct xfs_mount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) struct xfs_trans;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) struct xfs_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * Buffer verifier operations are widely used, including userspace tools
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) extern const struct xfs_buf_ops xfs_agf_buf_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) extern const struct xfs_buf_ops xfs_agi_buf_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) extern const struct xfs_buf_ops xfs_agf_buf_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) extern const struct xfs_buf_ops xfs_agfl_buf_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) extern const struct xfs_buf_ops xfs_bnobt_buf_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) extern const struct xfs_buf_ops xfs_cntbt_buf_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) extern const struct xfs_buf_ops xfs_rmapbt_buf_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) extern const struct xfs_buf_ops xfs_refcountbt_buf_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) extern const struct xfs_buf_ops xfs_attr3_leaf_buf_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) extern const struct xfs_buf_ops xfs_attr3_rmt_buf_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) extern const struct xfs_buf_ops xfs_bmbt_buf_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) extern const struct xfs_buf_ops xfs_da3_node_buf_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) extern const struct xfs_buf_ops xfs_dquot_buf_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) extern const struct xfs_buf_ops xfs_symlink_buf_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) extern const struct xfs_buf_ops xfs_agi_buf_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) extern const struct xfs_buf_ops xfs_inobt_buf_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) extern const struct xfs_buf_ops xfs_finobt_buf_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) extern const struct xfs_buf_ops xfs_inode_buf_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) extern const struct xfs_buf_ops xfs_inode_buf_ra_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) extern const struct xfs_buf_ops xfs_dquot_buf_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) extern const struct xfs_buf_ops xfs_dquot_buf_ra_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) extern const struct xfs_buf_ops xfs_sb_buf_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) extern const struct xfs_buf_ops xfs_sb_quiet_buf_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) extern const struct xfs_buf_ops xfs_symlink_buf_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) extern const struct xfs_buf_ops xfs_rtbuf_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) /* log size calculation functions */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) int xfs_log_calc_unit_res(struct xfs_mount *mp, int unit_bytes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) int xfs_log_calc_minimum_size(struct xfs_mount *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) struct xfs_trans_res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) void xfs_log_get_max_trans_res(struct xfs_mount *mp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) struct xfs_trans_res *max_resp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) * Values for t_flags.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #define XFS_TRANS_DIRTY 0x01 /* something needs to be logged */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) #define XFS_TRANS_SB_DIRTY 0x02 /* superblock is modified */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) #define XFS_TRANS_PERM_LOG_RES 0x04 /* xact took a permanent log res */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) #define XFS_TRANS_SYNC 0x08 /* make commit synchronous */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) #define XFS_TRANS_DQ_DIRTY 0x10 /* at least one dquot in trx dirty */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) #define XFS_TRANS_RESERVE 0x20 /* OK to use reserved data blocks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) #define XFS_TRANS_NO_WRITECOUNT 0x40 /* do not elevate SB writecount */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) #define XFS_TRANS_RES_FDBLKS 0x80 /* reserve newly freed blocks */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) * LOWMODE is used by the allocator to activate the lowspace algorithm - when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) * free space is running low the extent allocator may choose to allocate an
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) * extent from an AG without leaving sufficient space for a btree split when
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) * inserting the new extent. In this case the allocator will enable the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) * lowspace algorithm which is supposed to allow further allocations (such as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) * btree splits and newroots) to allocate from sequential AGs. In order to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) * avoid locking AGs out of order the lowspace algorithm will start searching
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) * for free space from AG 0. If the correct transaction reservations have been
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) * made then this algorithm will eventually find all the space it needs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) #define XFS_TRANS_LOWMODE 0x100 /* allocate in low space mode */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) * Field values for xfs_trans_mod_sb.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) #define XFS_TRANS_SB_ICOUNT 0x00000001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) #define XFS_TRANS_SB_IFREE 0x00000002
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) #define XFS_TRANS_SB_FDBLOCKS 0x00000004
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) #define XFS_TRANS_SB_RES_FDBLOCKS 0x00000008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) #define XFS_TRANS_SB_FREXTENTS 0x00000010
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) #define XFS_TRANS_SB_RES_FREXTENTS 0x00000020
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) #define XFS_TRANS_SB_DBLOCKS 0x00000040
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) #define XFS_TRANS_SB_AGCOUNT 0x00000080
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) #define XFS_TRANS_SB_IMAXPCT 0x00000100
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) #define XFS_TRANS_SB_REXTSIZE 0x00000200
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) #define XFS_TRANS_SB_RBMBLOCKS 0x00000400
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) #define XFS_TRANS_SB_RBLOCKS 0x00000800
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) #define XFS_TRANS_SB_REXTENTS 0x00001000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) #define XFS_TRANS_SB_REXTSLOG 0x00002000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) * Here we centralize the specification of XFS meta-data buffer reference count
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) * values. This determines how hard the buffer cache tries to hold onto the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) * buffer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) #define XFS_AGF_REF 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) #define XFS_AGI_REF 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) #define XFS_AGFL_REF 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) #define XFS_INO_BTREE_REF 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) #define XFS_ALLOC_BTREE_REF 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) #define XFS_BMAP_BTREE_REF 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) #define XFS_RMAP_BTREE_REF 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) #define XFS_DIR_BTREE_REF 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) #define XFS_INO_REF 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) #define XFS_ATTR_BTREE_REF 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) #define XFS_DQUOT_REF 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) #define XFS_REFC_BTREE_REF 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) #define XFS_SSB_REF 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) * Flags for xfs_trans_ichgtime().
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) #define XFS_ICHGTIME_MOD 0x1 /* data fork modification timestamp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) #define XFS_ICHGTIME_CHG 0x2 /* inode field change timestamp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) #define XFS_ICHGTIME_CREATE 0x4 /* inode create timestamp */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) * Symlink decoding/encoding functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) int xfs_symlink_blocks(struct xfs_mount *mp, int pathlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) int xfs_symlink_hdr_set(struct xfs_mount *mp, xfs_ino_t ino, uint32_t offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) uint32_t size, struct xfs_buf *bp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) bool xfs_symlink_hdr_ok(xfs_ino_t ino, uint32_t offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) uint32_t size, struct xfs_buf *bp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) void xfs_symlink_local_to_remote(struct xfs_trans *tp, struct xfs_buf *bp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) struct xfs_inode *ip, struct xfs_ifork *ifp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) xfs_failaddr_t xfs_symlink_shortform_verify(struct xfs_inode *ip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) /* Computed inode geometry for the filesystem. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) struct xfs_ino_geometry {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) /* Maximum inode count in this filesystem. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) uint64_t maxicount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) /* Actual inode cluster buffer size, in bytes. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) unsigned int inode_cluster_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) * Desired inode cluster buffer size, in bytes. This value is not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) * rounded up to at least one filesystem block, which is necessary for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) * the sole purpose of validating sb_spino_align. Runtime code must
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) * only ever use inode_cluster_size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) unsigned int inode_cluster_size_raw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) /* Inode cluster sizes, adjusted to be at least 1 fsb. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) unsigned int inodes_per_cluster;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) unsigned int blocks_per_cluster;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) /* Inode cluster alignment. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) unsigned int cluster_align;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) unsigned int cluster_align_inodes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) unsigned int inoalign_mask; /* mask sb_inoalignmt if used */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) unsigned int inobt_mxr[2]; /* max inobt btree records */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) unsigned int inobt_mnr[2]; /* min inobt btree records */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) unsigned int inobt_maxlevels; /* max inobt btree levels. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) /* Size of inode allocations under normal operation. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) unsigned int ialloc_inos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) unsigned int ialloc_blks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) /* Minimum inode blocks for a sparse allocation. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) unsigned int ialloc_min_blks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) /* stripe unit inode alignment */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) unsigned int ialloc_align;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) unsigned int agino_log; /* #bits for agino in inum */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) /* precomputed value for di_flags2 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) uint64_t new_diflags2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) #endif /* __XFS_SHARED_H__ */