Linux Audio

Check our new training course

Loading...
v5.14.15
  1// SPDX-License-Identifier: GPL-2.0
  2/*
  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 other
 12 * 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 tools
 23 */
 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/* log size calculation functions */
 47int	xfs_log_calc_unit_res(struct xfs_mount *mp, int unit_bytes);
 48int	xfs_log_calc_minimum_size(struct xfs_mount *);
 49
 50struct xfs_trans_res;
 51void	xfs_log_get_max_trans_res(struct xfs_mount *mp,
 52				  struct xfs_trans_res *max_resp);
 53
 54/*
 55 * Values for t_flags.
 56 */
 57#define	XFS_TRANS_DIRTY		0x01	/* something needs to be logged */
 58#define	XFS_TRANS_SB_DIRTY	0x02	/* superblock is modified */
 59#define	XFS_TRANS_PERM_LOG_RES	0x04	/* xact took a permanent log res */
 60#define	XFS_TRANS_SYNC		0x08	/* make commit synchronous */
 61#define XFS_TRANS_RESERVE	0x20    /* OK to use reserved data blocks */
 62#define XFS_TRANS_NO_WRITECOUNT 0x40	/* do not elevate SB writecount */
 63#define XFS_TRANS_RES_FDBLKS	0x80	/* reserve newly freed blocks */
 
 
 
 
 
 
 
 
 
 
 64/*
 65 * LOWMODE is used by the allocator to activate the lowspace algorithm - when
 66 * free space is running low the extent allocator may choose to allocate an
 67 * extent from an AG without leaving sufficient space for a btree split when
 68 * inserting the new extent. In this case the allocator will enable the
 69 * lowspace algorithm which is supposed to allow further allocations (such as
 70 * btree splits and newroots) to allocate from sequential AGs. In order to
 71 * avoid locking AGs out of order the lowspace algorithm will start searching
 72 * for free space from AG 0. If the correct transaction reservations have been
 73 * made then this algorithm will eventually find all the space it needs.
 74 */
 75#define XFS_TRANS_LOWMODE	0x100	/* allocate in low space mode */
 76
 77/*
 78 * Field values for xfs_trans_mod_sb.
 79 */
 80#define	XFS_TRANS_SB_ICOUNT		0x00000001
 81#define	XFS_TRANS_SB_IFREE		0x00000002
 82#define	XFS_TRANS_SB_FDBLOCKS		0x00000004
 83#define	XFS_TRANS_SB_RES_FDBLOCKS	0x00000008
 84#define	XFS_TRANS_SB_FREXTENTS		0x00000010
 85#define	XFS_TRANS_SB_RES_FREXTENTS	0x00000020
 86#define	XFS_TRANS_SB_DBLOCKS		0x00000040
 87#define	XFS_TRANS_SB_AGCOUNT		0x00000080
 88#define	XFS_TRANS_SB_IMAXPCT		0x00000100
 89#define	XFS_TRANS_SB_REXTSIZE		0x00000200
 90#define	XFS_TRANS_SB_RBMBLOCKS		0x00000400
 91#define	XFS_TRANS_SB_RBLOCKS		0x00000800
 92#define	XFS_TRANS_SB_REXTENTS		0x00001000
 93#define	XFS_TRANS_SB_REXTSLOG		0x00002000
 94
 95/*
 96 * Here we centralize the specification of XFS meta-data buffer reference count
 97 * values.  This determines how hard the buffer cache tries to hold onto the
 98 * buffer.
 99 */
