blob: 7fe3792b18df6cfc633c1b22068012c5b58074aa [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))
31#define XFS_DAENTER_1B(mp,w) ((w) == XFS_DATA_FORK ? (mp)->m_dirblkfsbs : 1)
32#define XFS_DAENTER_DBS(mp,w) \
33 (XFS_DA_NODE_MAXDEPTH + \
34 ((XFS_DIR_IS_V2(mp) && (w) == XFS_DATA_FORK) ? 2 : 0))
35#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)
44#define XFS_DIRENTER_MAX_SPLIT(mp,nl) \
45 (((mp)->m_sb.sb_blocksize == 512 && \
46 XFS_DIR_IS_V1(mp) && \
47 (nl) >= XFS_DIR_LEAF_CAN_DOUBLE_SPLIT_LEN) ? 2 : 1)
48#define XFS_DIRENTER_SPACE_RES(mp,nl) \
49 (XFS_DAENTER_SPACE_RES(mp, XFS_DATA_FORK) * \
50 XFS_DIRENTER_MAX_SPLIT(mp,nl))
51#define XFS_DIRREMOVE_SPACE_RES(mp) \
52 XFS_DAREMOVE_SPACE_RES(mp, XFS_DATA_FORK)
53#define XFS_IALLOC_SPACE_RES(mp) \
54 (XFS_IALLOC_BLOCKS(mp) + XFS_IN_MAXLEVELS(mp)-1)
55
56/*
57 * Space reservation values for various transactions.
58 */
59#define XFS_ADDAFORK_SPACE_RES(mp) \
60 ((mp)->m_dirblkfsbs + \
61 (XFS_DIR_IS_V1(mp) ? 0 : XFS_DAENTER_BMAP1B(mp, XFS_DATA_FORK)))
62#define XFS_ATTRRM_SPACE_RES(mp) \
63 XFS_DAREMOVE_SPACE_RES(mp, XFS_ATTR_FORK)
64/* This macro is not used - see inline code in xfs_attr_set */
65#define XFS_ATTRSET_SPACE_RES(mp, v) \
66 (XFS_DAENTER_SPACE_RES(mp, XFS_ATTR_FORK) + XFS_B_TO_FSB(mp, v))
67#define XFS_CREATE_SPACE_RES(mp,nl) \
68 (XFS_IALLOC_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl))
69#define XFS_DIOSTRAT_SPACE_RES(mp, v) \
70 (XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK) + (v))
71#define XFS_GROWFS_SPACE_RES(mp) \
72 (2 * XFS_AG_MAXLEVELS(mp))
73#define XFS_GROWFSRT_SPACE_RES(mp,b) \
74 ((b) + XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK))
75#define XFS_LINK_SPACE_RES(mp,nl) \
76 XFS_DIRENTER_SPACE_RES(mp,nl)
77#define XFS_MKDIR_SPACE_RES(mp,nl) \
78 (XFS_IALLOC_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl))
79#define XFS_QM_DQALLOC_SPACE_RES(mp) \
80 (XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK) + \
81 XFS_DQUOT_CLUSTER_SIZE_FSB)
82#define XFS_QM_QINOCREATE_SPACE_RES(mp) \
83 XFS_IALLOC_SPACE_RES(mp)
84#define XFS_REMOVE_SPACE_RES(mp) \
85 XFS_DIRREMOVE_SPACE_RES(mp)
86#define XFS_RENAME_SPACE_RES(mp,nl) \
87 (XFS_DIRREMOVE_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl))
88#define XFS_SYMLINK_SPACE_RES(mp,nl,b) \
89 (XFS_IALLOC_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl) + (b))
90
91#endif /* __XFS_TRANS_SPACE_H__ */