Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
0004  * Copyright (c) 2013 Red Hat, Inc.
0005  * All Rights Reserved.
0006  */
0007 #ifndef __XFS_SHARED_H__
0008 #define __XFS_SHARED_H__
0009 
0010 /*
0011  * Definitions shared between kernel and userspace that don't fit into any other
0012  * header file that is shared with userspace.
0013  */
0014 struct xfs_ifork;
0015 struct xfs_buf;
0016 struct xfs_buf_ops;
0017 struct xfs_mount;
0018 struct xfs_trans;
0019 struct xfs_inode;
0020 
0021 /*
0022  * Buffer verifier operations are widely used, including userspace tools
0023  */
0024 extern const struct xfs_buf_ops xfs_agf_buf_ops;
0025 extern const struct xfs_buf_ops xfs_agfl_buf_ops;
0026 extern const struct xfs_buf_ops xfs_agi_buf_ops;
0027 extern const struct xfs_buf_ops xfs_attr3_leaf_buf_ops;
0028 extern const struct xfs_buf_ops xfs_attr3_rmt_buf_ops;
0029 extern const struct xfs_buf_ops xfs_bmbt_buf_ops;
0030 extern const struct xfs_buf_ops xfs_bnobt_buf_ops;
0031 extern const struct xfs_buf_ops xfs_cntbt_buf_ops;
0032 extern const struct xfs_buf_ops xfs_da3_node_buf_ops;
0033 extern const struct xfs_buf_ops xfs_dquot_buf_ops;
0034 extern const struct xfs_buf_ops xfs_dquot_buf_ra_ops;
0035 extern const struct xfs_buf_ops xfs_finobt_buf_ops;
0036 extern const struct xfs_buf_ops xfs_inobt_buf_ops;
0037 extern const struct xfs_buf_ops xfs_inode_buf_ops;
0038 extern const struct xfs_buf_ops xfs_inode_buf_ra_ops;
0039 extern const struct xfs_buf_ops xfs_refcountbt_buf_ops;
0040 extern const struct xfs_buf_ops xfs_rmapbt_buf_ops;
0041 extern const struct xfs_buf_ops xfs_rtbuf_ops;
0042 extern const struct xfs_buf_ops xfs_sb_buf_ops;
0043 extern const struct xfs_buf_ops xfs_sb_quiet_buf_ops;
0044 extern const struct xfs_buf_ops xfs_symlink_buf_ops;
0045 
0046 /* log size calculation functions */
0047 int xfs_log_calc_unit_res(struct xfs_mount *mp, int unit_bytes);
0048 int xfs_log_calc_minimum_size(struct xfs_mount *);
0049 
0050 struct xfs_trans_res;
0051 void    xfs_log_get_max_trans_res(struct xfs_mount *mp,
0052                   struct xfs_trans_res *max_resp);
0053 
0054 /*
0055  * Values for t_flags.
0056  */
0057 /* Transaction needs to be logged */
0058 #define XFS_TRANS_DIRTY         (1u << 0)
0059 /* Superblock is dirty and needs to be logged */
0060 #define XFS_TRANS_SB_DIRTY      (1u << 1)
0061 /* Transaction took a permanent log reservation */
0062 #define XFS_TRANS_PERM_LOG_RES      (1u << 2)
0063 /* Synchronous transaction commit needed */
0064 #define XFS_TRANS_SYNC          (1u << 3)
0065 /* Transaction can use reserve block pool */
0066 #define XFS_TRANS_RESERVE       (1u << 4)
0067 /* Transaction should avoid VFS level superblock write accounting */
0068 #define XFS_TRANS_NO_WRITECOUNT     (1u << 5)
0069 /* Transaction has freed blocks returned to it's reservation */
0070 #define XFS_TRANS_RES_FDBLKS        (1u << 6)
0071 /* Transaction contains an intent done log item */
0072 #define XFS_TRANS_HAS_INTENT_DONE   (1u << 7)
0073 
0074 /*
0075  * LOWMODE is used by the allocator to activate the lowspace algorithm - when
0076  * free space is running low the extent allocator may choose to allocate an
0077  * extent from an AG without leaving sufficient space for a btree split when
0078  * inserting the new extent. In this case the allocator will enable the
0079  * lowspace algorithm which is supposed to allow further allocations (such as
0080  * btree splits and newroots) to allocate from sequential AGs. In order to
0081  * avoid locking AGs out of order the lowspace algorithm will start searching
0082  * for free space from AG 0. If the correct transaction reservations have been
0083  * made then this algorithm will eventually find all the space it needs.
0084  */
0085 #define XFS_TRANS_LOWMODE   0x100   /* allocate in low space mode */
0086 
0087 /*
0088  * Field values for xfs_trans_mod_sb.
0089  */
0090 #define XFS_TRANS_SB_ICOUNT     0x00000001
0091 #define XFS_TRANS_SB_IFREE      0x00000002
0092 #define XFS_TRANS_SB_FDBLOCKS       0x00000004
0093 #define XFS_TRANS_SB_RES_FDBLOCKS   0x00000008
0094 #define XFS_TRANS_SB_FREXTENTS      0x00000010
0095 #define XFS_TRANS_SB_RES_FREXTENTS  0x00000020
0096 #define XFS_TRANS_SB_DBLOCKS        0x00000040
0097 #define XFS_TRANS_SB_AGCOUNT        0x00000080
0098 #define XFS_TRANS_SB_IMAXPCT        0x00000100
0099 #define XFS_TRANS_SB_REXTSIZE       0x00000200
0100 #define XFS_TRANS_SB_RBMBLOCKS      0x00000400
0101 #define XFS_TRANS_SB_RBLOCKS        0x00000800
0102 #define XFS_TRANS_SB_REXTENTS       0x00001000
0103 #define XFS_TRANS_SB_REXTSLOG       0x00002000
0104 
0105 /*
0106  * Here we centralize the specification of XFS meta-data buffer reference count
0107  * values.  This determines how hard the buffer cache tries to hold onto the
0108  * buffer.
0109  */
0110 #define XFS_AGF_REF     4
0111 #define XFS_AGI_REF     4
0112 #define XFS_AGFL_REF        3
0113 #define XFS_INO_BTREE_REF   3
0114 #define XFS_ALLOC_BTREE_REF 2
0115 #define XFS_BMAP_BTREE_REF  2
0116 #define XFS_RMAP_BTREE_REF  2
0117 #define XFS_DIR_BTREE_REF   2
0118 #define XFS_INO_REF     2
0119 #define XFS_ATTR_BTREE_REF  1
0120 #define XFS_DQUOT_REF       1
0121 #define XFS_REFC_BTREE_REF  1
0122 #define XFS_SSB_REF     0
0123 
0124 /*
0125  * Flags for xfs_trans_ichgtime().
0126  */
0127 #define XFS_ICHGTIME_MOD    0x1 /* data fork modification timestamp */
0128 #define XFS_ICHGTIME_CHG    0x2 /* inode field change timestamp */
0129 #define XFS_ICHGTIME_CREATE 0x4 /* inode create timestamp */
0130 
0131 
0132 /*
0133  * Symlink decoding/encoding functions
0134  */
0135 int xfs_symlink_blocks(struct xfs_mount *mp, int pathlen);
0136 int xfs_symlink_hdr_set(struct xfs_mount *mp, xfs_ino_t ino, uint32_t offset,
0137             uint32_t size, struct xfs_buf *bp);
0138 bool xfs_symlink_hdr_ok(xfs_ino_t ino, uint32_t offset,
0139             uint32_t size, struct xfs_buf *bp);
0140 void xfs_symlink_local_to_remote(struct xfs_trans *tp, struct xfs_buf *bp,
0141                  struct xfs_inode *ip, struct xfs_ifork *ifp);
0142 xfs_failaddr_t xfs_symlink_shortform_verify(struct xfs_inode *ip);
0143 
0144 /* Computed inode geometry for the filesystem. */
0145 struct xfs_ino_geometry {
0146     /* Maximum inode count in this filesystem. */
0147     uint64_t    maxicount;
0148 
0149     /* Actual inode cluster buffer size, in bytes. */
0150     unsigned int    inode_cluster_size;
0151 
0152     /*
0153      * Desired inode cluster buffer size, in bytes.  This value is not
0154      * rounded up to at least one filesystem block, which is necessary for
0155      * the sole purpose of validating sb_spino_align.  Runtime code must
0156      * only ever use inode_cluster_size.
0157      */
0158     unsigned int    inode_cluster_size_raw;
0159 
0160     /* Inode cluster sizes, adjusted to be at least 1 fsb. */
0161     unsigned int    inodes_per_cluster;
0162     unsigned int    blocks_per_cluster;
0163 
0164     /* Inode cluster alignment. */
0165     unsigned int    cluster_align;
0166     unsigned int    cluster_align_inodes;
0167     unsigned int    inoalign_mask;  /* mask sb_inoalignmt if used */
0168 
0169     unsigned int    inobt_mxr[2]; /* max inobt btree records */
0170     unsigned int    inobt_mnr[2]; /* min inobt btree records */
0171     unsigned int    inobt_maxlevels; /* max inobt btree levels. */
0172 
0173     /* Size of inode allocations under normal operation. */
0174     unsigned int    ialloc_inos;
0175     unsigned int    ialloc_blks;
0176 
0177     /* Minimum inode blocks for a sparse allocation. */
0178     unsigned int    ialloc_min_blks;
0179 
0180     /* stripe unit inode alignment */
0181     unsigned int    ialloc_align;
0182 
0183     unsigned int    agino_log;  /* #bits for agino in inum */
0184 
0185     /* precomputed default inode attribute fork offset */
0186     unsigned int    attr_fork_offset;
0187 
0188     /* precomputed value for di_flags2 */
0189     uint64_t    new_diflags2;
0190 
0191 };
0192 
0193 #endif /* __XFS_SHARED_H__ */