Commit | Line | Data |
---|---|---|
7fd36c44 DC |
1 | /* |
2 | * Copyright (c) 2000-2002,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_RESV_H__ | |
19 | #define __XFS_TRANS_RESV_H__ | |
20 | ||
21 | struct xfs_mount; | |
22 | ||
23 | /* | |
24 | * structure for maintaining pre-calculated transaction reservations. | |
25 | */ | |
0eadd102 JL |
26 | struct xfs_trans_res { |
27 | uint tr_logres; /* log space unit in bytes per log ticket */ | |
28 | int tr_logcount; /* number of log operations per log ticket */ | |
29 | int tr_logflags; /* log flags, currently only used for indicating | |
30 | * a reservation request is permanent or not */ | |
31 | }; | |
32 | ||
7fd36c44 | 33 | struct xfs_trans_resv { |
0eadd102 JL |
34 | struct xfs_trans_res tr_write; /* extent alloc trans */ |
35 | struct xfs_trans_res tr_itruncate; /* truncate trans */ | |
36 | struct xfs_trans_res tr_rename; /* rename trans */ | |
37 | struct xfs_trans_res tr_link; /* link trans */ | |
38 | struct xfs_trans_res tr_remove; /* unlink trans */ | |
39 | struct xfs_trans_res tr_symlink; /* symlink trans */ | |
40 | struct xfs_trans_res tr_create; /* create trans */ | |
41 | struct xfs_trans_res tr_mkdir; /* mkdir trans */ | |
42 | struct xfs_trans_res tr_ifree; /* inode free trans */ | |
43 | struct xfs_trans_res tr_ichange; /* inode update trans */ | |
44 | struct xfs_trans_res tr_growdata; /* fs data section grow trans */ | |
45 | struct xfs_trans_res tr_swrite; /* sync write inode trans */ | |
46 | struct xfs_trans_res tr_addafork; /* add inode attr fork trans */ | |
47 | struct xfs_trans_res tr_writeid; /* write setuid/setgid file */ | |
48 | struct xfs_trans_res tr_attrinval; /* attr fork buffer | |
49 | * invalidation */ | |
50 | struct xfs_trans_res tr_attrsetm; /* set/create an attribute at | |
51 | * mount time */ | |
52 | struct xfs_trans_res tr_attrsetrt; /* set/create an attribute at | |
53 | * runtime */ | |
54 | struct xfs_trans_res tr_attrrm; /* remove an attribute */ | |
55 | struct xfs_trans_res tr_clearagi; /* clear agi unlinked bucket */ | |
56 | struct xfs_trans_res tr_growrtalloc; /* grow realtime allocations */ | |
57 | struct xfs_trans_res tr_growrtzero; /* grow realtime zeroing */ | |
58 | struct xfs_trans_res tr_growrtfree; /* grow realtime freeing */ | |
59 | struct xfs_trans_res tr_qm_sbchange; /* change quota flags */ | |
60 | struct xfs_trans_res tr_qm_setqlim; /* adjust quota limits */ | |
61 | struct xfs_trans_res tr_qm_dqalloc; /* allocate quota on disk */ | |
62 | struct xfs_trans_res tr_qm_quotaoff; /* turn quota off */ | |
63 | struct xfs_trans_res tr_qm_equotaoff;/* end of turn quota off */ | |
64 | struct xfs_trans_res tr_sb; /* modify superblock */ | |
7fd36c44 DC |
65 | }; |
66 | ||
67 | /* | |
68 | * Per-extent log reservation for the allocation btree changes | |
69 | * involved in freeing or allocating an extent. | |
70 | * 2 trees * (2 blocks/level * max depth - 1) * block size | |
71 | */ | |
72 | #define XFS_ALLOCFREE_LOG_RES(mp,nx) \ | |
73 | ((nx) * (2 * XFS_FSB_TO_B((mp), 2 * XFS_AG_MAXLEVELS(mp) - 1))) | |
74 | #define XFS_ALLOCFREE_LOG_COUNT(mp,nx) \ | |
75 | ((nx) * (2 * (2 * XFS_AG_MAXLEVELS(mp) - 1))) | |
76 | ||
77 | /* | |
78 | * Per-directory log reservation for any directory change. | |
79 | * dir blocks: (1 btree block per level + data block + free block) * dblock size | |
80 | * bmap btree: (levels + 2) * max depth * block size | |
81 | * v2 directory blocks can be fragmented below the dirblksize down to the fsb | |
82 | * size, so account for that in the DAENTER macros. | |
83 | */ | |
84 | #define XFS_DIROP_LOG_RES(mp) \ | |
85 | (XFS_FSB_TO_B(mp, XFS_DAENTER_BLOCKS(mp, XFS_DATA_FORK)) + \ | |
86 | (XFS_FSB_TO_B(mp, XFS_DAENTER_BMAPS(mp, XFS_DATA_FORK) + 1))) | |
87 | #define XFS_DIROP_LOG_COUNT(mp) \ | |
88 | (XFS_DAENTER_BLOCKS(mp, XFS_DATA_FORK) + \ | |
89 | XFS_DAENTER_BMAPS(mp, XFS_DATA_FORK) + 1) | |
90 | ||
91 | ||
0eadd102 JL |
92 | #define XFS_WRITE_LOG_RES(mp) ((mp)->m_resv.tr_write.tr_logres) |
93 | #define XFS_RENAME_LOG_RES(mp) ((mp)->m_resv.tr_rename.tr_logres) | |
94 | #define XFS_LINK_LOG_RES(mp) ((mp)->m_resv.tr_link.tr_logres) | |
95 | #define XFS_REMOVE_LOG_RES(mp) ((mp)->m_resv.tr_remove.tr_logres) | |
96 | #define XFS_SYMLINK_LOG_RES(mp) ((mp)->m_resv.tr_symlink.tr_logres) | |
97 | #define XFS_CREATE_LOG_RES(mp) ((mp)->m_resv.tr_create.tr_logres) | |
98 | #define XFS_MKDIR_LOG_RES(mp) ((mp)->m_resv.tr_mkdir.tr_logres) | |
99 | #define XFS_IFREE_LOG_RES(mp) ((mp)->m_resv.tr_ifree.tr_logres) | |
100 | #define XFS_SWRITE_LOG_RES(mp) ((mp)->m_resv.tr_swrite.tr_logres) | |
101 | #define XFS_ICHANGE_LOG_RES(mp) ((mp)->m_resv.tr_ichange.tr_logres) | |
102 | #define XFS_GROWDATA_LOG_RES(mp) ((mp)->m_resv.tr_growdata.tr_logres) | |
103 | #define XFS_ITRUNCATE_LOG_RES(mp) ((mp)->m_resv.tr_itruncate.tr_logres) | |
104 | #define XFS_GROWRTZERO_LOG_RES(mp) ((mp)->m_resv.tr_growrtzero.tr_logres) | |
105 | #define XFS_GROWRTFREE_LOG_RES(mp) ((mp)->m_resv.tr_growrtfree.tr_logres) | |
106 | #define XFS_GROWRTALLOC_LOG_RES(mp) ((mp)->m_resv.tr_growrtalloc.tr_logres) | |
107 | ||
7fd36c44 DC |
108 | /* |
109 | * Logging the inode timestamps on an fsync -- same as SWRITE | |
110 | * as long as SWRITE logs the entire inode core | |
111 | */ | |
0eadd102 JL |
112 | #define XFS_FSYNC_TS_LOG_RES(mp) ((mp)->m_resv.tr_swrite.tr_logres) |
113 | #define XFS_WRITEID_LOG_RES(mp) ((mp)->m_resv.tr_swrite.tr_logres) | |
114 | #define XFS_ADDAFORK_LOG_RES(mp) ((mp)->m_resv.tr_addafork.tr_logres) | |
115 | #define XFS_ATTRSETM_LOG_RES(mp) ((mp)->m_resv.tr_attrsetm.tr_logres) | |
116 | #define XFS_ATTRINVAL_LOG_RES(mp) ((mp)->m_resv.tr_attrinval.tr_logres) | |
117 | #define XFS_ATTRSETRT_LOG_RES(mp) ((mp)->m_resv.tr_attrsetrt.tr_logres) | |
118 | #define XFS_ATTRRM_LOG_RES(mp) ((mp)->m_resv.tr_attrrm.tr_logres) | |
119 | #define XFS_SB_LOG_RES(mp) ((mp)->m_resv.tr_sb.tr_logres) | |
120 | #define XFS_QM_SETQLIM_LOG_RES(mp) ((mp)->m_resv.tr_qm_setqlim.tr_logres) | |
121 | #define XFS_QM_DQALLOC_LOG_RES(mp) ((mp)->m_resv.tr_qm_dqalloc.tr_logres) | |
122 | #define XFS_QM_SBCHANGE_LOG_RES(mp) ((mp)->m_resv.tr_qm_sbchange.tr_logres) | |
123 | #define XFS_QM_QUOTAOFF_LOG_RES(mp) ((mp)->m_resv.tr_qm_quotaoff.tr_logres) | |
124 | #define XFS_QM_QUOTAOFF_END_LOG_RES(mp) ((mp)->m_resv.tr_qm_equotaoff.tr_logres) | |
125 | #define XFS_CLEAR_AGI_BUCKET_LOG_RES(mp) ((mp)->m_resv.tr_clearagi.tr_logres) | |
7fd36c44 DC |
126 | |
127 | /* | |
128 | * Various log count values. | |
129 | */ | |
130 | #define XFS_DEFAULT_LOG_COUNT 1 | |
131 | #define XFS_DEFAULT_PERM_LOG_COUNT 2 | |
132 | #define XFS_ITRUNCATE_LOG_COUNT 2 | |
133 | #define XFS_INACTIVE_LOG_COUNT 2 | |
134 | #define XFS_CREATE_LOG_COUNT 2 | |
135 | #define XFS_MKDIR_LOG_COUNT 3 | |
136 | #define XFS_SYMLINK_LOG_COUNT 3 | |
137 | #define XFS_REMOVE_LOG_COUNT 2 | |
138 | #define XFS_LINK_LOG_COUNT 2 | |
139 | #define XFS_RENAME_LOG_COUNT 2 | |
140 | #define XFS_WRITE_LOG_COUNT 2 | |
141 | #define XFS_ADDAFORK_LOG_COUNT 2 | |
142 | #define XFS_ATTRINVAL_LOG_COUNT 1 | |
143 | #define XFS_ATTRSET_LOG_COUNT 3 | |
144 | #define XFS_ATTRRM_LOG_COUNT 3 | |
145 | ||
146 | void xfs_trans_resv_calc(struct xfs_mount *mp, struct xfs_trans_resv *resp); | |
147 | ||
148 | #endif /* __XFS_TRANS_RESV_H__ */ |