100#define	XFS_AGF_REF		4
101#define	XFS_AGI_REF		4
102#define	XFS_AGFL_REF		3
103#define	XFS_INO_BTREE_REF	3
104#define	XFS_ALLOC_BTREE_REF	2
105#define	XFS_BMAP_BTREE_REF	2
106#define	XFS_RMAP_BTREE_REF	2
107#define	XFS_DIR_BTREE_REF	2
108#define	XFS_INO_REF		2
109#define	XFS_ATTR_BTREE_REF	1
110#define	XFS_DQUOT_REF		1
111#define	XFS_REFC_BTREE_REF	1
112#define	XFS_SSB_REF		0
113
114/*
115 * Flags for xfs_trans_ichgtime().
116 */
117#define	XFS_ICHGTIME_MOD	0x1	/* data fork modification timestamp */
118#define	XFS_ICHGTIME_CHG	0x2	/* inode field change timestamp */
119#define	XFS_ICHGTIME_CREATE	0x4	/* inode create timestamp */
120
121
122/*
123 * Symlink decoding/encoding functions
124 */
125int xfs_symlink_blocks(struct xfs_mount *mp, int pathlen);
126int xfs_symlink_hdr_set(struct xfs_mount *mp, xfs_ino_t ino, uint32_t offset,
127			uint32_t size, struct xfs_buf *bp);
128bool xfs_symlink_hdr_ok(xfs_ino_t ino, uint32_t offset,
129			uint32_t size, struct xfs_buf *bp);
130void xfs_symlink_local_to_remote(struct xfs_trans *tp, struct xfs_buf *bp,
131				 struct xfs_inode *ip, struct xfs_ifork *ifp);
132xfs_failaddr_t xfs_symlink_shortform_verify(struct xfs_inode *ip);
133
134/* Computed inode geometry for the filesystem. */
135struct xfs_ino_geometry {
136	/* Maximum inode count in this filesystem. */
137	uint64_t	maxicount;
138
139	/* Actual inode cluster buffer size, in bytes. */
140	unsigned int	inode_cluster_size;
141
142	/*
143	 * Desired inode cluster buffer size, in bytes.  This value is not
144	 * rounded up to at least one filesystem block, which is necessary for
145	 * the sole purpose of validating sb_spino_align.  Runtime code must
146	 * only ever use inode_cluster_size.
147	 */
148	unsigned int	inode_cluster_size_raw;
149
150	/* Inode cluster sizes, adjusted to be at least 1 fsb. */
151	unsigned int	inodes_per_cluster;
152	unsigned int	blocks_per_cluster;
153
154	/* Inode cluster alignment. */
155	unsigned int	cluster_align;
156	unsigned int	cluster_align_inodes;
157	unsigned int	inoalign_mask;	/* mask sb_inoalignmt if used */
158
159	unsigned int	inobt_mxr[2]; /* max inobt btree records */
160	unsigned int	inobt_mnr[2]; /* min inobt btree records */
161	unsigned int	inobt_maxlevels; /* max inobt btree levels. */
162
163	/* Size of inode allocations under normal operation. */
164	unsigned int	ialloc_inos;
165	unsigned int	ialloc_blks;
166
167	/* Minimum inode blocks for a sparse allocation. */
168	unsigned int	ialloc_min_blks;
169
170	/* stripe unit inode alignment */
171	unsigned int	ialloc_align;
172
173	unsigned int	agino_log;	/* #bits for agino in inum */
174
175	/* precomputed default inode attribute fork offset */
176	unsigned int	attr_fork_offset;
177
178	/* precomputed value for di_flags2 */
179	uint64_t	new_diflags2;
180
181};
182
183#endif /* __XFS_SHARED_H__ */
v6.8
  1// SPDX-License-Identifier: GPL-2.0
  2/*
  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 other
 12 * 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 tools
 23 */
 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/* log size calculation functions */
 47int	xfs_log_calc_unit_res(struct xfs_mount *mp, int unit_bytes);
 48int	xfs_log_calc_minimum_size(struct xfs_mount *);
 49
 50struct xfs_trans_res;
 51void	xfs_log_get_max_trans_res(struct xfs_mount *mp,
 52				  struct xfs_trans_res *max_resp);
 53
 54/*
 55 * Values for t_flags.
 56 */
 57/* Transaction needs to be logged */
 58#define XFS_TRANS_DIRTY			(1u << 0)
 59/* Superblock is dirty and needs to be logged */
 60#define XFS_TRANS_SB_DIRTY		(1u << 1)
 61/* Transaction took a permanent log reservation */
 62#define XFS_TRANS_PERM_LOG_RES		(1u << 2)
 63/* Synchronous transaction commit needed */
 64#define XFS_TRANS_SYNC			(1u << 3)
 65/* Transaction can use reserve block pool */
 66#define XFS_TRANS_RESERVE		(1u << 4)
 67/* Transaction should avoid VFS level superblock write accounting */
 68#define XFS_TRANS_NO_WRITECOUNT		(1u << 5)
 69/* Transaction has freed blocks returned to it's reservation */
 70#define XFS_TRANS_RES_FDBLKS		(1u << 6)
 71/* Transaction contains an intent done log item */
 72#define XFS_TRANS_HAS_INTENT_DONE	(1u << 7)
 73
 74/*
 75 * LOWMODE is used by the allocator to activate the lowspace algorithm - when
 76 * free space is running low the extent allocator may choose to allocate an
 77 * extent from an AG without leaving sufficient space for a btree split when
 78 * inserting the new extent. In this case the allocator will enable the
 79 * lowspace algorithm which is supposed to allow further allocations (such as
 80 * btree splits and newroots) to allocate from sequential AGs. In order to
 81 * avoid locking AGs out of order the lowspace algorithm will start searching
 82 * for free space from AG 0. If the correct transaction reservations have been
 83 * made then this algorithm will eventually find all the space it needs.
 84 */
 85#define XFS_TRANS_LOWMODE	0x100	/* allocate in low space mode */
 86
 87/*
 88 * Field values for xfs_trans_mod_sb.
 89 */
 90#define	XFS_TRANS_SB_ICOUNT		0x00000001
 91#define	XFS_TRANS_SB_IFREE		0x00000002
 92#define	XFS_TRANS_SB_FDBLOCKS		0x00000004
 93#define	XFS_TRANS_SB_RES_FDBLOCKS	0x00000008
 94#define	XFS_TRANS_SB_FREXTENTS		0x00000010
 95#define	XFS_TRANS_SB_RES_FREXTENTS	0x00000020
 96#define	XFS_TRANS_SB_DBLOCKS		0x00000040
 97#define	XFS_TRANS_SB_AGCOUNT		0x00000080
 98#define	XFS_TRANS_SB_IMAXPCT		0x00000100
 99#define	XFS_TRANS_SB_REXTSIZE		0x00000200
