Linux Audio

Check our new training course

Yocto / OpenEmbedded training

Feb 10-13, 2025
Register
Loading...
v6.8
  1// SPDX-License-Identifier: GPL-2.0
  2/*
  3 * Copyright (c) 2000,2005 Silicon Graphics, Inc.
  4 * All Rights Reserved.
 
 
 
 
 
 
 
 
 
 
 
 
 
  5 */
  6#ifndef __XFS_TRANS_SPACE_H__
  7#define __XFS_TRANS_SPACE_H__
  8
  9/*
 10 * Components of space reservations.
 11 */
 12
 13/* Worst case number of rmaps that can be held in a block. */
 14#define XFS_MAX_CONTIG_RMAPS_PER_BLOCK(mp)    \
 15		(((mp)->m_rmap_mxr[0]) - ((mp)->m_rmap_mnr[0]))
 16
 17/* Adding one rmap could split every level up to the top of the tree. */
 18#define XFS_RMAPADD_SPACE_RES(mp) ((mp)->m_rmap_maxlevels)
 19
 20/*
 21 * Note that we historically set m_rmap_maxlevels to 9 when reflink is enabled,
 22 * so we must preserve this behavior to avoid changing the transaction space
 23 * reservations and minimum log size calculations for existing filesystems.
 24 */
 25#define XFS_OLD_REFLINK_RMAP_MAXLEVELS		9
 26
 27/* Blocks we might need to add "b" rmaps to a tree. */
 28#define XFS_NRMAPADD_SPACE_RES(mp, b)\
 29	(((b + XFS_MAX_CONTIG_RMAPS_PER_BLOCK(mp) - 1) / \
 30	  XFS_MAX_CONTIG_RMAPS_PER_BLOCK(mp)) * \
 31	  XFS_RMAPADD_SPACE_RES(mp))
 32
 33#define XFS_MAX_CONTIG_EXTENTS_PER_BLOCK(mp)    \
 34		(((mp)->m_alloc_mxr[0]) - ((mp)->m_alloc_mnr[0]))
 35#define	XFS_EXTENTADD_SPACE_RES(mp,w)	(XFS_BM_MAXLEVELS(mp,w) - 1)
 36#define XFS_NEXTENTADD_SPACE_RES(mp,b,w)\
 37	(((b + XFS_MAX_CONTIG_EXTENTS_PER_BLOCK(mp) - 1) / \
 38	  XFS_MAX_CONTIG_EXTENTS_PER_BLOCK(mp)) * \
 39	  XFS_EXTENTADD_SPACE_RES(mp,w))
 40
 41/* Blocks we might need to add "b" mappings & rmappings to a file. */
 42#define XFS_SWAP_RMAP_SPACE_RES(mp,b,w)\
 43	(XFS_NEXTENTADD_SPACE_RES((mp), (b), (w)) + \
 44	 XFS_NRMAPADD_SPACE_RES((mp), (b)))
 45
 
 
 
 46#define	XFS_DAENTER_1B(mp,w)	\
 47	((w) == XFS_DATA_FORK ? (mp)->m_dir_geo->fsbcount : 1)
 48#define	XFS_DAENTER_DBS(mp,w)	\
 49	(XFS_DA_NODE_MAXDEPTH + (((w) == XFS_DATA_FORK) ? 2 : 0))
 50#define	XFS_DAENTER_BLOCKS(mp,w)	\
 51	(XFS_DAENTER_1B(mp,w) * XFS_DAENTER_DBS(mp,w))
 52#define	XFS_DAENTER_BMAP1B(mp,w)	\
 53	XFS_NEXTENTADD_SPACE_RES(mp, XFS_DAENTER_1B(mp, w), w)
 54#define	XFS_DAENTER_BMAPS(mp,w)		\
 55	(XFS_DAENTER_DBS(mp,w) * XFS_DAENTER_BMAP1B(mp,w))
 56#define	XFS_DAENTER_SPACE_RES(mp,w)	\
 57	(XFS_DAENTER_BLOCKS(mp,w) + XFS_DAENTER_BMAPS(mp,w))
 58#define	XFS_DAREMOVE_SPACE_RES(mp,w)	XFS_DAENTER_BMAPS(mp,w)
 59#define	XFS_DIRENTER_MAX_SPLIT(mp,nl)	1
 60#define	XFS_DIRENTER_SPACE_RES(mp,nl)	\
 61	(XFS_DAENTER_SPACE_RES(mp, XFS_DATA_FORK) * \
 62	 XFS_DIRENTER_MAX_SPLIT(mp,nl))
 63#define	XFS_DIRREMOVE_SPACE_RES(mp)	\
 64	XFS_DAREMOVE_SPACE_RES(mp, XFS_DATA_FORK)
 65#define	XFS_IALLOC_SPACE_RES(mp)	\
 66	(M_IGEO(mp)->ialloc_blks + \
 67	 ((xfs_has_finobt(mp) ? 2 : 1) * M_IGEO(mp)->inobt_maxlevels))
 
 68
 69/*
 70 * Space reservation values for various transactions.
 71 */
 72#define	XFS_ADDAFORK_SPACE_RES(mp)	\
 73	((mp)->m_dir_geo->fsbcount + XFS_DAENTER_BMAP1B(mp, XFS_DATA_FORK))
 74#define	XFS_ATTRRM_SPACE_RES(mp)	\
 75	XFS_DAREMOVE_SPACE_RES(mp, XFS_ATTR_FORK)
 76/* This macro is not used - see inline code in xfs_attr_set */
 77#define	XFS_ATTRSET_SPACE_RES(mp, v)	\
 78	(XFS_DAENTER_SPACE_RES(mp, XFS_ATTR_FORK) + XFS_B_TO_FSB(mp, v))
 79#define	XFS_CREATE_SPACE_RES(mp,nl)	\
 80	(XFS_IALLOC_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl))
 81#define	XFS_DIOSTRAT_SPACE_RES(mp, v)	\
 82	(XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK) + (v))
 83#define	XFS_GROWFS_SPACE_RES(mp)	\
 84	(2 * (mp)->m_alloc_maxlevels)
 85#define	XFS_GROWFSRT_SPACE_RES(mp,b)	\
 86	((b) + XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK))
 87#define	XFS_LINK_SPACE_RES(mp,nl)	\
 88	XFS_DIRENTER_SPACE_RES(mp,nl)
 89#define	XFS_MKDIR_SPACE_RES(mp,nl)	\
 90	(XFS_IALLOC_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl))
 91#define	XFS_QM_DQALLOC_SPACE_RES(mp)	\
 92	(XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK) + \
 93	 XFS_DQUOT_CLUSTER_SIZE_FSB)
 94#define	XFS_QM_QINOCREATE_SPACE_RES(mp)	\
 95	XFS_IALLOC_SPACE_RES(mp)
 96#define	XFS_REMOVE_SPACE_RES(mp)	\
 97	XFS_DIRREMOVE_SPACE_RES(mp)
 98#define	XFS_RENAME_SPACE_RES(mp,nl)	\
 99	(XFS_DIRREMOVE_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl))
