blob: bf9c4579334d500fea6c917d2a149ba05dead7fb [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Nathan Scott7b718762005-11-02 14:58:39 +11002 * Copyright (c) 2000,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
Nathan Scott7b718762005-11-02 14:58:39 +11005 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 * published by the Free Software Foundation.
8 *
Nathan Scott7b718762005-11-02 14:58:39 +11009 * 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.
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 *
Nathan Scott7b718762005-11-02 14:58:39 +110014 * 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
Linus Torvalds1da177e2005-04-16 15:20:36 -070017 */
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_EXTENTS_PER_BLOCK(mp) \
25 (((mp)->m_alloc_mxr[0]) - ((mp)->m_alloc_mnr[0]))
26#define XFS_EXTENTADD_SPACE_RES(mp,w) (XFS_BM_MAXLEVELS(mp,w) - 1)
27#define XFS_NEXTENTADD_SPACE_RES(mp,b,w)\
28 (((b + XFS_MAX_CONTIG_EXTENTS_PER_BLOCK(mp) - 1) / \
29 XFS_MAX_CONTIG_EXTENTS_PER_BLOCK(mp)) * \
30 XFS_EXTENTADD_SPACE_RES(mp,w))
Dave Chinnerd6cf1302014-06-06 15:14:11 +100031#define XFS_DAENTER_1B(mp,w) \
32 ((w) == XFS_DATA_FORK ? (mp)->m_dir_geo->fsbcount : 1)
Linus Torvalds1da177e2005-04-16 15:20:36 -070033#define XFS_DAENTER_DBS(mp,w) \
Nathan Scottf6c2d1f2006-06-20 13:04:51 +100034 (XFS_DA_NODE_MAXDEPTH + (((w) == XFS_DATA_FORK) ? 2 : 0))
Linus Torvalds1da177e2005-04-16 15:20:36 -070035#define XFS_DAENTER_BLOCKS(mp,w) \
36 (XFS_DAENTER_1B(mp,w) * XFS_DAENTER_DBS(mp,w))
37#define XFS_DAENTER_BMAP1B(mp,w) \
38 XFS_NEXTENTADD_SPACE_RES(mp, XFS_DAENTER_1B(mp, w), w)
39#define XFS_DAENTER_BMAPS(mp,w) \
40 (XFS_DAENTER_DBS(mp,w) * XFS_DAENTER_BMAP1B(mp,w))
41#define XFS_DAENTER_SPACE_RES(mp,w) \
42 (XFS_DAENTER_BLOCKS(mp,w) + XFS_DAENTER_BMAPS(mp,w))
43#define XFS_DAREMOVE_SPACE_RES(mp,w) XFS_DAENTER_BMAPS(mp,w)
Nathan Scottf6c2d1f2006-06-20 13:04:51 +100044#define XFS_DIRENTER_MAX_SPLIT(mp,nl) 1
Linus Torvalds1da177e2005-04-16 15:20:36 -070045#define XFS_DIRENTER_SPACE_RES(mp,nl) \
46 (XFS_DAENTER_SPACE_RES(mp, XFS_DATA_FORK) * \
47 XFS_DIRENTER_MAX_SPLIT(mp,nl))
48#define XFS_DIRREMOVE_SPACE_RES(mp) \
49 XFS_DAREMOVE_SPACE_RES(mp, XFS_DATA_FORK)
50#define XFS_IALLOC_SPACE_RES(mp) \
Brian Foster9d43b182014-04-24 16:00:52 +100051 ((mp)->m_ialloc_blks + \
52 (xfs_sb_version_hasfinobt(&mp->m_sb) ? 2 : 1 * \
53 ((mp)->m_in_maxlevels - 1)))
Linus Torvalds1da177e2005-04-16 15:20:36 -070054
55/*
56 * Space reservation values for various transactions.
57 */
58#define XFS_ADDAFORK_SPACE_RES(mp) \
Dave Chinnerd6cf1302014-06-06 15:14:11 +100059 ((mp)->m_dir_geo->fsbcount + XFS_DAENTER_BMAP1B(mp, XFS_DATA_FORK))
Linus Torvalds1da177e2005-04-16 15:20:36 -070060#define XFS_ATTRRM_SPACE_RES(mp) \
61 XFS_DAREMOVE_SPACE_RES(mp, XFS_ATTR_FORK)
62/* This macro is not used - see inline code in xfs_attr_set */
63#define XFS_ATTRSET_SPACE_RES(mp, v) \
64 (XFS_DAENTER_SPACE_RES(mp, XFS_ATTR_FORK) + XFS_B_TO_FSB(mp, v))
65#define XFS_CREATE_SPACE_RES(mp,nl) \
66 (XFS_IALLOC_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl))
67#define XFS_DIOSTRAT_SPACE_RES(mp, v) \
68 (XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK) + (v))
69#define XFS_GROWFS_SPACE_RES(mp) \
70 (2 * XFS_AG_MAXLEVELS(mp))
71#define XFS_GROWFSRT_SPACE_RES(mp,b) \
72 ((b) + XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK))
73#define XFS_LINK_SPACE_RES(mp,nl) \
74 XFS_DIRENTER_SPACE_RES(mp,nl)
75#define XFS_MKDIR_SPACE_RES(mp,nl) \
76 (XFS_IALLOC_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl))
77#define XFS_QM_DQALLOC_SPACE_RES(mp) \
78 (XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK) + \
79 XFS_DQUOT_CLUSTER_SIZE_FSB)
80#define XFS_QM_QINOCREATE_SPACE_RES(mp) \
81 XFS_IALLOC_SPACE_RES(mp)
82#define XFS_REMOVE_SPACE_RES(mp) \
83 XFS_DIRREMOVE_SPACE_RES(mp)
84#define XFS_RENAME_SPACE_RES(mp,nl) \
85 (XFS_DIRREMOVE_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl))
86#define XFS_SYMLINK_SPACE_RES(mp,nl,b) \
87 (XFS_IALLOC_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl) + (b))
Brian Foster9d43b182014-04-24 16:00:52 +100088#define XFS_IFREE_SPACE_RES(mp) \
89 (xfs_sb_version_hasfinobt(&mp->m_sb) ? (mp)->m_in_maxlevels : 0)
90
Linus Torvalds1da177e2005-04-16 15:20:36 -070091
92#endif /* __XFS_TRANS_SPACE_H__ */