100#define	XFS_TRANS_SB_RBMBLOCKS		0x00000400
101#define	XFS_TRANS_SB_RBLOCKS		0x00000800
102#define	XFS_TRANS_SB_REXTENTS		0x00001000
103#define	XFS_TRANS_SB_REXTSLOG		0x00002000
104
105/*
106 * Here we centralize the specification of XFS meta-data buffer reference count
107 * values.  This determines how hard the buffer cache tries to hold onto the
108 * buffer.
109 */
110#define	XFS_AGF_REF		4
111#define	XFS_AGI_REF		4
112#define	XFS_AGFL_REF		3
113#define	XFS_INO_BTREE_REF	3
114#define	XFS_ALLOC_BTREE_REF	2
115#define	XFS_BMAP_BTREE_REF	2
116#define	XFS_RMAP_BTREE_REF	2
117#define	XFS_DIR_BTREE_REF	2
118#define	XFS_INO_REF		2
119#define	XFS_ATTR_BTREE_REF	1
120#define	XFS_DQUOT_REF		1
121#define	XFS_REFC_BTREE_REF	1
122#define	XFS_SSB_REF		0
123
124/*
125 * Flags for xfs_trans_ichgtime().
126 */
127#define	XFS_ICHGTIME_MOD	0x1	/* data fork modification timestamp */
128#define	XFS_ICHGTIME_CHG	0x2	/* inode field change timestamp */
129#define	XFS_ICHGTIME_CREATE	0x4	/* inode create timestamp */
130
131
132/*
133 * Symlink decoding/encoding functions
134 */
135int xfs_symlink_blocks(struct xfs_mount *mp, int pathlen);
136int xfs_symlink_hdr_set(struct xfs_mount *mp, xfs_ino_t ino, uint32_t offset,
137			uint32_t size, struct xfs_buf *bp);
138bool xfs_symlink_hdr_ok(xfs_ino_t ino, uint32_t offset,
139			uint32_t size, struct xfs_buf *bp);
140void xfs_symlink_local_to_remote(struct xfs_trans *tp, struct xfs_buf *bp,
141				 struct xfs_inode *ip, struct xfs_ifork *ifp);
142xfs_failaddr_t xfs_symlink_shortform_verify(void *sfp, int64_t size);
143
144/* Computed inode geometry for the filesystem. */
145struct xfs_ino_geometry {
146	/* Maximum inode count in this filesystem. */
147	uint64_t	maxicount;
148
149	/* Actual inode cluster buffer size, in bytes. */
150	unsigned int	inode_cluster_size;
151
152	/*
153	 * Desired inode cluster buffer size, in bytes.  This value is not
154	 * rounded up to at least one filesystem block, which is necessary for
155	 * the sole purpose of validating sb_spino_align.  Runtime code must
156	 * only ever use inode_cluster_size.
157	 */
158	unsigned int	inode_cluster_size_raw;
159
160	/* Inode cluster sizes, adjusted to be at least 1 fsb. */
161	unsigned int	inodes_per_cluster;
162	unsigned int	blocks_per_cluster;
163
164	/* Inode cluster alignment. */
165	unsigned int	cluster_align;
166	unsigned int	cluster_align_inodes;
167	unsigned int	inoalign_mask;	/* mask sb_inoalignmt if used */
168
169	unsigned int	inobt_mxr[2]; /* max inobt btree records */
170	unsigned int	inobt_mnr[2]; /* min inobt btree records */
171	unsigned int	inobt_maxlevels; /* max inobt btree levels. */
172
173	/* Size of inode allocations under normal operation. */
174	unsigned int	ialloc_inos;
175	unsigned int	ialloc_blks;
176
177	/* Minimum inode blocks for a sparse allocation. */
178	unsigned int	ialloc_min_blks;
179
180	/* stripe unit inode alignment */
181	unsigned int	ialloc_align;
182
183	unsigned int	agino_log;	/* #bits for agino in inum */
184
185	/* precomputed default inode attribute fork offset */
186	unsigned int	attr_fork_offset;
187
188	/* precomputed value for di_flags2 */
189	uint64_t	new_diflags2;
190
191};
192
193#endif /* __XFS_SHARED_H__ */