blob: 3bccdf73e1410e821d84521897cf41a72258e5ce [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
Brian Foster57af33e2018-01-08 10:41:38 -080037#define _ALLOC true
38#define _FREE false
39
Dave Chinner7fd36c42013-08-12 20:49:32 +100040/*
41 * A buffer has a format structure overhead in the log in addition
42 * to the data, so we need to take this into account when reserving
43 * space in a transaction for a buffer. Round the space required up
44 * to a multiple of 128 bytes so that we don't change the historical
45 * reservation that has been used for this overhead.
46 */
47STATIC uint
48xfs_buf_log_overhead(void)
49{
50 return round_up(sizeof(struct xlog_op_header) +
51 sizeof(struct xfs_buf_log_format), 128);
52}
53
54/*
55 * Calculate out transaction log reservation per item in bytes.
56 *
57 * The nbufs argument is used to indicate the number of items that
58 * will be changed in a transaction. size is used to tell how many
59 * bytes should be reserved per item.
60 */
61STATIC uint
62xfs_calc_buf_res(
63 uint nbufs,
64 uint size)
65{
66 return nbufs * (size + xfs_buf_log_overhead());
67}
68
69/*
Darrick J. Wongfa30f032016-08-03 11:37:10 +100070 * Per-extent log reservation for the btree changes involved in freeing or
71 * allocating an extent. In classic XFS there were two trees that will be
72 * modified (bnobt + cntbt). With rmap enabled, there are three trees
Darrick J. Wongf310bd22016-10-03 09:11:19 -070073 * (rmapbt). With reflink, there are four trees (refcountbt). The number of
74 * blocks reserved is based on the formula:
Darrick J. Wongfa30f032016-08-03 11:37:10 +100075 *
76 * num trees * ((2 blocks/level * max depth) - 1)
77 *
78 * Keep in mind that max depth is calculated separately for each type of tree.
79 */
Darrick J. Wong1946b912016-10-03 09:11:18 -070080uint
Darrick J. Wongfa30f032016-08-03 11:37:10 +100081xfs_allocfree_log_count(
82 struct xfs_mount *mp,
83 uint num_ops)
84{
85 uint blocks;
86
87 blocks = num_ops * 2 * (2 * mp->m_ag_maxlevels - 1);
88 if (xfs_sb_version_hasrmapbt(&mp->m_sb))
89 blocks += num_ops * (2 * mp->m_rmap_maxlevels - 1);
Darrick J. Wongf310bd22016-10-03 09:11:19 -070090 if (xfs_sb_version_hasreflink(&mp->m_sb))
91 blocks += num_ops * (2 * mp->m_refc_maxlevels - 1);
Darrick J. Wongfa30f032016-08-03 11:37:10 +100092
93 return blocks;
94}
95
96/*
Dave Chinner23956702013-08-28 16:10:35 +100097 * Logging inodes is really tricksy. They are logged in memory format,
98 * which means that what we write into the log doesn't directly translate into
99 * the amount of space they use on disk.
100 *
101 * Case in point - btree format forks in memory format use more space than the
102 * on-disk format. In memory, the buffer contains a normal btree block header so
103 * the btree code can treat it as though it is just another generic buffer.
104 * However, when we write it to the inode fork, we don't write all of this
105 * header as it isn't needed. e.g. the root is only ever in the inode, so
106 * there's no need for sibling pointers which would waste 16 bytes of space.
107 *
108 * Hence when we have an inode with a maximally sized btree format fork, then
109 * amount of information we actually log is greater than the size of the inode
110 * on disk. Hence we need an inode reservation function that calculates all this
111 * correctly. So, we log:
112 *
Dave Chinnerfe4c2242014-03-07 16:19:14 +1100113 * - 4 log op headers for object
114 * - for the ilf, the inode core and 2 forks
Dave Chinner23956702013-08-28 16:10:35 +1000115 * - inode log format object
Dave Chinnerfe4c2242014-03-07 16:19:14 +1100116 * - the inode core
117 * - two inode forks containing bmap btree root blocks.
118 * - the btree data contained by both forks will fit into the inode size,
119 * hence when combined with the inode core above, we have a total of the
120 * actual inode size.
121 * - the BMBT headers need to be accounted separately, as they are
122 * additional to the records and pointers that fit inside the inode
123 * forks.
Dave Chinner23956702013-08-28 16:10:35 +1000124 */
125STATIC uint
126xfs_calc_inode_res(
127 struct xfs_mount *mp,
128 uint ninodes)
129{
Dave Chinnerfe4c2242014-03-07 16:19:14 +1100130 return ninodes *
131 (4 * sizeof(struct xlog_op_header) +
132 sizeof(struct xfs_inode_log_format) +
133 mp->m_sb.sb_inodesize +
134 2 * XFS_BMBT_BLOCK_LEN(mp));
Dave Chinner23956702013-08-28 16:10:35 +1000135}
136
137/*
Brian Fosterf03c78f2018-01-08 10:41:37 -0800138 * Inode btree record insertion/removal modifies the inode btree and free space
139 * btrees (since the inobt does not use the agfl). This requires the following
140 * reservation:
Brian Foster9d43b182014-04-24 16:00:52 +1000141 *
Brian Fosterf03c78f2018-01-08 10:41:37 -0800142 * the inode btree: max depth * blocksize
Brian Foster9d43b182014-04-24 16:00:52 +1000143 * the allocation btrees: 2 trees * (max depth - 1) * block size
Brian Fosterf03c78f2018-01-08 10:41:37 -0800144 *
145 * The caller must account for SB and AG header modifications, etc.
146 */
147STATIC uint
148xfs_calc_inobt_res(
149 struct xfs_mount *mp)
150{
151 return xfs_calc_buf_res(mp->m_in_maxlevels, XFS_FSB_TO_B(mp, 1)) +
152 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 1),
153 XFS_FSB_TO_B(mp, 1));
154}
155
156/*
157 * The free inode btree is a conditional feature. The behavior differs slightly
158 * from that of the traditional inode btree in that the finobt tracks records
159 * for inode chunks with at least one free inode. A record can be removed from
160 * the tree during individual inode allocation. Therefore the finobt
161 * reservation is unconditional for both the inode chunk allocation and
162 * individual inode allocation (modify) cases.
163 *
164 * Behavior aside, the reservation for finobt modification is equivalent to the
165 * traditional inobt: cover a full finobt shape change plus block allocation.
Brian Foster9d43b182014-04-24 16:00:52 +1000166 */
167STATIC uint
168xfs_calc_finobt_res(
Brian Fosterf03c78f2018-01-08 10:41:37 -0800169 struct xfs_mount *mp)
Brian Foster9d43b182014-04-24 16:00:52 +1000170{
Brian Foster9d43b182014-04-24 16:00:52 +1000171 if (!xfs_sb_version_hasfinobt(&mp->m_sb))
172 return 0;
173
Brian Fosterf03c78f2018-01-08 10:41:37 -0800174 return xfs_calc_inobt_res(mp);
Brian Foster9d43b182014-04-24 16:00:52 +1000175}
176
177/*
Brian Foster57af33e2018-01-08 10:41:38 -0800178 * Calculate the reservation required to allocate or free an inode chunk. This
179 * includes:
180 *
181 * the allocation btrees: 2 trees * (max depth - 1) * block size
182 * the inode chunk: m_ialloc_blks * N
183 *
184 * The size N of the inode chunk reservation depends on whether it is for
185 * allocation or free and which type of create transaction is in use. An inode
186 * chunk free always invalidates the buffers and only requires reservation for
187 * headers (N == 0). An inode chunk allocation requires a chunk sized
188 * reservation on v4 and older superblocks to initialize the chunk. No chunk
189 * reservation is required for allocation on v5 supers, which use ordered
190 * buffers to initialize.
191 */
192STATIC uint
193xfs_calc_inode_chunk_res(
194 struct xfs_mount *mp,
195 bool alloc)
196{
197 uint res, size = 0;
198
199 res = xfs_calc_buf_res(xfs_allocfree_log_count(mp, 1),
200 XFS_FSB_TO_B(mp, 1));
201 if (alloc) {
202 /* icreate tx uses ordered buffers */
203 if (xfs_sb_version_hascrc(&mp->m_sb))
204 return res;
205 size = XFS_FSB_TO_B(mp, 1);
206 }
207
208 res += xfs_calc_buf_res(mp->m_ialloc_blks, size);
209 return res;
210}
211
212/*
Dave Chinner7fd36c42013-08-12 20:49:32 +1000213 * Various log reservation values.
214 *
215 * These are based on the size of the file system block because that is what
216 * most transactions manipulate. Each adds in an additional 128 bytes per
217 * item logged to try to account for the overhead of the transaction mechanism.
218 *
219 * Note: Most of the reservations underestimate the number of allocation
Darrick J. Wong310a75a2016-08-03 11:18:10 +1000220 * groups into which they could free extents in the xfs_defer_finish() call.
Dave Chinner7fd36c42013-08-12 20:49:32 +1000221 * This is because the number in the worst case is quite high and quite
Darrick J. Wong310a75a2016-08-03 11:18:10 +1000222 * unusual. In order to fix this we need to change xfs_defer_finish() to free
Dave Chinner7fd36c42013-08-12 20:49:32 +1000223 * extents in only a single AG at a time. This will require changes to the
224 * EFI code as well, however, so that the EFI for the extents not freed is
225 * logged again in each transaction. See SGI PV #261917.
226 *
227 * Reservation functions here avoid a huge stack in xfs_trans_init due to
228 * register overflow from temporaries in the calculations.
229 */
230
231
232/*
233 * In a write transaction we can allocate a maximum of 2
234 * extents. This gives:
235 * the inode getting the new extents: inode size
236 * the inode's bmap btree: max depth * block size
237 * the agfs of the ags from which the extents are allocated: 2 * sector
238 * the superblock free block counter: sector size
239 * the allocation btrees: 2 exts * 2 trees * (2 * max depth - 1) * block size
240 * And the bmap_finish transaction can free bmap blocks in a join:
241 * the agfs of the ags containing the blocks: 2 * sector size
242 * the agfls of the ags containing the blocks: 2 * sector size
243 * the super block free block counter: sector size
244 * the allocation btrees: 2 exts * 2 trees * (2 * max depth - 1) * block size
245 */
246STATIC uint
247xfs_calc_write_reservation(
248 struct xfs_mount *mp)
249{
250 return XFS_DQUOT_LOGRES(mp) +
Dave Chinner23956702013-08-28 16:10:35 +1000251 MAX((xfs_calc_inode_res(mp, 1) +
Dave Chinner7fd36c42013-08-12 20:49:32 +1000252 xfs_calc_buf_res(XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK),
253 XFS_FSB_TO_B(mp, 1)) +
254 xfs_calc_buf_res(3, mp->m_sb.sb_sectsize) +
Darrick J. Wongfa30f032016-08-03 11:37:10 +1000255 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 2),
Dave Chinner7fd36c42013-08-12 20:49:32 +1000256 XFS_FSB_TO_B(mp, 1))),
257 (xfs_calc_buf_res(5, mp->m_sb.sb_sectsize) +
Darrick J. Wongfa30f032016-08-03 11:37:10 +1000258 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 2),
Dave Chinner7fd36c42013-08-12 20:49:32 +1000259 XFS_FSB_TO_B(mp, 1))));
260}
261
262/*
263 * In truncating a file we free up to two extents at once. We can modify:
264 * the inode being truncated: inode size
265 * the inode's bmap btree: (max depth + 1) * block size
266 * And the bmap_finish transaction can free the blocks and bmap blocks:
267 * the agf for each of the ags: 4 * sector size
268 * the agfl for each of the ags: 4 * sector size
269 * the super block to reflect the freed blocks: sector size
270 * worst case split in allocation btrees per extent assuming 4 extents:
271 * 4 exts * 2 trees * (2 * max depth - 1) * block size
Dave Chinner7fd36c42013-08-12 20:49:32 +1000272 */
273STATIC uint
274xfs_calc_itruncate_reservation(
275 struct xfs_mount *mp)
276{
277 return XFS_DQUOT_LOGRES(mp) +
Dave Chinner23956702013-08-28 16:10:35 +1000278 MAX((xfs_calc_inode_res(mp, 1) +
Dave Chinner7fd36c42013-08-12 20:49:32 +1000279 xfs_calc_buf_res(XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) + 1,
280 XFS_FSB_TO_B(mp, 1))),
281 (xfs_calc_buf_res(9, mp->m_sb.sb_sectsize) +
Darrick J. Wongfa30f032016-08-03 11:37:10 +1000282 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 4),
Brian Fostera606ebd2018-01-08 10:41:37 -0800283 XFS_FSB_TO_B(mp, 1))));
Dave Chinner7fd36c42013-08-12 20:49:32 +1000284}
285
286/*
287 * In renaming a files we can modify:
288 * the four inodes involved: 4 * inode size
289 * the two directory btrees: 2 * (max depth + v2) * dir block size
290 * the two directory bmap btrees: 2 * max depth * block size
291 * And the bmap_finish transaction can free dir and bmap blocks (two sets
292 * of bmap blocks) giving:
293 * the agf for the ags in which the blocks live: 3 * sector size
294 * the agfl for the ags in which the blocks live: 3 * sector size
295 * the superblock for the free block count: sector size
296 * the allocation btrees: 3 exts * 2 trees * (2 * max depth - 1) * block size
297 */
298STATIC uint
299xfs_calc_rename_reservation(
300 struct xfs_mount *mp)
301{
302 return XFS_DQUOT_LOGRES(mp) +
Dave Chinner23956702013-08-28 16:10:35 +1000303 MAX((xfs_calc_inode_res(mp, 4) +
Dave Chinner7fd36c42013-08-12 20:49:32 +1000304 xfs_calc_buf_res(2 * XFS_DIROP_LOG_COUNT(mp),
305 XFS_FSB_TO_B(mp, 1))),
306 (xfs_calc_buf_res(7, mp->m_sb.sb_sectsize) +
Darrick J. Wongfa30f032016-08-03 11:37:10 +1000307 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 3),
Dave Chinner7fd36c42013-08-12 20:49:32 +1000308 XFS_FSB_TO_B(mp, 1))));
309}
310
311/*
Zhi Yong Wuab297432013-12-18 08:22:41 +0800312 * For removing an inode from unlinked list at first, we can modify:
313 * the agi hash list and counters: sector size
314 * the on disk inode before ours in the agi hash list: inode cluster size
Brian Fostere8341d92018-01-08 10:41:36 -0800315 * the on disk inode in the agi hash list: inode cluster size
Zhi Yong Wuab297432013-12-18 08:22:41 +0800316 */
317STATIC uint
318xfs_calc_iunlink_remove_reservation(
319 struct xfs_mount *mp)
320{
321 return xfs_calc_buf_res(1, mp->m_sb.sb_sectsize) +
Brian Fostere8341d92018-01-08 10:41:36 -0800322 2 * max_t(uint, XFS_FSB_TO_B(mp, 1), mp->m_inode_cluster_size);
Zhi Yong Wuab297432013-12-18 08:22:41 +0800323}
324
325/*
Dave Chinner7fd36c42013-08-12 20:49:32 +1000326 * For creating a link to an inode:
327 * the parent directory inode: inode size
328 * the linked inode: inode size
329 * the directory btree could split: (max depth + v2) * dir block size
330 * the directory bmap btree could join or split: (max depth + v2) * blocksize
331 * And the bmap_finish transaction can free some bmap blocks giving:
332 * the agf for the ag in which the blocks live: sector size
333 * the agfl for the ag in which the blocks live: sector size
334 * the superblock for the free block count: sector size
335 * the allocation btrees: 2 trees * (2 * max depth - 1) * block size
336 */
337STATIC uint
338xfs_calc_link_reservation(
339 struct xfs_mount *mp)
340{
341 return XFS_DQUOT_LOGRES(mp) +
Zhi Yong Wuab297432013-12-18 08:22:41 +0800342 xfs_calc_iunlink_remove_reservation(mp) +
Dave Chinner23956702013-08-28 16:10:35 +1000343 MAX((xfs_calc_inode_res(mp, 2) +
Dave Chinner7fd36c42013-08-12 20:49:32 +1000344 xfs_calc_buf_res(XFS_DIROP_LOG_COUNT(mp),
345 XFS_FSB_TO_B(mp, 1))),
346 (xfs_calc_buf_res(3, mp->m_sb.sb_sectsize) +
Darrick J. Wongfa30f032016-08-03 11:37:10 +1000347 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 1),
Dave Chinner7fd36c42013-08-12 20:49:32 +1000348 XFS_FSB_TO_B(mp, 1))));
349}
350
351/*
Zhi Yong Wu99b64362013-12-18 08:22:40 +0800352 * For adding an inode to unlinked list we can modify:
353 * the agi hash list: sector size
Brian Fostere8341d92018-01-08 10:41:36 -0800354 * the on disk inode: inode cluster size
Zhi Yong Wu99b64362013-12-18 08:22:40 +0800355 */
356STATIC uint
357xfs_calc_iunlink_add_reservation(xfs_mount_t *mp)
358{
359 return xfs_calc_buf_res(1, mp->m_sb.sb_sectsize) +
Brian Fostere8341d92018-01-08 10:41:36 -0800360 max_t(uint, XFS_FSB_TO_B(mp, 1), mp->m_inode_cluster_size);
Zhi Yong Wu99b64362013-12-18 08:22:40 +0800361}
362
363/*
Dave Chinner7fd36c42013-08-12 20:49:32 +1000364 * For removing a directory entry we can modify:
365 * the parent directory inode: inode size
366 * the removed inode: inode size
367 * the directory btree could join: (max depth + v2) * dir block size
368 * the directory bmap btree could join or split: (max depth + v2) * blocksize
369 * And the bmap_finish transaction can free the dir and bmap blocks giving:
370 * the agf for the ag in which the blocks live: 2 * sector size
371 * the agfl for the ag in which the blocks live: 2 * sector size
372 * the superblock for the free block count: sector size
373 * the allocation btrees: 2 exts * 2 trees * (2 * max depth - 1) * block size
374 */
375STATIC uint
376xfs_calc_remove_reservation(
377 struct xfs_mount *mp)
378{
379 return XFS_DQUOT_LOGRES(mp) +
Zhi Yong Wu99b64362013-12-18 08:22:40 +0800380 xfs_calc_iunlink_add_reservation(mp) +
381 MAX((xfs_calc_inode_res(mp, 1) +
Dave Chinner7fd36c42013-08-12 20:49:32 +1000382 xfs_calc_buf_res(XFS_DIROP_LOG_COUNT(mp),
383 XFS_FSB_TO_B(mp, 1))),
Zhi Yong Wu99b64362013-12-18 08:22:40 +0800384 (xfs_calc_buf_res(4, mp->m_sb.sb_sectsize) +
Darrick J. Wongfa30f032016-08-03 11:37:10 +1000385 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 2),
Dave Chinner7fd36c42013-08-12 20:49:32 +1000386 XFS_FSB_TO_B(mp, 1))));
387}
388
389/*
390 * For create, break it in to the two cases that the transaction
391 * covers. We start with the modify case - allocation done by modification
392 * of the state of existing inodes - and the allocation case.
393 */
394
395/*
396 * For create we can modify:
397 * the parent directory inode: inode size
398 * the new inode: inode size
399 * the inode btree entry: block size
400 * the superblock for the nlink flag: sector size
401 * the directory btree: (max depth + v2) * dir block size
402 * the directory inode's bmap btree: (max depth + v2) * block size
Brian Foster9d43b182014-04-24 16:00:52 +1000403 * the finobt (record modification and allocation btrees)
Dave Chinner7fd36c42013-08-12 20:49:32 +1000404 */
405STATIC uint
406xfs_calc_create_resv_modify(
407 struct xfs_mount *mp)
408{
Dave Chinner23956702013-08-28 16:10:35 +1000409 return xfs_calc_inode_res(mp, 2) +
Dave Chinner7fd36c42013-08-12 20:49:32 +1000410 xfs_calc_buf_res(1, mp->m_sb.sb_sectsize) +
411 (uint)XFS_FSB_TO_B(mp, 1) +
Brian Foster9d43b182014-04-24 16:00:52 +1000412 xfs_calc_buf_res(XFS_DIROP_LOG_COUNT(mp), XFS_FSB_TO_B(mp, 1)) +
Brian Fosterf03c78f2018-01-08 10:41:37 -0800413 xfs_calc_finobt_res(mp);
Dave Chinner7fd36c42013-08-12 20:49:32 +1000414}
415
416/*
Dave Chinner7fd36c42013-08-12 20:49:32 +1000417 * For icreate we can allocate some inodes giving:
418 * the agi and agf of the ag getting the new inodes: 2 * sectorsize
419 * the superblock for the nlink flag: sector size
Brian Fosterc017cb52018-01-08 10:41:38 -0800420 * the inode chunk (allocation, optional init)
Brian Fosterf03c78f2018-01-08 10:41:37 -0800421 * the inobt (record insertion)
Brian Fosterc017cb52018-01-08 10:41:38 -0800422 * the finobt (optional, record insertion)
Dave Chinner7fd36c42013-08-12 20:49:32 +1000423 */
424STATIC uint
425xfs_calc_icreate_resv_alloc(
426 struct xfs_mount *mp)
427{
428 return xfs_calc_buf_res(2, mp->m_sb.sb_sectsize) +
429 mp->m_sb.sb_sectsize +
Brian Foster57af33e2018-01-08 10:41:38 -0800430 xfs_calc_inode_chunk_res(mp, _ALLOC) +
Brian Fosterf03c78f2018-01-08 10:41:37 -0800431 xfs_calc_inobt_res(mp) +
432 xfs_calc_finobt_res(mp);
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
Zhi Yong Wu99b64362013-12-18 08:22:40 +0800444xfs_calc_create_tmpfile_reservation(
445 struct xfs_mount *mp)
446{
447 uint res = XFS_DQUOT_LOGRES(mp);
448
Brian Fosterc017cb52018-01-08 10:41:38 -0800449 res += xfs_calc_icreate_resv_alloc(mp);
Zhi Yong Wu99b64362013-12-18 08:22:40 +0800450 return res + xfs_calc_iunlink_add_reservation(mp);
451}
452
Dave Chinner7fd36c42013-08-12 20:49:32 +1000453/*
454 * Making a new directory is the same as creating a new file.
455 */
456STATIC uint
457xfs_calc_mkdir_reservation(
458 struct xfs_mount *mp)
459{
Brian Fosterc017cb52018-01-08 10:41:38 -0800460 return xfs_calc_icreate_reservation(mp);
Dave Chinner7fd36c42013-08-12 20:49:32 +1000461}
462
463
464/*
465 * Making a new symplink is the same as creating a new file, but
466 * with the added blocks for remote symlink data which can be up to 1kB in
Darrick J. Wong6eb0b8d2017-07-07 08:37:26 -0700467 * length (XFS_SYMLINK_MAXLEN).
Dave Chinner7fd36c42013-08-12 20:49:32 +1000468 */
469STATIC uint
470xfs_calc_symlink_reservation(
471 struct xfs_mount *mp)
472{
Brian Fosterc017cb52018-01-08 10:41:38 -0800473 return xfs_calc_icreate_reservation(mp) +
Darrick J. Wong6eb0b8d2017-07-07 08:37:26 -0700474 xfs_calc_buf_res(1, XFS_SYMLINK_MAXLEN);
Dave Chinner7fd36c42013-08-12 20:49:32 +1000475}
476
477/*
478 * In freeing an inode we can modify:
479 * the inode being freed: inode size
Brian Fostera6f48592018-01-08 10:41:36 -0800480 * the super block free inode counter, AGF and AGFL: sector size
481 * the on disk inode (agi unlinked list removal)
Brian Foster57af33e2018-01-08 10:41:38 -0800482 * the inode chunk (invalidated, headers only)
Brian Fosterf03c78f2018-01-08 10:41:37 -0800483 * the inode btree
Brian Foster9d43b182014-04-24 16:00:52 +1000484 * the finobt (record insertion, removal or modification)
Brian Fosterf03c78f2018-01-08 10:41:37 -0800485 *
Brian Foster57af33e2018-01-08 10:41:38 -0800486 * Note that the inode chunk res. includes an allocfree res. for freeing of the
487 * inode chunk. This is technically extraneous because the inode chunk free is
488 * deferred (it occurs after a transaction roll). Include the extra reservation
489 * anyways since we've had reports of ifree transaction overruns due to too many
490 * agfl fixups during inode chunk frees.
Dave Chinner7fd36c42013-08-12 20:49:32 +1000491 */
492STATIC uint
493xfs_calc_ifree_reservation(
494 struct xfs_mount *mp)
495{
496 return XFS_DQUOT_LOGRES(mp) +
Dave Chinner23956702013-08-28 16:10:35 +1000497 xfs_calc_inode_res(mp, 1) +
Brian Fostera6f48592018-01-08 10:41:36 -0800498 xfs_calc_buf_res(3, mp->m_sb.sb_sectsize) +
Zhi Yong Wuab297432013-12-18 08:22:41 +0800499 xfs_calc_iunlink_remove_reservation(mp) +
Brian Foster57af33e2018-01-08 10:41:38 -0800500 xfs_calc_inode_chunk_res(mp, _FREE) +
Brian Fosterf03c78f2018-01-08 10:41:37 -0800501 xfs_calc_inobt_res(mp) +
502 xfs_calc_finobt_res(mp);
Dave Chinner7fd36c42013-08-12 20:49:32 +1000503}
504
505/*
506 * When only changing the inode we log the inode and possibly the superblock
507 * We also add a bit of slop for the transaction stuff.
508 */
509STATIC uint
510xfs_calc_ichange_reservation(
511 struct xfs_mount *mp)
512{
513 return XFS_DQUOT_LOGRES(mp) +
Dave Chinner23956702013-08-28 16:10:35 +1000514 xfs_calc_inode_res(mp, 1) +
515 xfs_calc_buf_res(1, mp->m_sb.sb_sectsize);
Dave Chinner7fd36c42013-08-12 20:49:32 +1000516
517}
518
519/*
520 * Growing the data section of the filesystem.
521 * superblock
522 * agi and agf
523 * allocation btrees
524 */
525STATIC uint
526xfs_calc_growdata_reservation(
527 struct xfs_mount *mp)
528{
529 return xfs_calc_buf_res(3, mp->m_sb.sb_sectsize) +
Darrick J. Wongfa30f032016-08-03 11:37:10 +1000530 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 1),
Dave Chinner7fd36c42013-08-12 20:49:32 +1000531 XFS_FSB_TO_B(mp, 1));
532}
533
534/*
535 * Growing the rt section of the filesystem.
536 * In the first set of transactions (ALLOC) we allocate space to the
537 * bitmap or summary files.
538 * superblock: sector size
539 * agf of the ag from which the extent is allocated: sector size
540 * bmap btree for bitmap/summary inode: max depth * blocksize
541 * bitmap/summary inode: inode size
542 * allocation btrees for 1 block alloc: 2 * (2 * maxdepth - 1) * blocksize
543 */
544STATIC uint
545xfs_calc_growrtalloc_reservation(
546 struct xfs_mount *mp)
547{
548 return xfs_calc_buf_res(2, mp->m_sb.sb_sectsize) +
549 xfs_calc_buf_res(XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK),
550 XFS_FSB_TO_B(mp, 1)) +
Dave Chinner23956702013-08-28 16:10:35 +1000551 xfs_calc_inode_res(mp, 1) +
Darrick J. Wongfa30f032016-08-03 11:37:10 +1000552 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 1),
Dave Chinner7fd36c42013-08-12 20:49:32 +1000553 XFS_FSB_TO_B(mp, 1));
554}
555
556/*
557 * Growing the rt section of the filesystem.
558 * In the second set of transactions (ZERO) we zero the new metadata blocks.
559 * one bitmap/summary block: blocksize
560 */
561STATIC uint
562xfs_calc_growrtzero_reservation(
563 struct xfs_mount *mp)
564{
565 return xfs_calc_buf_res(1, mp->m_sb.sb_blocksize);
566}
567
568/*
569 * Growing the rt section of the filesystem.
570 * In the third set of transactions (FREE) we update metadata without
571 * allocating any new blocks.
572 * superblock: sector size
573 * bitmap inode: inode size
574 * summary inode: inode size
575 * one bitmap block: blocksize
576 * summary blocks: new summary size
577 */
578STATIC uint
579xfs_calc_growrtfree_reservation(
580 struct xfs_mount *mp)
581{
582 return xfs_calc_buf_res(1, mp->m_sb.sb_sectsize) +
Dave Chinner23956702013-08-28 16:10:35 +1000583 xfs_calc_inode_res(mp, 2) +
Dave Chinner7fd36c42013-08-12 20:49:32 +1000584 xfs_calc_buf_res(1, mp->m_sb.sb_blocksize) +
585 xfs_calc_buf_res(1, mp->m_rsumsize);
586}
587
588/*
589 * Logging the inode modification timestamp on a synchronous write.
590 * inode
591 */
592STATIC uint
593xfs_calc_swrite_reservation(
594 struct xfs_mount *mp)
595{
Dave Chinner23956702013-08-28 16:10:35 +1000596 return xfs_calc_inode_res(mp, 1);
Dave Chinner7fd36c42013-08-12 20:49:32 +1000597}
598
599/*
600 * Logging the inode mode bits when writing a setuid/setgid file
601 * inode
602 */
603STATIC uint
Dave Chinner23956702013-08-28 16:10:35 +1000604xfs_calc_writeid_reservation(
605 struct xfs_mount *mp)
Dave Chinner7fd36c42013-08-12 20:49:32 +1000606{
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 * Converting the inode from non-attributed to attributed.
612 * the inode being converted: inode size
613 * agf block and superblock (for block allocation)
614 * the new block (directory sized)
615 * bmap blocks for the new directory block
616 * allocation btrees
617 */
618STATIC uint
619xfs_calc_addafork_reservation(
620 struct xfs_mount *mp)
621{
622 return XFS_DQUOT_LOGRES(mp) +
Dave Chinner23956702013-08-28 16:10:35 +1000623 xfs_calc_inode_res(mp, 1) +
Dave Chinner7fd36c42013-08-12 20:49:32 +1000624 xfs_calc_buf_res(2, mp->m_sb.sb_sectsize) +
Dave Chinner8f661932014-06-06 15:15:59 +1000625 xfs_calc_buf_res(1, mp->m_dir_geo->blksize) +
Dave Chinner7fd36c42013-08-12 20:49:32 +1000626 xfs_calc_buf_res(XFS_DAENTER_BMAP1B(mp, XFS_DATA_FORK) + 1,
627 XFS_FSB_TO_B(mp, 1)) +
Darrick J. Wongfa30f032016-08-03 11:37:10 +1000628 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 1),
Dave Chinner7fd36c42013-08-12 20:49:32 +1000629 XFS_FSB_TO_B(mp, 1));
630}
631
632/*
633 * Removing the attribute fork of a file
634 * the inode being truncated: inode size
635 * the inode's bmap btree: max depth * block size
636 * And the bmap_finish transaction can free the blocks and bmap blocks:
637 * the agf for each of the ags: 4 * sector size
638 * the agfl for each of the ags: 4 * sector size
639 * the super block to reflect the freed blocks: sector size
640 * worst case split in allocation btrees per extent assuming 4 extents:
641 * 4 exts * 2 trees * (2 * max depth - 1) * block size
642 */
643STATIC uint
644xfs_calc_attrinval_reservation(
645 struct xfs_mount *mp)
646{
Dave Chinner23956702013-08-28 16:10:35 +1000647 return MAX((xfs_calc_inode_res(mp, 1) +
Dave Chinner7fd36c42013-08-12 20:49:32 +1000648 xfs_calc_buf_res(XFS_BM_MAXLEVELS(mp, XFS_ATTR_FORK),
649 XFS_FSB_TO_B(mp, 1))),
650 (xfs_calc_buf_res(9, mp->m_sb.sb_sectsize) +
Darrick J. Wongfa30f032016-08-03 11:37:10 +1000651 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 4),
Dave Chinner7fd36c42013-08-12 20:49:32 +1000652 XFS_FSB_TO_B(mp, 1))));
653}
654
655/*
656 * Setting an attribute at mount time.
657 * the inode getting the attribute
658 * the superblock for allocations
659 * the agfs extents are allocated from
660 * the attribute btree * max depth
661 * the inode allocation btree
662 * Since attribute transaction space is dependent on the size of the attribute,
663 * the calculation is done partially at mount time and partially at runtime(see
664 * below).
665 */
666STATIC uint
667xfs_calc_attrsetm_reservation(
668 struct xfs_mount *mp)
669{
670 return XFS_DQUOT_LOGRES(mp) +
Dave Chinner23956702013-08-28 16:10:35 +1000671 xfs_calc_inode_res(mp, 1) +
Dave Chinner7fd36c42013-08-12 20:49:32 +1000672 xfs_calc_buf_res(1, mp->m_sb.sb_sectsize) +
673 xfs_calc_buf_res(XFS_DA_NODE_MAXDEPTH, XFS_FSB_TO_B(mp, 1));
674}
675
676/*
677 * Setting an attribute at runtime, transaction space unit per block.
678 * the superblock for allocations: sector size
679 * the inode bmap btree could join or split: max depth * block size
680 * Since the runtime attribute transaction space is dependent on the total
681 * blocks needed for the 1st bmap, here we calculate out the space unit for
682 * one block so that the caller could figure out the total space according
Jie Liu3d3c8b52013-08-12 20:49:59 +1000683 * to the attibute extent length in blocks by:
684 * ext * M_RES(mp)->tr_attrsetrt.tr_logres
Dave Chinner7fd36c42013-08-12 20:49:32 +1000685 */
686STATIC uint
687xfs_calc_attrsetrt_reservation(
688 struct xfs_mount *mp)
689{
690 return xfs_calc_buf_res(1, mp->m_sb.sb_sectsize) +
691 xfs_calc_buf_res(XFS_BM_MAXLEVELS(mp, XFS_ATTR_FORK),
692 XFS_FSB_TO_B(mp, 1));
693}
694
695/*
696 * Removing an attribute.
697 * the inode: inode size
698 * the attribute btree could join: max depth * block size
699 * the inode bmap btree could join or split: max depth * block size
700 * And the bmap_finish transaction can free the attr blocks freed giving:
701 * the agf for the ag in which the blocks live: 2 * sector size
702 * the agfl for the ag in which the blocks live: 2 * sector size
703 * the superblock for the free block count: sector size
704 * the allocation btrees: 2 exts * 2 trees * (2 * max depth - 1) * block size
705 */
706STATIC uint
707xfs_calc_attrrm_reservation(
708 struct xfs_mount *mp)
709{
710 return XFS_DQUOT_LOGRES(mp) +
Dave Chinner23956702013-08-28 16:10:35 +1000711 MAX((xfs_calc_inode_res(mp, 1) +
Dave Chinner7fd36c42013-08-12 20:49:32 +1000712 xfs_calc_buf_res(XFS_DA_NODE_MAXDEPTH,
713 XFS_FSB_TO_B(mp, 1)) +
714 (uint)XFS_FSB_TO_B(mp,
715 XFS_BM_MAXLEVELS(mp, XFS_ATTR_FORK)) +
716 xfs_calc_buf_res(XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK), 0)),
717 (xfs_calc_buf_res(5, mp->m_sb.sb_sectsize) +
Darrick J. Wongfa30f032016-08-03 11:37:10 +1000718 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 2),
Dave Chinner7fd36c42013-08-12 20:49:32 +1000719 XFS_FSB_TO_B(mp, 1))));
720}
721
722/*
723 * Clearing a bad agino number in an agi hash bucket.
724 */
725STATIC uint
726xfs_calc_clear_agi_bucket_reservation(
727 struct xfs_mount *mp)
728{
729 return xfs_calc_buf_res(1, mp->m_sb.sb_sectsize);
730}
731
732/*
Dave Chinner7fd36c42013-08-12 20:49:32 +1000733 * Adjusting quota limits.
734 * the xfs_disk_dquot_t: sizeof(struct xfs_disk_dquot)
735 */
736STATIC uint
Eric Sandeena1f69412018-04-06 10:09:42 -0700737xfs_calc_qm_setqlim_reservation(void)
Dave Chinner7fd36c42013-08-12 20:49:32 +1000738{
739 return xfs_calc_buf_res(1, sizeof(struct xfs_disk_dquot));
740}
741
742/*
743 * Allocating quota on disk if needed.
Brian Foster410b11a2014-02-07 14:55:54 +1100744 * the write transaction log space for quota file extent allocation
Dave Chinner7fd36c42013-08-12 20:49:32 +1000745 * the unit of quota allocation: one system block size
746 */
747STATIC uint
748xfs_calc_qm_dqalloc_reservation(
749 struct xfs_mount *mp)
750{
Brian Foster410b11a2014-02-07 14:55:54 +1100751 return xfs_calc_write_reservation(mp) +
Dave Chinner7fd36c42013-08-12 20:49:32 +1000752 xfs_calc_buf_res(1,
753 XFS_FSB_TO_B(mp, XFS_DQUOT_CLUSTER_SIZE_FSB) - 1);
754}
755
756/*
757 * Turning off quotas.
758 * the xfs_qoff_logitem_t: sizeof(struct xfs_qoff_logitem) * 2
759 * the superblock for the quota flags: sector size
760 */
761STATIC uint
762xfs_calc_qm_quotaoff_reservation(
763 struct xfs_mount *mp)
764{
765 return sizeof(struct xfs_qoff_logitem) * 2 +
766 xfs_calc_buf_res(1, mp->m_sb.sb_sectsize);
767}
768
769/*
770 * End of turning off quotas.
771 * the xfs_qoff_logitem_t: sizeof(struct xfs_qoff_logitem) * 2
772 */
773STATIC uint
Eric Sandeena1f69412018-04-06 10:09:42 -0700774xfs_calc_qm_quotaoff_end_reservation(void)
Dave Chinner7fd36c42013-08-12 20:49:32 +1000775{
776 return sizeof(struct xfs_qoff_logitem) * 2;
777}
778
779/*
780 * Syncing the incore super block changes to disk.
781 * the super block to reflect the changes: sector size
782 */
783STATIC uint
784xfs_calc_sb_reservation(
785 struct xfs_mount *mp)
786{
787 return xfs_calc_buf_res(1, mp->m_sb.sb_sectsize);
788}
789
790void
791xfs_trans_resv_calc(
792 struct xfs_mount *mp,
793 struct xfs_trans_resv *resp)
794{
Jie Liu0eadd102013-08-12 20:49:56 +1000795 /*
796 * The following transactions are logged in physical format and
797 * require a permanent reservation on space.
798 */
799 resp->tr_write.tr_logres = xfs_calc_write_reservation(mp);
Darrick J. Wong80de4622016-10-03 09:11:47 -0700800 if (xfs_sb_version_hasreflink(&mp->m_sb))
801 resp->tr_write.tr_logcount = XFS_WRITE_LOG_COUNT_REFLINK;
802 else
803 resp->tr_write.tr_logcount = XFS_WRITE_LOG_COUNT;
Jie Liu0eadd102013-08-12 20:49:56 +1000804 resp->tr_write.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
805
806 resp->tr_itruncate.tr_logres = xfs_calc_itruncate_reservation(mp);
Darrick J. Wong80de4622016-10-03 09:11:47 -0700807 if (xfs_sb_version_hasreflink(&mp->m_sb))
808 resp->tr_itruncate.tr_logcount =
809 XFS_ITRUNCATE_LOG_COUNT_REFLINK;
810 else
811 resp->tr_itruncate.tr_logcount = XFS_ITRUNCATE_LOG_COUNT;
Jie Liu0eadd102013-08-12 20:49:56 +1000812 resp->tr_itruncate.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
813
814 resp->tr_rename.tr_logres = xfs_calc_rename_reservation(mp);
815 resp->tr_rename.tr_logcount = XFS_RENAME_LOG_COUNT;
816 resp->tr_rename.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
817
818 resp->tr_link.tr_logres = xfs_calc_link_reservation(mp);
819 resp->tr_link.tr_logcount = XFS_LINK_LOG_COUNT;
820 resp->tr_link.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
821
822 resp->tr_remove.tr_logres = xfs_calc_remove_reservation(mp);
823 resp->tr_remove.tr_logcount = XFS_REMOVE_LOG_COUNT;
824 resp->tr_remove.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
825
826 resp->tr_symlink.tr_logres = xfs_calc_symlink_reservation(mp);
827 resp->tr_symlink.tr_logcount = XFS_SYMLINK_LOG_COUNT;
828 resp->tr_symlink.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
829
Brian Fosterc017cb52018-01-08 10:41:38 -0800830 resp->tr_create.tr_logres = xfs_calc_icreate_reservation(mp);
Jie Liu0eadd102013-08-12 20:49:56 +1000831 resp->tr_create.tr_logcount = XFS_CREATE_LOG_COUNT;
832 resp->tr_create.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
833
Zhi Yong Wu99b64362013-12-18 08:22:40 +0800834 resp->tr_create_tmpfile.tr_logres =
835 xfs_calc_create_tmpfile_reservation(mp);
836 resp->tr_create_tmpfile.tr_logcount = XFS_CREATE_TMPFILE_LOG_COUNT;
837 resp->tr_create_tmpfile.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
838
Jie Liu0eadd102013-08-12 20:49:56 +1000839 resp->tr_mkdir.tr_logres = xfs_calc_mkdir_reservation(mp);
840 resp->tr_mkdir.tr_logcount = XFS_MKDIR_LOG_COUNT;
841 resp->tr_mkdir.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
842
843 resp->tr_ifree.tr_logres = xfs_calc_ifree_reservation(mp);
844 resp->tr_ifree.tr_logcount = XFS_INACTIVE_LOG_COUNT;
845 resp->tr_ifree.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
846
847 resp->tr_addafork.tr_logres = xfs_calc_addafork_reservation(mp);
848 resp->tr_addafork.tr_logcount = XFS_ADDAFORK_LOG_COUNT;
849 resp->tr_addafork.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
850
851 resp->tr_attrinval.tr_logres = xfs_calc_attrinval_reservation(mp);
852 resp->tr_attrinval.tr_logcount = XFS_ATTRINVAL_LOG_COUNT;
853 resp->tr_attrinval.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
854
855 resp->tr_attrsetm.tr_logres = xfs_calc_attrsetm_reservation(mp);
856 resp->tr_attrsetm.tr_logcount = XFS_ATTRSET_LOG_COUNT;
857 resp->tr_attrsetm.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
858
859 resp->tr_attrrm.tr_logres = xfs_calc_attrrm_reservation(mp);
860 resp->tr_attrrm.tr_logcount = XFS_ATTRRM_LOG_COUNT;
861 resp->tr_attrrm.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
862
863 resp->tr_growrtalloc.tr_logres = xfs_calc_growrtalloc_reservation(mp);
864 resp->tr_growrtalloc.tr_logcount = XFS_DEFAULT_PERM_LOG_COUNT;
865 resp->tr_growrtalloc.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
866
867 resp->tr_qm_dqalloc.tr_logres = xfs_calc_qm_dqalloc_reservation(mp);
Darrick J. Wong80de4622016-10-03 09:11:47 -0700868 if (xfs_sb_version_hasreflink(&mp->m_sb))
869 resp->tr_qm_dqalloc.tr_logcount = XFS_WRITE_LOG_COUNT_REFLINK;
870 else
871 resp->tr_qm_dqalloc.tr_logcount = XFS_WRITE_LOG_COUNT;
Jie Liu0eadd102013-08-12 20:49:56 +1000872 resp->tr_qm_dqalloc.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
873
874 /*
875 * The following transactions are logged in logical format with
876 * a default log count.
877 */
Eric Sandeena1f69412018-04-06 10:09:42 -0700878 resp->tr_qm_setqlim.tr_logres = xfs_calc_qm_setqlim_reservation();
Jie Liu0eadd102013-08-12 20:49:56 +1000879 resp->tr_qm_setqlim.tr_logcount = XFS_DEFAULT_LOG_COUNT;
880
881 resp->tr_qm_quotaoff.tr_logres = xfs_calc_qm_quotaoff_reservation(mp);
882 resp->tr_qm_quotaoff.tr_logcount = XFS_DEFAULT_LOG_COUNT;
883
884 resp->tr_qm_equotaoff.tr_logres =
Eric Sandeena1f69412018-04-06 10:09:42 -0700885 xfs_calc_qm_quotaoff_end_reservation();
Jie Liu0eadd102013-08-12 20:49:56 +1000886 resp->tr_qm_equotaoff.tr_logcount = XFS_DEFAULT_LOG_COUNT;
887
888 resp->tr_sb.tr_logres = xfs_calc_sb_reservation(mp);
889 resp->tr_sb.tr_logcount = XFS_DEFAULT_LOG_COUNT;
890
891 /* The following transaction are logged in logical format */
892 resp->tr_ichange.tr_logres = xfs_calc_ichange_reservation(mp);
893 resp->tr_growdata.tr_logres = xfs_calc_growdata_reservation(mp);
Jie Liu20996c92013-08-12 20:49:57 +1000894 resp->tr_fsyncts.tr_logres = xfs_calc_swrite_reservation(mp);
Jie Liu0eadd102013-08-12 20:49:56 +1000895 resp->tr_writeid.tr_logres = xfs_calc_writeid_reservation(mp);
896 resp->tr_attrsetrt.tr_logres = xfs_calc_attrsetrt_reservation(mp);
897 resp->tr_clearagi.tr_logres = xfs_calc_clear_agi_bucket_reservation(mp);
898 resp->tr_growrtzero.tr_logres = xfs_calc_growrtzero_reservation(mp);
899 resp->tr_growrtfree.tr_logres = xfs_calc_growrtfree_reservation(mp);
Dave Chinner7fd36c42013-08-12 20:49:32 +1000900}