blob: 838566b856229cbc41edfba068aaa1d2f0e03996 [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
285 */
286STATIC uint
287xfs_calc_iunlink_remove_reservation(
288 struct xfs_mount *mp)
289{
290 return xfs_calc_buf_res(1, mp->m_sb.sb_sectsize) +
Dave Chinnerfe986f92014-03-13 19:14:43 +1100291 max_t(uint, XFS_FSB_TO_B(mp, 1), mp->m_inode_cluster_size);
Zhi Yong Wuab297432013-12-18 08:22:41 +0800292}
293
294/*
Dave Chinner7fd36c42013-08-12 20:49:32 +1000295 * For creating a link to an inode:
296 * the parent directory inode: inode size
297 * the linked inode: inode size
298 * the directory btree could split: (max depth + v2) * dir block size
299 * the directory bmap btree could join or split: (max depth + v2) * blocksize
300 * And the bmap_finish transaction can free some bmap blocks giving:
301 * the agf for the ag in which the blocks live: sector size
302 * the agfl for the ag in which the blocks live: sector size
303 * the superblock for the free block count: sector size
304 * the allocation btrees: 2 trees * (2 * max depth - 1) * block size
305 */
306STATIC uint
307xfs_calc_link_reservation(
308 struct xfs_mount *mp)
309{
310 return XFS_DQUOT_LOGRES(mp) +
Zhi Yong Wuab297432013-12-18 08:22:41 +0800311 xfs_calc_iunlink_remove_reservation(mp) +
Dave Chinner23956702013-08-28 16:10:35 +1000312 MAX((xfs_calc_inode_res(mp, 2) +
Dave Chinner7fd36c42013-08-12 20:49:32 +1000313 xfs_calc_buf_res(XFS_DIROP_LOG_COUNT(mp),
314 XFS_FSB_TO_B(mp, 1))),
315 (xfs_calc_buf_res(3, mp->m_sb.sb_sectsize) +
Darrick J. Wongfa30f032016-08-03 11:37:10 +1000316 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 1),
Dave Chinner7fd36c42013-08-12 20:49:32 +1000317 XFS_FSB_TO_B(mp, 1))));
318}
319
320/*
Zhi Yong Wu99b64362013-12-18 08:22:40 +0800321 * For adding an inode to unlinked list we can modify:
322 * the agi hash list: sector size
323 * the unlinked inode: inode size
324 */
325STATIC uint
326xfs_calc_iunlink_add_reservation(xfs_mount_t *mp)
327{
328 return xfs_calc_buf_res(1, mp->m_sb.sb_sectsize) +
329 xfs_calc_inode_res(mp, 1);
330}
331
332/*
Dave Chinner7fd36c42013-08-12 20:49:32 +1000333 * For removing a directory entry we can modify:
334 * the parent directory inode: inode size
335 * the removed inode: inode size
336 * the directory btree could join: (max depth + v2) * dir block size
337 * the directory bmap btree could join or split: (max depth + v2) * blocksize
338 * And the bmap_finish transaction can free the dir and bmap blocks giving:
339 * the agf for the ag in which the blocks live: 2 * sector size
340 * the agfl for the ag in which the blocks live: 2 * sector size
341 * the superblock for the free block count: sector size
342 * the allocation btrees: 2 exts * 2 trees * (2 * max depth - 1) * block size
343 */
344STATIC uint
345xfs_calc_remove_reservation(
346 struct xfs_mount *mp)
347{
348 return XFS_DQUOT_LOGRES(mp) +
Zhi Yong Wu99b64362013-12-18 08:22:40 +0800349 xfs_calc_iunlink_add_reservation(mp) +
350 MAX((xfs_calc_inode_res(mp, 1) +
Dave Chinner7fd36c42013-08-12 20:49:32 +1000351 xfs_calc_buf_res(XFS_DIROP_LOG_COUNT(mp),
352 XFS_FSB_TO_B(mp, 1))),
Zhi Yong Wu99b64362013-12-18 08:22:40 +0800353 (xfs_calc_buf_res(4, mp->m_sb.sb_sectsize) +
Darrick J. Wongfa30f032016-08-03 11:37:10 +1000354 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 2),
Dave Chinner7fd36c42013-08-12 20:49:32 +1000355 XFS_FSB_TO_B(mp, 1))));
356}
357
358/*
359 * For create, break it in to the two cases that the transaction
360 * covers. We start with the modify case - allocation done by modification
361 * of the state of existing inodes - and the allocation case.
362 */
363
364/*
365 * For create we can modify:
366 * the parent directory inode: inode size
367 * the new inode: inode size
368 * the inode btree entry: block size
369 * the superblock for the nlink flag: sector size
370 * the directory btree: (max depth + v2) * dir block size
371 * the directory inode's bmap btree: (max depth + v2) * block size
Brian Foster9d43b182014-04-24 16:00:52 +1000372 * the finobt (record modification and allocation btrees)
Dave Chinner7fd36c42013-08-12 20:49:32 +1000373 */
374STATIC uint
375xfs_calc_create_resv_modify(
376 struct xfs_mount *mp)
377{
Dave Chinner23956702013-08-28 16:10:35 +1000378 return xfs_calc_inode_res(mp, 2) +
Dave Chinner7fd36c42013-08-12 20:49:32 +1000379 xfs_calc_buf_res(1, mp->m_sb.sb_sectsize) +
380 (uint)XFS_FSB_TO_B(mp, 1) +
Brian Foster9d43b182014-04-24 16:00:52 +1000381 xfs_calc_buf_res(XFS_DIROP_LOG_COUNT(mp), XFS_FSB_TO_B(mp, 1)) +
382 xfs_calc_finobt_res(mp, 1, 1);
Dave Chinner7fd36c42013-08-12 20:49:32 +1000383}
384
385/*
386 * For create we can allocate some inodes giving:
387 * the agi and agf of the ag getting the new inodes: 2 * sectorsize
388 * the superblock for the nlink flag: sector size
Jie Liu126cd102013-12-13 15:51:48 +1100389 * the inode blocks allocated: mp->m_ialloc_blks * blocksize
Dave Chinner7fd36c42013-08-12 20:49:32 +1000390 * the inode btree: max depth * blocksize
391 * the allocation btrees: 2 trees * (max depth - 1) * block size
392 */
393STATIC uint
394xfs_calc_create_resv_alloc(
395 struct xfs_mount *mp)
396{
397 return xfs_calc_buf_res(2, mp->m_sb.sb_sectsize) +
398 mp->m_sb.sb_sectsize +
Jie Liu126cd102013-12-13 15:51:48 +1100399 xfs_calc_buf_res(mp->m_ialloc_blks, XFS_FSB_TO_B(mp, 1)) +
Dave Chinner7fd36c42013-08-12 20:49:32 +1000400 xfs_calc_buf_res(mp->m_in_maxlevels, XFS_FSB_TO_B(mp, 1)) +
Darrick J. Wongfa30f032016-08-03 11:37:10 +1000401 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 1),
Dave Chinner7fd36c42013-08-12 20:49:32 +1000402 XFS_FSB_TO_B(mp, 1));
403}
404
405STATIC uint
406__xfs_calc_create_reservation(
407 struct xfs_mount *mp)
408{
409 return XFS_DQUOT_LOGRES(mp) +
410 MAX(xfs_calc_create_resv_alloc(mp),
411 xfs_calc_create_resv_modify(mp));
412}
413
414/*
415 * For icreate we can allocate some inodes giving:
416 * the agi and agf of the ag getting the new inodes: 2 * sectorsize
417 * the superblock for the nlink flag: sector size
418 * the inode btree: max depth * blocksize
419 * the allocation btrees: 2 trees * (max depth - 1) * block size
Brian Foster9d43b182014-04-24 16:00:52 +1000420 * the finobt (record insertion)
Dave Chinner7fd36c42013-08-12 20:49:32 +1000421 */
422STATIC uint
423xfs_calc_icreate_resv_alloc(
424 struct xfs_mount *mp)
425{
426 return xfs_calc_buf_res(2, mp->m_sb.sb_sectsize) +
427 mp->m_sb.sb_sectsize +
428 xfs_calc_buf_res(mp->m_in_maxlevels, XFS_FSB_TO_B(mp, 1)) +
Darrick J. Wongfa30f032016-08-03 11:37:10 +1000429 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 1),
Brian Foster9d43b182014-04-24 16:00:52 +1000430 XFS_FSB_TO_B(mp, 1)) +
431 xfs_calc_finobt_res(mp, 0, 0);
Dave Chinner7fd36c42013-08-12 20:49:32 +1000432}
433
434STATIC uint
435xfs_calc_icreate_reservation(xfs_mount_t *mp)
436{
437 return XFS_DQUOT_LOGRES(mp) +
438 MAX(xfs_calc_icreate_resv_alloc(mp),
439 xfs_calc_create_resv_modify(mp));
440}
441
442STATIC uint
443xfs_calc_create_reservation(
444 struct xfs_mount *mp)
445{
446 if (xfs_sb_version_hascrc(&mp->m_sb))
447 return xfs_calc_icreate_reservation(mp);
448 return __xfs_calc_create_reservation(mp);
449
450}
451
Zhi Yong Wu99b64362013-12-18 08:22:40 +0800452STATIC uint
453xfs_calc_create_tmpfile_reservation(
454 struct xfs_mount *mp)
455{
456 uint res = XFS_DQUOT_LOGRES(mp);
457
458 if (xfs_sb_version_hascrc(&mp->m_sb))
459 res += xfs_calc_icreate_resv_alloc(mp);
460 else
461 res += xfs_calc_create_resv_alloc(mp);
462
463 return res + xfs_calc_iunlink_add_reservation(mp);
464}
465
Dave Chinner7fd36c42013-08-12 20:49:32 +1000466/*
467 * Making a new directory is the same as creating a new file.
468 */
469STATIC uint
470xfs_calc_mkdir_reservation(
471 struct xfs_mount *mp)
472{
473 return xfs_calc_create_reservation(mp);
474}
475
476
477/*
478 * Making a new symplink is the same as creating a new file, but
479 * with the added blocks for remote symlink data which can be up to 1kB in
Darrick J. Wong6eb0b8d2017-07-07 08:37:26 -0700480 * length (XFS_SYMLINK_MAXLEN).
Dave Chinner7fd36c42013-08-12 20:49:32 +1000481 */
482STATIC uint
483xfs_calc_symlink_reservation(
484 struct xfs_mount *mp)
485{
486 return xfs_calc_create_reservation(mp) +
Darrick J. Wong6eb0b8d2017-07-07 08:37:26 -0700487 xfs_calc_buf_res(1, XFS_SYMLINK_MAXLEN);
Dave Chinner7fd36c42013-08-12 20:49:32 +1000488}
489
490/*
491 * In freeing an inode we can modify:
492 * the inode being freed: inode size
Brian Fostera6f48592018-01-08 10:41:36 -0800493 * the super block free inode counter, AGF and AGFL: sector size
494 * the on disk inode (agi unlinked list removal)
495 * the inode chunk is marked stale (headers only)
Dave Chinner7fd36c42013-08-12 20:49:32 +1000496 * the inode btree: max depth * blocksize
497 * the allocation btrees: 2 trees * (max depth - 1) * block size
Brian Foster9d43b182014-04-24 16:00:52 +1000498 * the finobt (record insertion, removal or modification)
Dave Chinner7fd36c42013-08-12 20:49:32 +1000499 */
500STATIC uint
501xfs_calc_ifree_reservation(
502 struct xfs_mount *mp)
503{
504 return XFS_DQUOT_LOGRES(mp) +
Dave Chinner23956702013-08-28 16:10:35 +1000505 xfs_calc_inode_res(mp, 1) +
Brian Fostera6f48592018-01-08 10:41:36 -0800506 xfs_calc_buf_res(3, mp->m_sb.sb_sectsize) +
Zhi Yong Wuab297432013-12-18 08:22:41 +0800507 xfs_calc_iunlink_remove_reservation(mp) +
Brian Fostera6f48592018-01-08 10:41:36 -0800508 xfs_calc_buf_res(mp->m_ialloc_blks, 0) +
509 xfs_calc_buf_res(mp->m_in_maxlevels, XFS_FSB_TO_B(mp, 1)) +
Darrick J. Wongfa30f032016-08-03 11:37:10 +1000510 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 1),
Brian Foster9d43b182014-04-24 16:00:52 +1000511 XFS_FSB_TO_B(mp, 1)) +
512 xfs_calc_finobt_res(mp, 0, 1);
Dave Chinner7fd36c42013-08-12 20:49:32 +1000513}
514
515/*
516 * When only changing the inode we log the inode and possibly the superblock
517 * We also add a bit of slop for the transaction stuff.
518 */
519STATIC uint
520xfs_calc_ichange_reservation(
521 struct xfs_mount *mp)
522{
523 return XFS_DQUOT_LOGRES(mp) +
Dave Chinner23956702013-08-28 16:10:35 +1000524 xfs_calc_inode_res(mp, 1) +
525 xfs_calc_buf_res(1, mp->m_sb.sb_sectsize);
Dave Chinner7fd36c42013-08-12 20:49:32 +1000526
527}
528
529/*
530 * Growing the data section of the filesystem.
531 * superblock
532 * agi and agf
533 * allocation btrees
534 */
535STATIC uint
536xfs_calc_growdata_reservation(
537 struct xfs_mount *mp)
538{
539 return xfs_calc_buf_res(3, mp->m_sb.sb_sectsize) +
Darrick J. Wongfa30f032016-08-03 11:37:10 +1000540 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 1),
Dave Chinner7fd36c42013-08-12 20:49:32 +1000541 XFS_FSB_TO_B(mp, 1));
542}
543
544/*
545 * Growing the rt section of the filesystem.
546 * In the first set of transactions (ALLOC) we allocate space to the
547 * bitmap or summary files.
548 * superblock: sector size
549 * agf of the ag from which the extent is allocated: sector size
550 * bmap btree for bitmap/summary inode: max depth * blocksize
551 * bitmap/summary inode: inode size
552 * allocation btrees for 1 block alloc: 2 * (2 * maxdepth - 1) * blocksize
553 */
554STATIC uint
555xfs_calc_growrtalloc_reservation(
556 struct xfs_mount *mp)
557{
558 return xfs_calc_buf_res(2, mp->m_sb.sb_sectsize) +
559 xfs_calc_buf_res(XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK),
560 XFS_FSB_TO_B(mp, 1)) +
Dave Chinner23956702013-08-28 16:10:35 +1000561 xfs_calc_inode_res(mp, 1) +
Darrick J. Wongfa30f032016-08-03 11:37:10 +1000562 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 1),
Dave Chinner7fd36c42013-08-12 20:49:32 +1000563 XFS_FSB_TO_B(mp, 1));
564}
565
566/*
567 * Growing the rt section of the filesystem.
568 * In the second set of transactions (ZERO) we zero the new metadata blocks.
569 * one bitmap/summary block: blocksize
570 */
571STATIC uint
572xfs_calc_growrtzero_reservation(
573 struct xfs_mount *mp)
574{
575 return xfs_calc_buf_res(1, mp->m_sb.sb_blocksize);
576}
577
578/*
579 * Growing the rt section of the filesystem.
580 * In the third set of transactions (FREE) we update metadata without
581 * allocating any new blocks.
582 * superblock: sector size
583 * bitmap inode: inode size
584 * summary inode: inode size
585 * one bitmap block: blocksize
586 * summary blocks: new summary size
587 */
588STATIC uint
589xfs_calc_growrtfree_reservation(
590 struct xfs_mount *mp)
591{
592 return xfs_calc_buf_res(1, mp->m_sb.sb_sectsize) +
Dave Chinner23956702013-08-28 16:10:35 +1000593 xfs_calc_inode_res(mp, 2) +
Dave Chinner7fd36c42013-08-12 20:49:32 +1000594 xfs_calc_buf_res(1, mp->m_sb.sb_blocksize) +
595 xfs_calc_buf_res(1, mp->m_rsumsize);
596}
597
598/*
599 * Logging the inode modification timestamp on a synchronous write.
600 * inode
601 */
602STATIC uint
603xfs_calc_swrite_reservation(
604 struct xfs_mount *mp)
605{
Dave Chinner23956702013-08-28 16:10:35 +1000606 return xfs_calc_inode_res(mp, 1);
Dave Chinner7fd36c42013-08-12 20:49:32 +1000607}
608
609/*
610 * Logging the inode mode bits when writing a setuid/setgid file
611 * inode
612 */
613STATIC uint
Dave Chinner23956702013-08-28 16:10:35 +1000614xfs_calc_writeid_reservation(
615 struct xfs_mount *mp)
Dave Chinner7fd36c42013-08-12 20:49:32 +1000616{
Dave Chinner23956702013-08-28 16:10:35 +1000617 return xfs_calc_inode_res(mp, 1);
Dave Chinner7fd36c42013-08-12 20:49:32 +1000618}
619
620/*
621 * Converting the inode from non-attributed to attributed.
622 * the inode being converted: inode size
623 * agf block and superblock (for block allocation)
624 * the new block (directory sized)
625 * bmap blocks for the new directory block
626 * allocation btrees
627 */
628STATIC uint
629xfs_calc_addafork_reservation(
630 struct xfs_mount *mp)
631{
632 return XFS_DQUOT_LOGRES(mp) +
Dave Chinner23956702013-08-28 16:10:35 +1000633 xfs_calc_inode_res(mp, 1) +
Dave Chinner7fd36c42013-08-12 20:49:32 +1000634 xfs_calc_buf_res(2, mp->m_sb.sb_sectsize) +
Dave Chinner8f661932014-06-06 15:15:59 +1000635 xfs_calc_buf_res(1, mp->m_dir_geo->blksize) +
Dave Chinner7fd36c42013-08-12 20:49:32 +1000636 xfs_calc_buf_res(XFS_DAENTER_BMAP1B(mp, XFS_DATA_FORK) + 1,
637 XFS_FSB_TO_B(mp, 1)) +
Darrick J. Wongfa30f032016-08-03 11:37:10 +1000638 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 1),
Dave Chinner7fd36c42013-08-12 20:49:32 +1000639 XFS_FSB_TO_B(mp, 1));
640}
641
642/*
643 * Removing the attribute fork of a file
644 * the inode being truncated: inode size
645 * the inode's bmap btree: max depth * block size
646 * And the bmap_finish transaction can free the blocks and bmap blocks:
647 * the agf for each of the ags: 4 * sector size
648 * the agfl for each of the ags: 4 * sector size
649 * the super block to reflect the freed blocks: sector size
650 * worst case split in allocation btrees per extent assuming 4 extents:
651 * 4 exts * 2 trees * (2 * max depth - 1) * block size
652 */
653STATIC uint
654xfs_calc_attrinval_reservation(
655 struct xfs_mount *mp)
656{
Dave Chinner23956702013-08-28 16:10:35 +1000657 return MAX((xfs_calc_inode_res(mp, 1) +
Dave Chinner7fd36c42013-08-12 20:49:32 +1000658 xfs_calc_buf_res(XFS_BM_MAXLEVELS(mp, XFS_ATTR_FORK),
659 XFS_FSB_TO_B(mp, 1))),
660 (xfs_calc_buf_res(9, mp->m_sb.sb_sectsize) +
Darrick J. Wongfa30f032016-08-03 11:37:10 +1000661 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 4),
Dave Chinner7fd36c42013-08-12 20:49:32 +1000662 XFS_FSB_TO_B(mp, 1))));
663}
664
665/*
666 * Setting an attribute at mount time.
667 * the inode getting the attribute
668 * the superblock for allocations
669 * the agfs extents are allocated from
670 * the attribute btree * max depth
671 * the inode allocation btree
672 * Since attribute transaction space is dependent on the size of the attribute,
673 * the calculation is done partially at mount time and partially at runtime(see
674 * below).
675 */
676STATIC uint
677xfs_calc_attrsetm_reservation(
678 struct xfs_mount *mp)
679{
680 return XFS_DQUOT_LOGRES(mp) +
Dave Chinner23956702013-08-28 16:10:35 +1000681 xfs_calc_inode_res(mp, 1) +
Dave Chinner7fd36c42013-08-12 20:49:32 +1000682 xfs_calc_buf_res(1, mp->m_sb.sb_sectsize) +
683 xfs_calc_buf_res(XFS_DA_NODE_MAXDEPTH, XFS_FSB_TO_B(mp, 1));
684}
685
686/*
687 * Setting an attribute at runtime, transaction space unit per block.
688 * the superblock for allocations: sector size
689 * the inode bmap btree could join or split: max depth * block size
690 * Since the runtime attribute transaction space is dependent on the total
691 * blocks needed for the 1st bmap, here we calculate out the space unit for
692 * one block so that the caller could figure out the total space according
Jie Liu3d3c8b52013-08-12 20:49:59 +1000693 * to the attibute extent length in blocks by:
694 * ext * M_RES(mp)->tr_attrsetrt.tr_logres
Dave Chinner7fd36c42013-08-12 20:49:32 +1000695 */
696STATIC uint
697xfs_calc_attrsetrt_reservation(
698 struct xfs_mount *mp)
699{
700 return xfs_calc_buf_res(1, mp->m_sb.sb_sectsize) +
701 xfs_calc_buf_res(XFS_BM_MAXLEVELS(mp, XFS_ATTR_FORK),
702 XFS_FSB_TO_B(mp, 1));
703}
704
705/*
706 * Removing an attribute.
707 * the inode: inode size
708 * the attribute btree could join: max depth * block size
709 * the inode bmap btree could join or split: max depth * block size
710 * And the bmap_finish transaction can free the attr blocks freed giving:
711 * the agf for the ag in which the blocks live: 2 * sector size
712 * the agfl for the ag in which the blocks live: 2 * sector size
713 * the superblock for the free block count: sector size
714 * the allocation btrees: 2 exts * 2 trees * (2 * max depth - 1) * block size
715 */
716STATIC uint
717xfs_calc_attrrm_reservation(
718 struct xfs_mount *mp)
719{
720 return XFS_DQUOT_LOGRES(mp) +
Dave Chinner23956702013-08-28 16:10:35 +1000721 MAX((xfs_calc_inode_res(mp, 1) +
Dave Chinner7fd36c42013-08-12 20:49:32 +1000722 xfs_calc_buf_res(XFS_DA_NODE_MAXDEPTH,
723 XFS_FSB_TO_B(mp, 1)) +
724 (uint)XFS_FSB_TO_B(mp,
725 XFS_BM_MAXLEVELS(mp, XFS_ATTR_FORK)) +
726 xfs_calc_buf_res(XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK), 0)),
727 (xfs_calc_buf_res(5, mp->m_sb.sb_sectsize) +
Darrick J. Wongfa30f032016-08-03 11:37:10 +1000728 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 2),
Dave Chinner7fd36c42013-08-12 20:49:32 +1000729 XFS_FSB_TO_B(mp, 1))));
730}
731
732/*
733 * Clearing a bad agino number in an agi hash bucket.
734 */
735STATIC uint
736xfs_calc_clear_agi_bucket_reservation(
737 struct xfs_mount *mp)
738{
739 return xfs_calc_buf_res(1, mp->m_sb.sb_sectsize);
740}
741
742/*
Dave Chinner7fd36c42013-08-12 20:49:32 +1000743 * Adjusting quota limits.
744 * the xfs_disk_dquot_t: sizeof(struct xfs_disk_dquot)
745 */
746STATIC uint
747xfs_calc_qm_setqlim_reservation(
748 struct xfs_mount *mp)
749{
750 return xfs_calc_buf_res(1, sizeof(struct xfs_disk_dquot));
751}
752
753/*
754 * Allocating quota on disk if needed.
Brian Foster410b11a2014-02-07 14:55:54 +1100755 * the write transaction log space for quota file extent allocation
Dave Chinner7fd36c42013-08-12 20:49:32 +1000756 * the unit of quota allocation: one system block size
757 */
758STATIC uint
759xfs_calc_qm_dqalloc_reservation(
760 struct xfs_mount *mp)
761{
Brian Foster410b11a2014-02-07 14:55:54 +1100762 return xfs_calc_write_reservation(mp) +
Dave Chinner7fd36c42013-08-12 20:49:32 +1000763 xfs_calc_buf_res(1,
764 XFS_FSB_TO_B(mp, XFS_DQUOT_CLUSTER_SIZE_FSB) - 1);
765}
766
767/*
768 * Turning off quotas.
769 * the xfs_qoff_logitem_t: sizeof(struct xfs_qoff_logitem) * 2
770 * the superblock for the quota flags: sector size
771 */
772STATIC uint
773xfs_calc_qm_quotaoff_reservation(
774 struct xfs_mount *mp)
775{
776 return sizeof(struct xfs_qoff_logitem) * 2 +
777 xfs_calc_buf_res(1, mp->m_sb.sb_sectsize);
778}
779
780/*
781 * End of turning off quotas.
782 * the xfs_qoff_logitem_t: sizeof(struct xfs_qoff_logitem) * 2
783 */
784STATIC uint
785xfs_calc_qm_quotaoff_end_reservation(
786 struct xfs_mount *mp)
787{
788 return sizeof(struct xfs_qoff_logitem) * 2;
789}
790
791/*
792 * Syncing the incore super block changes to disk.
793 * the super block to reflect the changes: sector size
794 */
795STATIC uint
796xfs_calc_sb_reservation(
797 struct xfs_mount *mp)
798{
799 return xfs_calc_buf_res(1, mp->m_sb.sb_sectsize);
800}
801
802void
803xfs_trans_resv_calc(
804 struct xfs_mount *mp,
805 struct xfs_trans_resv *resp)
806{
Jie Liu0eadd102013-08-12 20:49:56 +1000807 /*
808 * The following transactions are logged in physical format and
809 * require a permanent reservation on space.
810 */
811 resp->tr_write.tr_logres = xfs_calc_write_reservation(mp);
Darrick J. Wong80de4622016-10-03 09:11:47 -0700812 if (xfs_sb_version_hasreflink(&mp->m_sb))
813 resp->tr_write.tr_logcount = XFS_WRITE_LOG_COUNT_REFLINK;
814 else
815 resp->tr_write.tr_logcount = XFS_WRITE_LOG_COUNT;
Jie Liu0eadd102013-08-12 20:49:56 +1000816 resp->tr_write.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
817
818 resp->tr_itruncate.tr_logres = xfs_calc_itruncate_reservation(mp);
Darrick J. Wong80de4622016-10-03 09:11:47 -0700819 if (xfs_sb_version_hasreflink(&mp->m_sb))
820 resp->tr_itruncate.tr_logcount =
821 XFS_ITRUNCATE_LOG_COUNT_REFLINK;
822 else
823 resp->tr_itruncate.tr_logcount = XFS_ITRUNCATE_LOG_COUNT;
Jie Liu0eadd102013-08-12 20:49:56 +1000824 resp->tr_itruncate.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
825
826 resp->tr_rename.tr_logres = xfs_calc_rename_reservation(mp);
827 resp->tr_rename.tr_logcount = XFS_RENAME_LOG_COUNT;
828 resp->tr_rename.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
829
830 resp->tr_link.tr_logres = xfs_calc_link_reservation(mp);
831 resp->tr_link.tr_logcount = XFS_LINK_LOG_COUNT;
832 resp->tr_link.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
833
834 resp->tr_remove.tr_logres = xfs_calc_remove_reservation(mp);
835 resp->tr_remove.tr_logcount = XFS_REMOVE_LOG_COUNT;
836 resp->tr_remove.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
837
838 resp->tr_symlink.tr_logres = xfs_calc_symlink_reservation(mp);
839 resp->tr_symlink.tr_logcount = XFS_SYMLINK_LOG_COUNT;
840 resp->tr_symlink.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
841
842 resp->tr_create.tr_logres = xfs_calc_create_reservation(mp);
843 resp->tr_create.tr_logcount = XFS_CREATE_LOG_COUNT;
844 resp->tr_create.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
845
Zhi Yong Wu99b64362013-12-18 08:22:40 +0800846 resp->tr_create_tmpfile.tr_logres =
847 xfs_calc_create_tmpfile_reservation(mp);
848 resp->tr_create_tmpfile.tr_logcount = XFS_CREATE_TMPFILE_LOG_COUNT;
849 resp->tr_create_tmpfile.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
850
Jie Liu0eadd102013-08-12 20:49:56 +1000851 resp->tr_mkdir.tr_logres = xfs_calc_mkdir_reservation(mp);
852 resp->tr_mkdir.tr_logcount = XFS_MKDIR_LOG_COUNT;
853 resp->tr_mkdir.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
854
855 resp->tr_ifree.tr_logres = xfs_calc_ifree_reservation(mp);
856 resp->tr_ifree.tr_logcount = XFS_INACTIVE_LOG_COUNT;
857 resp->tr_ifree.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
858
859 resp->tr_addafork.tr_logres = xfs_calc_addafork_reservation(mp);
860 resp->tr_addafork.tr_logcount = XFS_ADDAFORK_LOG_COUNT;
861 resp->tr_addafork.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
862
863 resp->tr_attrinval.tr_logres = xfs_calc_attrinval_reservation(mp);
864 resp->tr_attrinval.tr_logcount = XFS_ATTRINVAL_LOG_COUNT;
865 resp->tr_attrinval.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
866
867 resp->tr_attrsetm.tr_logres = xfs_calc_attrsetm_reservation(mp);
868 resp->tr_attrsetm.tr_logcount = XFS_ATTRSET_LOG_COUNT;
869 resp->tr_attrsetm.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
870
871 resp->tr_attrrm.tr_logres = xfs_calc_attrrm_reservation(mp);
872 resp->tr_attrrm.tr_logcount = XFS_ATTRRM_LOG_COUNT;
873 resp->tr_attrrm.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
874
875 resp->tr_growrtalloc.tr_logres = xfs_calc_growrtalloc_reservation(mp);
876 resp->tr_growrtalloc.tr_logcount = XFS_DEFAULT_PERM_LOG_COUNT;
877 resp->tr_growrtalloc.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
878
879 resp->tr_qm_dqalloc.tr_logres = xfs_calc_qm_dqalloc_reservation(mp);
Darrick J. Wong80de4622016-10-03 09:11:47 -0700880 if (xfs_sb_version_hasreflink(&mp->m_sb))
881 resp->tr_qm_dqalloc.tr_logcount = XFS_WRITE_LOG_COUNT_REFLINK;
882 else
883 resp->tr_qm_dqalloc.tr_logcount = XFS_WRITE_LOG_COUNT;
Jie Liu0eadd102013-08-12 20:49:56 +1000884 resp->tr_qm_dqalloc.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
885
886 /*
887 * The following transactions are logged in logical format with
888 * a default log count.
889 */
Jie Liu0eadd102013-08-12 20:49:56 +1000890 resp->tr_qm_setqlim.tr_logres = xfs_calc_qm_setqlim_reservation(mp);
891 resp->tr_qm_setqlim.tr_logcount = XFS_DEFAULT_LOG_COUNT;
892
893 resp->tr_qm_quotaoff.tr_logres = xfs_calc_qm_quotaoff_reservation(mp);
894 resp->tr_qm_quotaoff.tr_logcount = XFS_DEFAULT_LOG_COUNT;
895
896 resp->tr_qm_equotaoff.tr_logres =
897 xfs_calc_qm_quotaoff_end_reservation(mp);
898 resp->tr_qm_equotaoff.tr_logcount = XFS_DEFAULT_LOG_COUNT;
899
900 resp->tr_sb.tr_logres = xfs_calc_sb_reservation(mp);
901 resp->tr_sb.tr_logcount = XFS_DEFAULT_LOG_COUNT;
902
903 /* The following transaction are logged in logical format */
904 resp->tr_ichange.tr_logres = xfs_calc_ichange_reservation(mp);
905 resp->tr_growdata.tr_logres = xfs_calc_growdata_reservation(mp);
Jie Liu20996c92013-08-12 20:49:57 +1000906 resp->tr_fsyncts.tr_logres = xfs_calc_swrite_reservation(mp);
Jie Liu0eadd102013-08-12 20:49:56 +1000907 resp->tr_writeid.tr_logres = xfs_calc_writeid_reservation(mp);
908 resp->tr_attrsetrt.tr_logres = xfs_calc_attrsetrt_reservation(mp);
909 resp->tr_clearagi.tr_logres = xfs_calc_clear_agi_bucket_reservation(mp);
910 resp->tr_growrtzero.tr_logres = xfs_calc_growrtzero_reservation(mp);
911 resp->tr_growrtfree.tr_logres = xfs_calc_growrtfree_reservation(mp);
Dave Chinner7fd36c42013-08-12 20:49:32 +1000912}