Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 2 | * Copyright (c) 2000,2005 Silicon Graphics, Inc. |
| 3 | * All Rights Reserved. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 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 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * published by the Free Software Foundation. |
| 8 | * |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 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. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | * |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 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 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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_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) \ |
Nathan Scott | f6c2d1f | 2006-06-20 13:04:51 +1000 | [diff] [blame] | 33 | (XFS_DA_NODE_MAXDEPTH + (((w) == XFS_DATA_FORK) ? 2 : 0)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | #define XFS_DAENTER_BLOCKS(mp,w) \ |
| 35 | (XFS_DAENTER_1B(mp,w) * XFS_DAENTER_DBS(mp,w)) |
| 36 | #define XFS_DAENTER_BMAP1B(mp,w) \ |
| 37 | XFS_NEXTENTADD_SPACE_RES(mp, XFS_DAENTER_1B(mp, w), w) |
| 38 | #define XFS_DAENTER_BMAPS(mp,w) \ |
| 39 | (XFS_DAENTER_DBS(mp,w) * XFS_DAENTER_BMAP1B(mp,w)) |
| 40 | #define XFS_DAENTER_SPACE_RES(mp,w) \ |
| 41 | (XFS_DAENTER_BLOCKS(mp,w) + XFS_DAENTER_BMAPS(mp,w)) |
| 42 | #define XFS_DAREMOVE_SPACE_RES(mp,w) XFS_DAENTER_BMAPS(mp,w) |
Nathan Scott | f6c2d1f | 2006-06-20 13:04:51 +1000 | [diff] [blame] | 43 | #define XFS_DIRENTER_MAX_SPLIT(mp,nl) 1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | #define XFS_DIRENTER_SPACE_RES(mp,nl) \ |
| 45 | (XFS_DAENTER_SPACE_RES(mp, XFS_DATA_FORK) * \ |
| 46 | XFS_DIRENTER_MAX_SPLIT(mp,nl)) |
| 47 | #define XFS_DIRREMOVE_SPACE_RES(mp) \ |
| 48 | XFS_DAREMOVE_SPACE_RES(mp, XFS_DATA_FORK) |
| 49 | #define XFS_IALLOC_SPACE_RES(mp) \ |
Christoph Hellwig | 0d87e65 | 2009-02-09 08:37:14 +0100 | [diff] [blame^] | 50 | (XFS_IALLOC_BLOCKS(mp) + (mp)->m_in_maxlevels - 1) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | |
| 52 | /* |
| 53 | * Space reservation values for various transactions. |
| 54 | */ |
| 55 | #define XFS_ADDAFORK_SPACE_RES(mp) \ |
Nathan Scott | f6c2d1f | 2006-06-20 13:04:51 +1000 | [diff] [blame] | 56 | ((mp)->m_dirblkfsbs + XFS_DAENTER_BMAP1B(mp, XFS_DATA_FORK)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | #define XFS_ATTRRM_SPACE_RES(mp) \ |
| 58 | XFS_DAREMOVE_SPACE_RES(mp, XFS_ATTR_FORK) |
| 59 | /* This macro is not used - see inline code in xfs_attr_set */ |
| 60 | #define XFS_ATTRSET_SPACE_RES(mp, v) \ |
| 61 | (XFS_DAENTER_SPACE_RES(mp, XFS_ATTR_FORK) + XFS_B_TO_FSB(mp, v)) |
| 62 | #define XFS_CREATE_SPACE_RES(mp,nl) \ |
| 63 | (XFS_IALLOC_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl)) |
| 64 | #define XFS_DIOSTRAT_SPACE_RES(mp, v) \ |
| 65 | (XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK) + (v)) |
| 66 | #define XFS_GROWFS_SPACE_RES(mp) \ |
| 67 | (2 * XFS_AG_MAXLEVELS(mp)) |
| 68 | #define XFS_GROWFSRT_SPACE_RES(mp,b) \ |
| 69 | ((b) + XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK)) |
| 70 | #define XFS_LINK_SPACE_RES(mp,nl) \ |
| 71 | XFS_DIRENTER_SPACE_RES(mp,nl) |
| 72 | #define XFS_MKDIR_SPACE_RES(mp,nl) \ |
| 73 | (XFS_IALLOC_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl)) |
| 74 | #define XFS_QM_DQALLOC_SPACE_RES(mp) \ |
| 75 | (XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK) + \ |
| 76 | XFS_DQUOT_CLUSTER_SIZE_FSB) |
| 77 | #define XFS_QM_QINOCREATE_SPACE_RES(mp) \ |
| 78 | XFS_IALLOC_SPACE_RES(mp) |
| 79 | #define XFS_REMOVE_SPACE_RES(mp) \ |
| 80 | XFS_DIRREMOVE_SPACE_RES(mp) |
| 81 | #define XFS_RENAME_SPACE_RES(mp,nl) \ |
| 82 | (XFS_DIRREMOVE_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl)) |
| 83 | #define XFS_SYMLINK_SPACE_RES(mp,nl,b) \ |
| 84 | (XFS_IALLOC_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl) + (b)) |
| 85 | |
| 86 | #endif /* __XFS_TRANS_SPACE_H__ */ |