blob: 173b1bc13ffeb39ed8647014aa555dac5b154275 [file] [log] [blame]
Dave Chinner7fd36c42013-08-12 20:49:32 +10001/*
2 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * Copyright (C) 2010 Red Hat, Inc.
4 * All Rights Reserved.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it would be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19#include "xfs.h"
20#include "xfs_fs.h"
Dave Chinner70a98832013-10-23 10:36:05 +110021#include "xfs_shared.h"
Dave Chinner239880e2013-10-23 10:50:10 +110022#include "xfs_format.h"
23#include "xfs_log_format.h"
Dave Chinner7fd36c42013-08-12 20:49:32 +100024#include "xfs_trans_resv.h"
Dave Chinner7fd36c42013-08-12 20:49:32 +100025#include "xfs_mount.h"
Dave Chinner57062782013-10-15 09:17:51 +110026#include "xfs_da_format.h"
Dave Chinnerd6cf1302014-06-06 15:14:11 +100027#include "xfs_da_btree.h"
Dave Chinner7fd36c42013-08-12 20:49:32 +100028#include "xfs_inode.h"
Dave Chinnera4fbe6a2013-10-23 10:51:50 +110029#include "xfs_bmap_btree.h"
Dave Chinner7fd36c42013-08-12 20:49:32 +100030#include "xfs_ialloc.h"
Dave Chinner7fd36c42013-08-12 20:49:32 +100031#include "xfs_quota.h"
Dave Chinner239880e2013-10-23 10:50:10 +110032#include "xfs_trans.h"
Dave Chinner7fd36c42013-08-12 20:49:32 +100033#include "xfs_qm.h"
34#include "xfs_trans_space.h"
35#include "xfs_trace.h"
36
37/*
38 * A buffer has a format structure overhead in the log in addition
39 * to the data, so we need to take this into account when reserving
40 * space in a transaction for a buffer. Round the space required up
41 * to a multiple of 128 bytes so that we don't change the historical
42 * reservation that has been used for this overhead.
43 */
44STATIC uint
45xfs_buf_log_overhead(void)
46{
47 return round_up(sizeof(struct xlog_op_header) +
48 sizeof(struct xfs_buf_log_format), 128);
49}
50
51/*
52 * Calculate out transaction log reservation per item in bytes.
53 *
54 * The nbufs argument is used to indicate the number of items that
55 * will be changed in a transaction. size is used to tell how many
56 * bytes should be reserved per item.
57 */
58STATIC uint
59xfs_calc_buf_res(
60 uint nbufs,
61 uint size)
62{
63 return nbufs * (size + xfs_buf_log_overhead());
64}
65
66/*
Darrick J. Wongfa30f032016-08-03 11:37:10 +100067 * Per-extent log reservation for the btree changes involved in freeing or
68 * allocating an extent. In classic XFS there were two trees that will be
69 * modified (bnobt + cntbt). With rmap enabled, there are three trees
Darrick J. Wongf310bd22016-10-03 09:11:19 -070070 * (rmapbt). With reflink, there are four trees (refcountbt). The number of
71 * blocks reserved is based on the formula:
Darrick J. Wongfa30f032016-08-03 11:37:10 +100072 *
73 * num trees * ((2 blocks/level * max depth) - 1)
74 *
75 * Keep in mind that max depth is calculated separately for each type of tree.
76 */
Darrick J. Wong1946b912016-10-03 09:11:18 -070077uint
Darrick J. Wongfa30f032016-08-03 11:37:10 +100078xfs_allocfree_log_count(
79 struct xfs_mount *mp,
80 uint num_ops)
81{
82 uint blocks;
83
84 blocks = num_ops * 2 * (2 * mp->m_ag_maxlevels - 1);
85 if (xfs_sb_version_hasrmapbt(&mp->m_sb))
86 blocks += num_ops * (2 * mp->m_rmap_maxlevels - 1);
Darrick J. Wongf310bd22016-10-03 09:11:19 -070087 if (xfs_sb_version_hasreflink(&mp->m_sb))
88 blocks += num_ops * (2 * mp->m_refc_maxlevels - 1);
Darrick J. Wongfa30f032016-08-03 11:37:10 +100089
90 return blocks;
91}
92
93/*
Dave Chinner23956702013-08-28 16:10:35 +100094 * Logging inodes is really tricksy. They are logged in memory format,
95 * which means that what we write into the log doesn't directly translate into
96 * the amount of space they use on disk.
97 *
98 * Case in point - btree format forks in memory format use more space than the
99 * on-disk format. In memory, the buffer contains a normal btree block header so
100 * the btree code can treat it as though it is just another generic buffer.
101 * However, when we write it to the inode fork, we don't write all of this
102 * header as it isn't needed. e.g. the root is only ever in the inode, so
103 * there's no need for sibling pointers which would waste 16 bytes of space.
104 *
105 * Hence when we have an inode with a maximally sized btree format fork, then
106 * amount of information we actually log is greater than the size of the inode
107 * on disk. Hence we need an inode reservation function that calculates all this
108 * correctly. So, we log:
109 *
Dave Chinnerfe4c2242014-03-07 16:19:14 +1100110 * - 4 log op headers for object
111 * - for the ilf, the inode core and 2 forks
Dave Chinner23956702013-08-28 16:10:35 +1000112 * - inode log format object
Dave Chinnerfe4c2242014-03-07 16:19:14 +1100113 * - the inode core
114 * - two inode forks containing bmap btree root blocks.
115 * - the btree data contained by both forks will fit into the inode size,
116 * hence when combined with the inode core above, we have a total of the
117 * actual inode size.
118 * - the BMBT headers need to be accounted separately, as they are
119 * additional to the records and pointers that fit inside the inode
120 * forks.
Dave Chinner23956702013-08-28 16:10:35 +1000121 */
122STATIC uint
123xfs_calc_inode_res(
124 struct xfs_mount *mp,
125 uint ninodes)
126{
Dave Chinnerfe4c2242014-03-07 16:19:14 +1100127 return ninodes *
128 (4 * sizeof(struct xlog_op_header) +
129 sizeof(struct xfs_inode_log_format) +
130 mp->m_sb.sb_inodesize +
131 2 * XFS_BMBT_BLOCK_LEN(mp));
Dave Chinner23956702013-08-28 16:10:35 +1000132}
133
134/*
Brian Foster9d43b182014-04-24 16:00:52 +1000135 * The free inode btree is a conditional feature and the log reservation
136 * requirements differ slightly from that of the traditional inode allocation
137 * btree. The finobt tracks records for inode chunks with at least one free
138 * inode. A record can be removed from the tree for an inode allocation
139 * or free and thus the finobt reservation is unconditional across:
140 *
141 * - inode allocation
142 * - inode free
143 * - inode chunk allocation
144 *
145 * The 'modify' param indicates to include the record modification scenario. The
146 * 'alloc' param indicates to include the reservation for free space btree
147 * modifications on behalf of finobt modifications. This is required only for
148 * transactions that do not already account for free space btree modifications.
149 *
150 * the free inode btree: max depth * block size
151 * the allocation btrees: 2 trees * (max depth - 1) * block size
152 * the free inode btree entry: block size
153 */
154STATIC uint
155xfs_calc_finobt_res(
Darrick J. Wongfa30f032016-08-03 11:37:10 +1000156 struct xfs_mount *mp,
Brian Foster9d43b182014-04-24 16:00:52 +1000157 int alloc,
158 int modify)
159{
160 uint res;
161
162 if (!xfs_sb_version_hasfinobt(&mp->m_sb))
163 return 0;
164
165 res = xfs_calc_buf_res(mp->m_in_maxlevels, XFS_FSB_TO_B(mp, 1));
166 if (alloc)
Darrick J. Wongfa30f032016-08-03 11:37:10 +1000167 res += xfs_calc_buf_res(xfs_allocfree_log_count(mp, 1),
Brian Foster9d43b182014-04-24 16:00:52 +1000168 XFS_FSB_TO_B(mp, 1));
169 if (modify)
170 res += (uint)XFS_FSB_TO_B(mp, 1);
171
172 return res;
173}
174
175/*
Dave Chinner7fd36c42013-08-12 20:49:32 +1000176 * Various log reservation values.
177 *
178 * These are based on the size of the file system block because that is what
179 * most transactions manipulate. Each adds in an additional 128 bytes per
180 * item logged to try to account for the overhead of the transaction mechanism.
181 *
182 * Note: Most of the reservations underestimate the number of allocation
Darrick J. Wong310a75a2016-08-03 11:18:10 +1000183 * groups into which they could free extents in the xfs_defer_finish() call.
Dave Chinner7fd36c42013-08-12 20:49:32 +1000184 * This is because the number in the worst case is quite high and quite
Darrick J. Wong310a75a2016-08-03 11:18:10 +1000185 * unusual. In order to fix this we need to change xfs_defer_finish() to free
Dave Chinner7fd36c42013-08-12 20:49:32 +1000186 * extents in only a single AG at a time. This will require changes to the
187 * EFI code as well, however, so that the EFI for the extents not freed is
188 * logged again in each transaction. See SGI PV #261917.
189 *
190 * Reservation functions here avoid a huge stack in xfs_trans_init due to
191 * register overflow from temporaries in the calculations.
192 */
193
194
195/*
196 * In a write transaction we can allocate a maximum of 2
197 * extents. This gives:
198 * the inode getting the new extents: inode size
199 * the inode's bmap btree: max depth * block size
200 * the agfs of the ags from which the extents are allocated: 2 * sector
201 * the superblock free block counter: sector size
202 * the allocation btrees: 2 exts * 2 trees * (2 * max depth - 1) * block size
203 * And the bmap_finish transaction can free bmap blocks in a join:
204 * the agfs of the ags containing the blocks: 2 * sector size
205 * the agfls of the ags containing the blocks: 2 * sector size
206 * the super block free block counter: sector size
207 * the allocation btrees: 2 exts * 2 trees * (2 * max depth - 1) * block size
208 */
209STATIC uint
210xfs_calc_write_reservation(
211 struct xfs_mount *mp)
212{
213 return XFS_DQUOT_LOGRES(mp) +
Dave Chinner23956702013-08-28 16:10:35 +1000214 MAX((xfs_calc_inode_res(mp, 1) +
Dave Chinner7fd36c42013-08-12 20:49:32 +1000215 xfs_calc_buf_res(XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK),
216 XFS_FSB_TO_B(mp, 1)) +
217 xfs_calc_buf_res(3, mp->m_sb.sb_sectsize) +
Darrick J. Wongfa30f032016-08-03 11:37:10 +1000218 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 2),
Dave Chinner7fd36c42013-08-12 20:49:32 +1000219 XFS_FSB_TO_B(mp, 1))),
220 (xfs_calc_buf_res(5, mp->m_sb.sb_sectsize) +
Darrick J. Wongfa30f032016-08-03 11:37:10 +1000221 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 2),
Dave Chinner7fd36c42013-08-12 20:49:32 +1000222 XFS_FSB_TO_B(mp, 1))));
223}
224
225/*
226 * In truncating a file we free up to two extents at once. We can modify:
227 * the inode being truncated: inode size
228 * the inode's bmap btree: (max depth + 1) * block size
229 * And the bmap_finish transaction can free the blocks and bmap blocks:
230 * the agf for each of the ags: 4 * sector size
231 * the agfl for each of the ags: 4 * sector size
232 * the super block to reflect the freed blocks: sector size
233 * worst case split in allocation btrees per extent assuming 4 extents:
234 * 4 exts * 2 trees * (2 * max depth - 1) * block size
235 * the inode btree: max depth * blocksize
236 * the allocation btrees: 2 trees * (max depth - 1) * block size
237 */
238STATIC uint
239xfs_calc_itruncate_reservation(
240 struct xfs_mount *mp)
241{
242 return XFS_DQUOT_LOGRES(mp) +
Dave Chinner23956702013-08-28 16:10:35 +1000243 MAX((xfs_calc_inode_res(mp, 1) +
Dave Chinner7fd36c42013-08-12 20:49:32 +1000244 xfs_calc_buf_res(XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) + 1,
245 XFS_FSB_TO_B(mp, 1))),
246 (xfs_calc_buf_res(9, mp->m_sb.sb_sectsize) +
Darrick J. Wongfa30f032016-08-03 11:37:10 +1000247 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 4),
Dave Chinner7fd36c42013-08-12 20:49:32 +1000248 XFS_FSB_TO_B(mp, 1)) +
249 xfs_calc_buf_res(5, 0) +
Darrick J. Wongfa30f032016-08-03 11:37:10 +1000250 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 1),
Dave Chinner7fd36c42013-08-12 20:49:32 +1000251 XFS_FSB_TO_B(mp, 1)) +
Jie Liu126cd102013-12-13 15:51:48 +1100252 xfs_calc_buf_res(2 + mp->m_ialloc_blks +
Dave Chinner7fd36c42013-08-12 20:49:32 +1000253 mp->m_in_maxlevels, 0)));
254}
255
256/*
257 * In renaming a files we can modify:
258 * the four inodes involved: 4 * inode size
259 * the two directory btrees: 2 * (max depth + v2) * dir block size
260 * the two directory bmap btrees: 2 * max depth * block size
261 * And the bmap_finish transaction can free dir and bmap blocks (two sets
262 * of bmap blocks) giving:
263 * the agf for the ags in which the blocks live: 3 * sector size
264 * the agfl for the ags in which the blocks live: 3 * sector size
265 * the superblock for the free block count: sector size
266 * the allocation btrees: 3 exts * 2 trees * (2 * max depth - 1) * block size
267 */
268STATIC uint
269xfs_calc_rename_reservation(
270 struct xfs_mount *mp)
271{
272 return XFS_DQUOT_LOGRES(mp) +
Dave Chinner23956702013-08-28 16:10:35 +1000273 MAX((xfs_calc_inode_res(mp, 4) +
Dave Chinner7fd36c42013-08-12 20:49:32 +1000274 xfs_calc_buf_res(2 * XFS_DIROP_LOG_COUNT(mp),
275 XFS_FSB_TO_B(mp, 1))),
276 (xfs_calc_buf_res(7, mp->m_sb.sb_sectsize) +
Darrick J. Wongfa30f032016-08-03 11:37:10 +1000277 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 3),
Dave Chinner7fd36c42013-08-12 20:49:32 +1000278 XFS_FSB_TO_B(mp, 1))));
279}
280
281/*
Zhi Yong Wuab297432013-12-18 08:22:41 +0800282 * For removing an inode from unlinked list at first, we can modify:
283 * the agi hash list and counters: sector size
284 * the on disk inode before ours in the agi hash list: inode cluster size
Brian Fostere8341d92018-01-08 10:41:36 -0800285 * the on disk inode in the agi hash list: inode cluster size
Zhi Yong Wuab297432013-12-18 08:22:41 +0800286 */
287STATIC uint
288xfs_calc_iunlink_remove_reservation(
289 struct xfs_mount *mp)
290{
291 return xfs_calc_buf_res(1, mp->m_sb.sb_sectsize) +
Brian Fostere8341d92018-01-08 10:41:36 -0800292 2 * max_t(uint, XFS_FSB_TO_B(mp, 1), mp->m_inode_cluster_size);
Zhi Yong Wuab297432013-12-18 08:22:41 +0800293}
294
295/*
Dave Chinner7fd36c42013-08-12 20:49:32 +1000296 * For creating a link to an inode:
297 * the parent directory inode: inode size
298 * the linked inode: inode size
299 * the directory btree could split: (max depth + v2) * dir block size
300 * the directory bmap btree could join or split: (max depth + v2) * blocksize
301 * And the bmap_finish transaction can free some bmap blocks giving:
302 * the agf for the ag in which the blocks live: sector size
303 * the agfl for the ag in which the blocks live: sector size
304 * the superblock for the free block count: sector size
305 * the allocation btrees: 2 trees * (2 * max depth - 1) * block size
306 */
307STATIC uint
308xfs_calc_link_reservation(
309 struct xfs_mount *mp)
310{
311 return XFS_DQUOT_LOGRES(mp) +
Zhi Yong Wuab297432013-12-18 08:22:41 +0800312 xfs_calc_iunlink_remove_reservation(mp) +
Dave Chinner23956702013-08-28 16:10:35 +1000313 MAX((xfs_calc_inode_res(mp, 2) +
Dave Chinner7fd36c42013-08-12 20:49:32 +1000314 xfs_calc_buf_res(XFS_DIROP_LOG_COUNT(mp),
315 XFS_FSB_TO_B(mp, 1))),
316 (xfs_calc_buf_res(3, mp->m_sb.sb_sectsize) +
Darrick J. Wongfa30f032016-08-03 11:37:10 +1000317 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 1),
Dave Chinner7fd36c42013-08-12 20:49:32 +1000318 XFS_FSB_TO_B(mp, 1))));
319}
320
321/*
Zhi Yong Wu99b64362013-12-18 08:22:40 +0800322 * For adding an inode to unlinked list we can modify:
323 * the agi hash list: sector size
Brian Fostere8341d92018-01-08 10:41:36 -0800324 * the on disk inode: inode cluster size
Zhi Yong Wu99b64362013-12-18 08:22:40 +0800325 */
326STATIC uint
327xfs_calc_iunlink_add_reservation(xfs_mount_t *mp)
328{
329 return xfs_calc_buf_res(1, mp->m_sb.sb_sectsize) +
Brian Fostere8341d92018-01-08 10:41:36 -0800330 max_t(uint, XFS_FSB_TO_B(mp, 1), mp->m_inode_cluster_size);
Zhi Yong Wu99b64362013-12-18 08:22:40 +0800331}
332
333/*
Dave Chinner7fd36c42013-08-12 20:49:32 +1000334 * For removing a directory entry we can modify:
335 * the parent directory inode: inode size
336 * the removed inode: inode size
337 * the directory btree could join: (max depth + v2) * dir block size
338 * the directory bmap btree could join or split: (max depth + v2) * blocksize
339 * And the bmap_finish transaction can free the dir and bmap blocks giving:
340 * the agf for the ag in which the blocks live: 2 * sector size
341 * the agfl for the ag in which the blocks live: 2 * sector size
342 * the superblock for the free block count: sector size
343 * the allocation btrees: 2 exts * 2 trees * (2 * max depth - 1) * block size
344 */
345STATIC uint
346xfs_calc_remove_reservation(
347 struct xfs_mount *mp)
348{
349 return XFS_DQUOT_LOGRES(mp) +
Zhi Yong Wu99b64362013-12-18 08:22:40 +0800350 xfs_calc_iunlink_add_reservation(mp) +
351 MAX((xfs_calc_inode_res(mp, 1) +
Dave Chinner7fd36c42013-08-12 20:49:32 +1000352 xfs_calc_buf_res(XFS_DIROP_LOG_COUNT(mp),
353 XFS_FSB_TO_B(mp, 1))),
Zhi Yong Wu99b64362013-12-18 08:22:40 +0800354 (xfs_calc_buf_res(4, mp->m_sb.sb_sectsize) +
Darrick J. Wongfa30f032016-08-03 11:37:10 +1000355 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 2),
Dave Chinner7fd36c42013-08-12 20:49:32 +1000356 XFS_FSB_TO_B(mp, 1))));
357}
358
359/*
360 * For create, break it in to the two cases that the transaction
361 * covers. We start with the modify case - allocation done by modification
362 * of the state of existing inodes - and the allocation case.
363 */
364
365/*
366 * For create we can modify:
367 * the parent directory inode: inode size
368 * the new inode: inode size
369 * the inode btree entry: block size
370 * the superblock for the nlink flag: sector size
371 * the directory btree: (max depth + v2) * dir block size
372 * the directory inode's bmap btree: (max depth + v2) * block size
Brian Foster9d43b182014-04-24 16:00:52 +1000373 * the finobt (record modification and allocation btrees)
Dave Chinner7fd36c42013-08-12 20:49:32 +1000374 */
375STATIC uint
376xfs_calc_create_resv_modify(
377 struct xfs_mount *mp)
378{
Dave Chinner23956702013-08-28 16:10:35 +1000379 return xfs_calc_inode_res(mp, 2) +
Dave Chinner7fd36c42013-08-12 20:49:32 +1000380 xfs_calc_buf_res(1, mp->m_sb.sb_sectsize) +
381 (uint)XFS_FSB_TO_B(mp, 1) +
Brian Foster9d43b182014-04-24 16:00:52 +1000382 xfs_calc_buf_res(XFS_DIROP_LOG_COUNT(mp), XFS_FSB_TO_B(mp, 1)) +
383 xfs_calc_finobt_res(mp, 1, 1);
Dave Chinner7fd36c42013-08-12 20:49:32 +1000384}
385
386/*
387 * For create we can allocate some inodes giving:
388 * the agi and agf of the ag getting the new inodes: 2 * sectorsize
389 * the superblock for the nlink flag: sector size
Jie Liu126cd102013-12-13 15:51:48 +1100390 * the inode blocks allocated: mp->m_ialloc_blks * blocksize
Dave Chinner7fd36c42013-08-12 20:49:32 +1000391 * the inode btree: max depth * blocksize
392 * the allocation btrees: 2 trees * (max depth - 1) * block size
393 */
394STATIC uint
395xfs_calc_create_resv_alloc(
396 struct xfs_mount *mp)
397{
398 return xfs_calc_buf_res(2, mp->m_sb.sb_sectsize) +
399 mp->m_sb.sb_sectsize +
Jie Liu126cd102013-12-13 15:51:48 +1100400 xfs_calc_buf_res(mp->m_ialloc_blks, XFS_FSB_TO_B(mp, 1)) +
Dave Chinner7fd36c42013-08-12 20:49:32 +1000401 xfs_calc_buf_res(mp->m_in_maxlevels, XFS_FSB_TO_B(mp, 1)) +
Darrick J. Wongfa30f032016-08-03 11:37:10 +1000402 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 1),
Dave Chinner7fd36c42013-08-12 20:49:32 +1000403 XFS_FSB_TO_B(mp, 1));
404}
405
406STATIC uint
407__xfs_calc_create_reservation(
408 struct xfs_mount *mp)
409{
410 return XFS_DQUOT_LOGRES(mp) +
411 MAX(xfs_calc_create_resv_alloc(mp),
412 xfs_calc_create_resv_modify(mp));
413}
414
415/*
416 * For icreate we can allocate some inodes giving:
417 * the agi and agf of the ag getting the new inodes: 2 * sectorsize
418 * the superblock for the nlink flag: sector size
419 * the inode btree: max depth * blocksize
420 * the allocation btrees: 2 trees * (max depth - 1) * block size
Brian Foster9d43b182014-04-24 16:00:52 +1000421 * the finobt (record insertion)
Dave Chinner7fd36c42013-08-12 20:49:32 +1000422 */
423STATIC uint
424xfs_calc_icreate_resv_alloc(
425 struct xfs_mount *mp)
426{
427 return xfs_calc_buf_res(2, mp->m_sb.sb_sectsize) +
428 mp->m_sb.sb_sectsize +
429 xfs_calc_buf_res(mp->m_in_maxlevels, XFS_FSB_TO_B(mp, 1)) +
Darrick J. Wongfa30f032016-08-03 11:37:10 +1000430 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 1),
Brian Foster9d43b182014-04-24 16:00:52 +1000431 XFS_FSB_TO_B(mp, 1)) +
432 xfs_calc_finobt_res(mp, 0, 0);
Dave Chinner7fd36c42013-08-12 20:49:32 +1000433}
434
435STATIC uint
436xfs_calc_icreate_reservation(xfs_mount_t *mp)
437{
438 return XFS_DQUOT_LOGRES(mp) +
439 MAX(xfs_calc_icreate_resv_alloc(mp),
440 xfs_calc_create_resv_modify(mp));
441}
442
443STATIC uint
444xfs_calc_create_reservation(
445 struct xfs_mount *mp)
446{
447 if (xfs_sb_version_hascrc(&mp->m_sb))
448 return xfs_calc_icreate_reservation(mp);
449 return __xfs_calc_create_reservation(mp);
450
451}
452
Zhi Yong Wu99b64362013-12-18 08:22:40 +0800453STATIC uint
454xfs_calc_create_tmpfile_reservation(
455 struct xfs_mount *mp)
456{
457 uint res = XFS_DQUOT_LOGRES(mp);
458
459 if (xfs_sb_version_hascrc(&mp->m_sb))
460 res += xfs_calc_icreate_resv_alloc(mp);
461 else
462 res += xfs_calc_create_resv_alloc(mp);
463
464 return res + xfs_calc_iunlink_add_reservation(mp);
465}
466
Dave Chinner7fd36c42013-08-12 20:49:32 +1000467/*
468 * Making a new directory is the same as creating a new file.
469 */
470STATIC uint
471xfs_calc_mkdir_reservation(
472 struct xfs_mount *mp)
473{
474 return xfs_calc_create_reservation(mp);
475}
476
477
478/*
479 * Making a new symplink is the same as creating a new file, but
480 * with the added blocks for remote symlink data which can be up to 1kB in
Darrick J. Wong6eb0b8d2017-07-07 08:37:26 -0700481 * length (XFS_SYMLINK_MAXLEN).
Dave Chinner7fd36c42013-08-12 20:49:32 +1000482 */
483STATIC uint
484xfs_calc_symlink_reservation(
485 struct xfs_mount *mp)
486{
487 return xfs_calc_create_reservation(mp) +
Darrick J. Wong6eb0b8d2017-07-07 08:37:26 -0700488 xfs_calc_buf_res(1, XFS_SYMLINK_MAXLEN);
Dave Chinner7fd36c42013-08-12 20:49:32 +1000489}
490
491/*
492 * In freeing an inode we can modify:
493 * the inode being freed: inode size
Brian Fostera6f48592018-01-08 10:41:36 -0800494 * the super block free inode counter, AGF and AGFL: sector size
495 * the on disk inode (agi unlinked list removal)
496 * the inode chunk is marked stale (headers only)
Dave Chinner7fd36c42013-08-12 20:49:32 +1000497 * the inode btree: max depth * blocksize
498 * the allocation btrees: 2 trees * (max depth - 1) * block size
Brian Foster9d43b182014-04-24 16:00:52 +1000499 * the finobt (record insertion, removal or modification)
Dave Chinner7fd36c42013-08-12 20:49:32 +1000500 */
501STATIC uint
502xfs_calc_ifree_reservation(
503 struct xfs_mount *mp)
504{
505 return XFS_DQUOT_LOGRES(mp) +
Dave Chinner23956702013-08-28 16:10:35 +1000506 xfs_calc_inode_res(mp, 1) +
Brian Fostera6f48592018-01-08 10:41:36 -0800507 xfs_calc_buf_res(3, mp->m_sb.sb_sectsize) +
Zhi Yong Wuab297432013-12-18 08:22:41 +0800508 xfs_calc_iunlink_remove_reservation(mp) +
Brian Fostera6f48592018-01-08 10:41:36 -0800509 xfs_calc_buf_res(mp->m_ialloc_blks, 0) +
510 xfs_calc_buf_res(mp->m_in_maxlevels, XFS_FSB_TO_B(mp, 1)) +
Darrick J. Wongfa30f032016-08-03 11:37:10 +1000511 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 1),
Brian Foster9d43b182014-04-24 16:00:52 +1000512 XFS_FSB_TO_B(mp, 1)) +
513 xfs_calc_finobt_res(mp, 0, 1);
Dave Chinner7fd36c42013-08-12 20:49:32 +1000514}
515
516/*
517 * When only changing the inode we log the inode and possibly the superblock
518 * We also add a bit of slop for the transaction stuff.
519 */
520STATIC uint
521xfs_calc_ichange_reservation(
522 struct xfs_mount *mp)
523{
524 return XFS_DQUOT_LOGRES(mp) +
Dave Chinner23956702013-08-28 16:10:35 +1000525 xfs_calc_inode_res(mp, 1) +
526 xfs_calc_buf_res(1, mp->m_sb.sb_sectsize);
Dave Chinner7fd36c42013-08-12 20:49:32 +1000527
528}
529
530/*
531 * Growing the data section of the filesystem.
532 * superblock
533 * agi and agf
534 * allocation btrees
535 */
536STATIC uint
537xfs_calc_growdata_reservation(
538 struct xfs_mount *mp)
539{
540 return xfs_calc_buf_res(3, mp->m_sb.sb_sectsize) +
Darrick J. Wongfa30f032016-08-03 11:37:10 +1000541 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 1),
Dave Chinner7fd36c42013-08-12 20:49:32 +1000542 XFS_FSB_TO_B(mp, 1));
543}
544
545/*
546 * Growing the rt section of the filesystem.
547 * In the first set of transactions (ALLOC) we allocate space to the
548 * bitmap or summary files.
549 * superblock: sector size
550 * agf of the ag from which the extent is allocated: sector size
551 * bmap btree for bitmap/summary inode: max depth * blocksize
552 * bitmap/summary inode: inode size
553 * allocation btrees for 1 block alloc: 2 * (2 * maxdepth - 1) * blocksize
554 */
555STATIC uint
556xfs_calc_growrtalloc_reservation(
557 struct xfs_mount *mp)
558{
559 return xfs_calc_buf_res(2, mp->m_sb.sb_sectsize) +
560 xfs_calc_buf_res(XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK),
561 XFS_FSB_TO_B(mp, 1)) +
Dave Chinner23956702013-08-28 16:10:35 +1000562 xfs_calc_inode_res(mp, 1) +
Darrick J. Wongfa30f032016-08-03 11:37:10 +1000563 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 1),
Dave Chinner7fd36c42013-08-12 20:49:32 +1000564 XFS_FSB_TO_B(mp, 1));
565}
566
567/*
568 * Growing the rt section of the filesystem.
569 * In the second set of transactions (ZERO) we zero the new metadata blocks.
570 * one bitmap/summary block: blocksize
571 */
572STATIC uint
573xfs_calc_growrtzero_reservation(
574 struct xfs_mount *mp)
575{
576 return xfs_calc_buf_res(1, mp->m_sb.sb_blocksize);
577}
578
579/*
580 * Growing the rt section of the filesystem.
581 * In the third set of transactions (FREE) we update metadata without
582 * allocating any new blocks.
583 * superblock: sector size
584 * bitmap inode: inode size
585 * summary inode: inode size
586 * one bitmap block: blocksize
587 * summary blocks: new summary size
588 */
589STATIC uint
590xfs_calc_growrtfree_reservation(
591 struct xfs_mount *mp)
592{
593 return xfs_calc_buf_res(1, mp->m_sb.sb_sectsize) +
Dave Chinner23956702013-08-28 16:10:35 +1000594 xfs_calc_inode_res(mp, 2) +
Dave Chinner7fd36c42013-08-12 20:49:32 +1000595 xfs_calc_buf_res(1, mp->m_sb.sb_blocksize) +
596 xfs_calc_buf_res(1, mp->m_rsumsize);
597}
598
599/*
600 * Logging the inode modification timestamp on a synchronous write.
601 * inode
602 */
603STATIC uint
604xfs_calc_swrite_reservation(
605 struct xfs_mount *mp)
606{
Dave Chinner23956702013-08-28 16:10:35 +1000607 return xfs_calc_inode_res(mp, 1);
Dave Chinner7fd36c42013-08-12 20:49:32 +1000608}
609
610/*
611 * Logging the inode mode bits when writing a setuid/setgid file
612 * inode
613 */
614STATIC uint
Dave Chinner23956702013-08-28 16:10:35 +1000615xfs_calc_writeid_reservation(
616 struct xfs_mount *mp)
Dave Chinner7fd36c42013-08-12 20:49:32 +1000617{
Dave Chinner23956702013-08-28 16:10:35 +1000618 return xfs_calc_inode_res(mp, 1);
Dave Chinner7fd36c42013-08-12 20:49:32 +1000619}
620
621/*
622 * Converting the inode from non-attributed to attributed.
623 * the inode being converted: inode size
624 * agf block and superblock (for block allocation)
625 * the new block (directory sized)
626 * bmap blocks for the new directory block
627 * allocation btrees
628 */
629STATIC uint
630xfs_calc_addafork_reservation(
631 struct xfs_mount *mp)
632{
633 return XFS_DQUOT_LOGRES(mp) +
Dave Chinner23956702013-08-28 16:10:35 +1000634 xfs_calc_inode_res(mp, 1) +
Dave Chinner7fd36c42013-08-12 20:49:32 +1000635 xfs_calc_buf_res(2, mp->m_sb.sb_sectsize) +
Dave Chinner8f661932014-06-06 15:15:59 +1000636 xfs_calc_buf_res(1, mp->m_dir_geo->blksize) +
Dave Chinner7fd36c42013-08-12 20:49:32 +1000637 xfs_calc_buf_res(XFS_DAENTER_BMAP1B(mp, XFS_DATA_FORK) + 1,
638 XFS_FSB_TO_B(mp, 1)) +
Darrick J. Wongfa30f032016-08-03 11:37:10 +1000639 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 1),
Dave Chinner7fd36c42013-08-12 20:49:32 +1000640 XFS_FSB_TO_B(mp, 1));
641}
642
643/*
644 * Removing the attribute fork of a file
645 * the inode being truncated: inode size
646 * the inode's bmap btree: max depth * block size
647 * And the bmap_finish transaction can free the blocks and bmap blocks:
648 * the agf for each of the ags: 4 * sector size
649 * the agfl for each of the ags: 4 * sector size
650 * the super block to reflect the freed blocks: sector size
651 * worst case split in allocation btrees per extent assuming 4 extents:
652 * 4 exts * 2 trees * (2 * max depth - 1) * block size
653 */
654STATIC uint
655xfs_calc_attrinval_reservation(
656 struct xfs_mount *mp)
657{
Dave Chinner23956702013-08-28 16:10:35 +1000658 return MAX((xfs_calc_inode_res(mp, 1) +
Dave Chinner7fd36c42013-08-12 20:49:32 +1000659 xfs_calc_buf_res(XFS_BM_MAXLEVELS(mp, XFS_ATTR_FORK),
660 XFS_FSB_TO_B(mp, 1))),
661 (xfs_calc_buf_res(9, mp->m_sb.sb_sectsize) +
Darrick J. Wongfa30f032016-08-03 11:37:10 +1000662 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 4),
Dave Chinner7fd36c42013-08-12 20:49:32 +1000663 XFS_FSB_TO_B(mp, 1))));
664}
665
666/*
667 * Setting an attribute at mount time.
668 * the inode getting the attribute
669 * the superblock for allocations
670 * the agfs extents are allocated from
671 * the attribute btree * max depth
672 * the inode allocation btree
673 * Since attribute transaction space is dependent on the size of the attribute,
674 * the calculation is done partially at mount time and partially at runtime(see
675 * below).
676 */
677STATIC uint
678xfs_calc_attrsetm_reservation(
679 struct xfs_mount *mp)
680{
681 return XFS_DQUOT_LOGRES(mp) +
Dave Chinner23956702013-08-28 16:10:35 +1000682 xfs_calc_inode_res(mp, 1) +
Dave Chinner7fd36c42013-08-12 20:49:32 +1000683 xfs_calc_buf_res(1, mp->m_sb.sb_sectsize) +
684 xfs_calc_buf_res(XFS_DA_NODE_MAXDEPTH, XFS_FSB_TO_B(mp, 1));
685}
686
687/*
688 * Setting an attribute at runtime, transaction space unit per block.
689 * the superblock for allocations: sector size
690 * the inode bmap btree could join or split: max depth * block size
691 * Since the runtime attribute transaction space is dependent on the total
692 * blocks needed for the 1st bmap, here we calculate out the space unit for
693 * one block so that the caller could figure out the total space according
Jie Liu3d3c8b52013-08-12 20:49:59 +1000694 * to the attibute extent length in blocks by:
695 * ext * M_RES(mp)->tr_attrsetrt.tr_logres
Dave Chinner7fd36c42013-08-12 20:49:32 +1000696 */
697STATIC uint
698xfs_calc_attrsetrt_reservation(
699 struct xfs_mount *mp)
700{
701 return xfs_calc_buf_res(1, mp->m_sb.sb_sectsize) +
702 xfs_calc_buf_res(XFS_BM_MAXLEVELS(mp, XFS_ATTR_FORK),
703 XFS_FSB_TO_B(mp, 1));
704}
705
706/*
707 * Removing an attribute.
708 * the inode: inode size
709 * the attribute btree could join: max depth * block size
710 * the inode bmap btree could join or split: max depth * block size
711 * And the bmap_finish transaction can free the attr blocks freed giving:
712 * the agf for the ag in which the blocks live: 2 * sector size
713 * the agfl for the ag in which the blocks live: 2 * sector size
714 * the superblock for the free block count: sector size
715 * the allocation btrees: 2 exts * 2 trees * (2 * max depth - 1) * block size
716 */
717STATIC uint
718xfs_calc_attrrm_reservation(
719 struct xfs_mount *mp)
720{
721 return XFS_DQUOT_LOGRES(mp) +
Dave Chinner23956702013-08-28 16:10:35 +1000722 MAX((xfs_calc_inode_res(mp, 1) +
Dave Chinner7fd36c42013-08-12 20:49:32 +1000723 xfs_calc_buf_res(XFS_DA_NODE_MAXDEPTH,
724 XFS_FSB_TO_B(mp, 1)) +
725 (uint)XFS_FSB_TO_B(mp,
726 XFS_BM_MAXLEVELS(mp, XFS_ATTR_FORK)) +
727 xfs_calc_buf_res(XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK), 0)),
728 (xfs_calc_buf_res(5, mp->m_sb.sb_sectsize) +
Darrick J. Wongfa30f032016-08-03 11:37:10 +1000729 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 2),
Dave Chinner7fd36c42013-08-12 20:49:32 +1000730 XFS_FSB_TO_B(mp, 1))));
731}
732
733/*
734 * Clearing a bad agino number in an agi hash bucket.
735 */
736STATIC uint
737xfs_calc_clear_agi_bucket_reservation(
738 struct xfs_mount *mp)
739{
740 return xfs_calc_buf_res(1, mp->m_sb.sb_sectsize);
741}
742
743/*
Dave Chinner7fd36c42013-08-12 20:49:32 +1000744 * Adjusting quota limits.
745 * the xfs_disk_dquot_t: sizeof(struct xfs_disk_dquot)
746 */
747STATIC uint
748xfs_calc_qm_setqlim_reservation(
749 struct xfs_mount *mp)
750{
751 return xfs_calc_buf_res(1, sizeof(struct xfs_disk_dquot));
752}
753
754/*
755 * Allocating quota on disk if needed.
Brian Foster410b11a2014-02-07 14:55:54 +1100756 * the write transaction log space for quota file extent allocation
Dave Chinner7fd36c42013-08-12 20:49:32 +1000757 * the unit of quota allocation: one system block size
758 */
759STATIC uint
760xfs_calc_qm_dqalloc_reservation(
761 struct xfs_mount *mp)
762{
Brian Foster410b11a2014-02-07 14:55:54 +1100763 return xfs_calc_write_reservation(mp) +
Dave Chinner7fd36c42013-08-12 20:49:32 +1000764 xfs_calc_buf_res(1,
765 XFS_FSB_TO_B(mp, XFS_DQUOT_CLUSTER_SIZE_FSB) - 1);
766}
767
768/*
769 * Turning off quotas.
770 * the xfs_qoff_logitem_t: sizeof(struct xfs_qoff_logitem) * 2
771 * the superblock for the quota flags: sector size
772 */
773STATIC uint
774xfs_calc_qm_quotaoff_reservation(
775 struct xfs_mount *mp)
776{
777 return sizeof(struct xfs_qoff_logitem) * 2 +
778 xfs_calc_buf_res(1, mp->m_sb.sb_sectsize);
779}
780
781/*
782 * End of turning off quotas.
783 * the xfs_qoff_logitem_t: sizeof(struct xfs_qoff_logitem) * 2
784 */
785STATIC uint
786xfs_calc_qm_quotaoff_end_reservation(
787 struct xfs_mount *mp)
788{
789 return sizeof(struct xfs_qoff_logitem) * 2;
790}
791
792/*
793 * Syncing the incore super block changes to disk.
794 * the super block to reflect the changes: sector size
795 */
796STATIC uint
797xfs_calc_sb_reservation(
798 struct xfs_mount *mp)
799{
800 return xfs_calc_buf_res(1, mp->m_sb.sb_sectsize);
801}
802
803void
804xfs_trans_resv_calc(
805 struct xfs_mount *mp,
806 struct xfs_trans_resv *resp)
807{
Jie Liu0eadd102013-08-12 20:49:56 +1000808 /*
809 * The following transactions are logged in physical format and
810 * require a permanent reservation on space.
811 */
812 resp->tr_write.tr_logres = xfs_calc_write_reservation(mp);
Darrick J. Wong80de4622016-10-03 09:11:47 -0700813 if (xfs_sb_version_hasreflink(&mp->m_sb))
814 resp->tr_write.tr_logcount = XFS_WRITE_LOG_COUNT_REFLINK;
815 else
816 resp->tr_write.tr_logcount = XFS_WRITE_LOG_COUNT;
Jie Liu0eadd102013-08-12 20:49:56 +1000817 resp->tr_write.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
818
819 resp->tr_itruncate.tr_logres = xfs_calc_itruncate_reservation(mp);
Darrick J. Wong80de4622016-10-03 09:11:47 -0700820 if (xfs_sb_version_hasreflink(&mp->m_sb))
821 resp->tr_itruncate.tr_logcount =
822 XFS_ITRUNCATE_LOG_COUNT_REFLINK;
823 else
824 resp->tr_itruncate.tr_logcount = XFS_ITRUNCATE_LOG_COUNT;
Jie Liu0eadd102013-08-12 20:49:56 +1000825 resp->tr_itruncate.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
826
827 resp->tr_rename.tr_logres = xfs_calc_rename_reservation(mp);
828 resp->tr_rename.tr_logcount = XFS_RENAME_LOG_COUNT;
829 resp->tr_rename.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
830
831 resp->tr_link.tr_logres = xfs_calc_link_reservation(mp);
832 resp->tr_link.tr_logcount = XFS_LINK_LOG_COUNT;
833 resp->tr_link.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
834
835 resp->tr_remove.tr_logres = xfs_calc_remove_reservation(mp);
836 resp->tr_remove.tr_logcount = XFS_REMOVE_LOG_COUNT;
837 resp->tr_remove.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
838
839 resp->tr_symlink.tr_logres = xfs_calc_symlink_reservation(mp);
840 resp->tr_symlink.tr_logcount = XFS_SYMLINK_LOG_COUNT;
841 resp->tr_symlink.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
842
843 resp->tr_create.tr_logres = xfs_calc_create_reservation(mp);
844 resp->tr_create.tr_logcount = XFS_CREATE_LOG_COUNT;
845 resp->tr_create.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
846
Zhi Yong Wu99b64362013-12-18 08:22:40 +0800847 resp->tr_create_tmpfile.tr_logres =
848 xfs_calc_create_tmpfile_reservation(mp);
849 resp->tr_create_tmpfile.tr_logcount = XFS_CREATE_TMPFILE_LOG_COUNT;
850 resp->tr_create_tmpfile.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
851
Jie Liu0eadd102013-08-12 20:49:56 +1000852 resp->tr_mkdir.tr_logres = xfs_calc_mkdir_reservation(mp);
853 resp->tr_mkdir.tr_logcount = XFS_MKDIR_LOG_COUNT;
854 resp->tr_mkdir.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
855
856 resp->tr_ifree.tr_logres = xfs_calc_ifree_reservation(mp);
857 resp->tr_ifree.tr_logcount = XFS_INACTIVE_LOG_COUNT;
858 resp->tr_ifree.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
859
860 resp->tr_addafork.tr_logres = xfs_calc_addafork_reservation(mp);
861 resp->tr_addafork.tr_logcount = XFS_ADDAFORK_LOG_COUNT;
862 resp->tr_addafork.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
863
864 resp->tr_attrinval.tr_logres = xfs_calc_attrinval_reservation(mp);
865 resp->tr_attrinval.tr_logcount = XFS_ATTRINVAL_LOG_COUNT;
866 resp->tr_attrinval.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
867
868 resp->tr_attrsetm.tr_logres = xfs_calc_attrsetm_reservation(mp);
869 resp->tr_attrsetm.tr_logcount = XFS_ATTRSET_LOG_COUNT;
870 resp->tr_attrsetm.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
871
872 resp->tr_attrrm.tr_logres = xfs_calc_attrrm_reservation(mp);
873 resp->tr_attrrm.tr_logcount = XFS_ATTRRM_LOG_COUNT;
874 resp->tr_attrrm.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
875
876 resp->tr_growrtalloc.tr_logres = xfs_calc_growrtalloc_reservation(mp);
877 resp->tr_growrtalloc.tr_logcount = XFS_DEFAULT_PERM_LOG_COUNT;
878 resp->tr_growrtalloc.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
879
880 resp->tr_qm_dqalloc.tr_logres = xfs_calc_qm_dqalloc_reservation(mp);
Darrick J. Wong80de4622016-10-03 09:11:47 -0700881 if (xfs_sb_version_hasreflink(&mp->m_sb))
882 resp->tr_qm_dqalloc.tr_logcount = XFS_WRITE_LOG_COUNT_REFLINK;
883 else
884 resp->tr_qm_dqalloc.tr_logcount = XFS_WRITE_LOG_COUNT;
Jie Liu0eadd102013-08-12 20:49:56 +1000885 resp->tr_qm_dqalloc.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
886
887 /*
888 * The following transactions are logged in logical format with
889 * a default log count.
890 */
Jie Liu0eadd102013-08-12 20:49:56 +1000891 resp->tr_qm_setqlim.tr_logres = xfs_calc_qm_setqlim_reservation(mp);
892 resp->tr_qm_setqlim.tr_logcount = XFS_DEFAULT_LOG_COUNT;
893
894 resp->tr_qm_quotaoff.tr_logres = xfs_calc_qm_quotaoff_reservation(mp);
895 resp->tr_qm_quotaoff.tr_logcount = XFS_DEFAULT_LOG_COUNT;
896
897 resp->tr_qm_equotaoff.tr_logres =
898 xfs_calc_qm_quotaoff_end_reservation(mp);
899 resp->tr_qm_equotaoff.tr_logcount = XFS_DEFAULT_LOG_COUNT;
900
901 resp->tr_sb.tr_logres = xfs_calc_sb_reservation(mp);
902 resp->tr_sb.tr_logcount = XFS_DEFAULT_LOG_COUNT;
903
904 /* The following transaction are logged in logical format */
905 resp->tr_ichange.tr_logres = xfs_calc_ichange_reservation(mp);
906 resp->tr_growdata.tr_logres = xfs_calc_growdata_reservation(mp);
Jie Liu20996c92013-08-12 20:49:57 +1000907 resp->tr_fsyncts.tr_logres = xfs_calc_swrite_reservation(mp);
Jie Liu0eadd102013-08-12 20:49:56 +1000908 resp->tr_writeid.tr_logres = xfs_calc_writeid_reservation(mp);
909 resp->tr_attrsetrt.tr_logres = xfs_calc_attrsetrt_reservation(mp);
910 resp->tr_clearagi.tr_logres = xfs_calc_clear_agi_bucket_reservation(mp);
911 resp->tr_growrtzero.tr_logres = xfs_calc_growrtzero_reservation(mp);
912 resp->tr_growrtfree.tr_logres = xfs_calc_growrtfree_reservation(mp);
Dave Chinner7fd36c42013-08-12 20:49:32 +1000913}