100#define	XFS_SYMLINK_SPACE_RES(mp,nl,b)	\
101	(XFS_IALLOC_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl) + (b))
102#define XFS_IFREE_SPACE_RES(mp)		\
103	(xfs_has_finobt(mp) ? M_IGEO(mp)->inobt_maxlevels : 0)
104
105
106#endif	/* __XFS_TRANS_SPACE_H__ */
v4.10.11
 
  1/*
  2 * Copyright (c) 2000,2005 Silicon Graphics, Inc.
  3 * All Rights Reserved.
  4 *
  5 * This program is free software; you can redistribute it and/or
  6 * modify it under the terms of the GNU General Public License as
  7 * published by the Free Software Foundation.
  8 *
  9 * This program is distributed in the hope that it would be useful,
 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 12 * GNU General Public License for more details.
 13 *
 14 * You should have received a copy of the GNU General Public License
 15 * along with this program; if not, write the Free Software Foundation,
 16 * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 17 */
 18#ifndef __XFS_TRANS_SPACE_H__
 19#define __XFS_TRANS_SPACE_H__
 20
 21/*
 22 * Components of space reservations.
 23 */
 
 
 24#define XFS_MAX_CONTIG_RMAPS_PER_BLOCK(mp)    \
 25		(((mp)->m_rmap_mxr[0]) - ((mp)->m_rmap_mnr[0]))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 26#define XFS_MAX_CONTIG_EXTENTS_PER_BLOCK(mp)    \
 27		(((mp)->m_alloc_mxr[0]) - ((mp)->m_alloc_mnr[0]))
 28#define	XFS_EXTENTADD_SPACE_RES(mp,w)	(XFS_BM_MAXLEVELS(mp,w) - 1)
 29#define XFS_NEXTENTADD_SPACE_RES(mp,b,w)\
 30	(((b + XFS_MAX_CONTIG_EXTENTS_PER_BLOCK(mp) - 1) / \
 31	  XFS_MAX_CONTIG_EXTENTS_PER_BLOCK(mp)) * \
 32	  XFS_EXTENTADD_SPACE_RES(mp,w))
 
 
 33#define XFS_SWAP_RMAP_SPACE_RES(mp,b,w)\
 34	(((b + XFS_MAX_CONTIG_EXTENTS_PER_BLOCK(mp) - 1) / \
 35	  XFS_MAX_CONTIG_EXTENTS_PER_BLOCK(mp)) * \
 36	  XFS_EXTENTADD_SPACE_RES(mp,w) + \
 37	 ((b + XFS_MAX_CONTIG_RMAPS_PER_BLOCK(mp) - 1) / \
 38	  XFS_MAX_CONTIG_RMAPS_PER_BLOCK(mp)) * \
 39	  (mp)->m_rmap_maxlevels)
 40#define	XFS_DAENTER_1B(mp,w)	\
 41	((w) == XFS_DATA_FORK ? (mp)->m_dir_geo->fsbcount : 1)
 42#define	XFS_DAENTER_DBS(mp,w)	\
 43	(XFS_DA_NODE_MAXDEPTH + (((w) == XFS_DATA_FORK) ? 2 : 0))
 44#define	XFS_DAENTER_BLOCKS(mp,w)	\
 45	(XFS_DAENTER_1B(mp,w) * XFS_DAENTER_DBS(mp,w))
 46#define	XFS_DAENTER_BMAP1B(mp,w)	\
 47	XFS_NEXTENTADD_SPACE_RES(mp, XFS_DAENTER_1B(mp, w), w)
 48#define	XFS_DAENTER_BMAPS(mp,w)		\
 49	(XFS_DAENTER_DBS(mp,w) * XFS_DAENTER_BMAP1B(mp,w))
 50#define	XFS_DAENTER_SPACE_RES(mp,w)	\
 51	(XFS_DAENTER_BLOCKS(mp,w) + XFS_DAENTER_BMAPS(mp,w))
 52#define	XFS_DAREMOVE_SPACE_RES(mp,w)	XFS_DAENTER_BMAPS(mp,w)
 53#define	XFS_DIRENTER_MAX_SPLIT(mp,nl)	1
 54#define	XFS_DIRENTER_SPACE_RES(mp,nl)	\
 55	(XFS_DAENTER_SPACE_RES(mp, XFS_DATA_FORK) * \
 56	 XFS_DIRENTER_MAX_SPLIT(mp,nl))
 57#define	XFS_DIRREMOVE_SPACE_RES(mp)	\
 58	XFS_DAREMOVE_SPACE_RES(mp, XFS_DATA_FORK)
 59#define	XFS_IALLOC_SPACE_RES(mp)	\
 60	((mp)->m_ialloc_blks + \
 61	 (xfs_sb_version_hasfinobt(&mp->m_sb) ? 2 : 1 * \
 62	  ((mp)->m_in_maxlevels - 1)))
 63
 64/*
 65 * Space reservation values for various transactions.
 66 */
 67#define	XFS_ADDAFORK_SPACE_RES(mp)	\
 68	((mp)->m_dir_geo->fsbcount + XFS_DAENTER_BMAP1B(mp, XFS_DATA_FORK))
 69#define	XFS_ATTRRM_SPACE_RES(mp)	\
 70	XFS_DAREMOVE_SPACE_RES(mp, XFS_ATTR_FORK)
 71/* This macro is not used - see inline code in xfs_attr_set */
 72#define	XFS_ATTRSET_SPACE_RES(mp, v)	\
 73	(XFS_DAENTER_SPACE_RES(mp, XFS_ATTR_FORK) + XFS_B_TO_FSB(mp, v))
 74#define	XFS_CREATE_SPACE_RES(mp,nl)	\
 75	(XFS_IALLOC_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl))
 76#define	XFS_DIOSTRAT_SPACE_RES(mp, v)	\
 77	(XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK) + (v))
 78#define	XFS_GROWFS_SPACE_RES(mp)	\
 79	(2 * (mp)->m_ag_maxlevels)
 80#define	XFS_GROWFSRT_SPACE_RES(mp,b)	\
 81	((b) + XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK))
 82#define	XFS_LINK_SPACE_RES(mp,nl)	\
 83	XFS_DIRENTER_SPACE_RES(mp,nl)
 84#define	XFS_MKDIR_SPACE_RES(mp,nl)	\
 85	(XFS_IALLOC_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl))
 86#define	XFS_QM_DQALLOC_SPACE_RES(mp)	\
 87	(XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK) + \
 88	 XFS_DQUOT_CLUSTER_SIZE_FSB)
 89#define	XFS_QM_QINOCREATE_SPACE_RES(mp)	\
 90	XFS_IALLOC_SPACE_RES(mp)
 91#define	XFS_REMOVE_SPACE_RES(mp)	\
 92	XFS_DIRREMOVE_SPACE_RES(mp)
 93#define	XFS_RENAME_SPACE_RES(mp,nl)	\
 94	(XFS_DIRREMOVE_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl))
 95#define	XFS_SYMLINK_SPACE_RES(mp,nl,b)	\
 96	(XFS_IALLOC_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl) + (b))
 97#define XFS_IFREE_SPACE_RES(mp)		\
 98	(xfs_sb_version_hasfinobt(&mp->m_sb) ? (mp)->m_in_maxlevels : 0)
 99
100
101#endif	/* __XFS_TRANS_SPACE_H__ */