aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_trans_resv.c
diff options
context:
space:
mode:
authorDave Chinner <david@fromorbit.com>2014-03-13 04:14:43 -0400
committerDave Chinner <david@fromorbit.com>2014-03-13 04:14:43 -0400
commitfe986f9d88ab8079c91669b7f175081f15491a80 (patch)
tree73be54e2c5378750dee0ebc0720af5143d2c4dc6 /fs/xfs/xfs_trans_resv.c
parent5f44e4c185ec5a4a438841cbd4983d0c4a106a4a (diff)
parentab29743117f9f4c22ac44c13c1647fb24fb2bafe (diff)
Merge branch 'xfs-O_TMPFILE-support' into for-next
Conflicts: fs/xfs/xfs_trans_resv.c - fix for XFS_INODE_CLUSTER_SIZE macro removal
Diffstat (limited to 'fs/xfs/xfs_trans_resv.c')
-rw-r--r--fs/xfs/xfs_trans_resv.c54
1 files changed, 50 insertions, 4 deletions
diff --git a/fs/xfs/xfs_trans_resv.c b/fs/xfs/xfs_trans_resv.c
index d2c8e4a6ee2a..ae368165244d 100644
--- a/fs/xfs/xfs_trans_resv.c
+++ b/fs/xfs/xfs_trans_resv.c
@@ -212,6 +212,19 @@ xfs_calc_rename_reservation(
212} 212}
213 213
214/* 214/*
215 * For removing an inode from unlinked list at first, we can modify:
216 * the agi hash list and counters: sector size
217 * the on disk inode before ours in the agi hash list: inode cluster size
218 */
219STATIC uint
220xfs_calc_iunlink_remove_reservation(
221 struct xfs_mount *mp)
222{
223 return xfs_calc_buf_res(1, mp->m_sb.sb_sectsize) +
224 max_t(uint, XFS_FSB_TO_B(mp, 1), mp->m_inode_cluster_size);
225}
226
227/*
215 * For creating a link to an inode: 228 * For creating a link to an inode:
216 * the parent directory inode: inode size 229 * the parent directory inode: inode size
217 * the linked inode: inode size 230 * the linked inode: inode size
@@ -228,6 +241,7 @@ xfs_calc_link_reservation(
228 struct xfs_mount *mp) 241 struct xfs_mount *mp)
229{ 242{
230 return XFS_DQUOT_LOGRES(mp) + 243 return XFS_DQUOT_LOGRES(mp) +
244 xfs_calc_iunlink_remove_reservation(mp) +
231 MAX((xfs_calc_inode_res(mp, 2) + 245 MAX((xfs_calc_inode_res(mp, 2) +
232 xfs_calc_buf_res(XFS_DIROP_LOG_COUNT(mp), 246 xfs_calc_buf_res(XFS_DIROP_LOG_COUNT(mp),
233 XFS_FSB_TO_B(mp, 1))), 247 XFS_FSB_TO_B(mp, 1))),
@@ -237,6 +251,18 @@ xfs_calc_link_reservation(
237} 251}
238 252
239/* 253/*
254 * For adding an inode to unlinked list we can modify:
255 * the agi hash list: sector size
256 * the unlinked inode: inode size
257 */
258STATIC uint
259xfs_calc_iunlink_add_reservation(xfs_mount_t *mp)
260{
261 return xfs_calc_buf_res(1, mp->m_sb.sb_sectsize) +
262 xfs_calc_inode_res(mp, 1);
263}
264
265/*
240 * For removing a directory entry we can modify: 266 * For removing a directory entry we can modify:
241 * the parent directory inode: inode size 267 * the parent directory inode: inode size
242 * the removed inode: inode size 268 * the removed inode: inode size
@@ -253,10 +279,11 @@ xfs_calc_remove_reservation(
253 struct xfs_mount *mp) 279 struct xfs_mount *mp)
254{ 280{
255 return XFS_DQUOT_LOGRES(mp) + 281 return XFS_DQUOT_LOGRES(mp) +
256 MAX((xfs_calc_inode_res(mp, 2) + 282 xfs_calc_iunlink_add_reservation(mp) +
283 MAX((xfs_calc_inode_res(mp, 1) +
257 xfs_calc_buf_res(XFS_DIROP_LOG_COUNT(mp), 284 xfs_calc_buf_res(XFS_DIROP_LOG_COUNT(mp),
258 XFS_FSB_TO_B(mp, 1))), 285 XFS_FSB_TO_B(mp, 1))),
259 (xfs_calc_buf_res(5, mp->m_sb.sb_sectsize) + 286 (xfs_calc_buf_res(4, mp->m_sb.sb_sectsize) +
260 xfs_calc_buf_res(XFS_ALLOCFREE_LOG_COUNT(mp, 2), 287 xfs_calc_buf_res(XFS_ALLOCFREE_LOG_COUNT(mp, 2),
261 XFS_FSB_TO_B(mp, 1)))); 288 XFS_FSB_TO_B(mp, 1))));
262} 289}
@@ -351,6 +378,20 @@ xfs_calc_create_reservation(
351 378
352} 379}
353 380
381STATIC uint
382xfs_calc_create_tmpfile_reservation(
383 struct xfs_mount *mp)
384{
385 uint res = XFS_DQUOT_LOGRES(mp);
386
387 if (xfs_sb_version_hascrc(&mp->m_sb))
388 res += xfs_calc_icreate_resv_alloc(mp);
389 else
390 res += xfs_calc_create_resv_alloc(mp);
391
392 return res + xfs_calc_iunlink_add_reservation(mp);
393}
394
354/* 395/*
355 * Making a new directory is the same as creating a new file. 396 * Making a new directory is the same as creating a new file.
356 */ 397 */
@@ -391,9 +432,9 @@ xfs_calc_ifree_reservation(
391{ 432{
392 return XFS_DQUOT_LOGRES(mp) + 433 return XFS_DQUOT_LOGRES(mp) +
393 xfs_calc_inode_res(mp, 1) + 434 xfs_calc_inode_res(mp, 1) +
394 xfs_calc_buf_res(2, mp->m_sb.sb_sectsize) + 435 xfs_calc_buf_res(1, mp->m_sb.sb_sectsize) +
395 xfs_calc_buf_res(1, XFS_FSB_TO_B(mp, 1)) + 436 xfs_calc_buf_res(1, XFS_FSB_TO_B(mp, 1)) +
396 max_t(uint, XFS_FSB_TO_B(mp, 1), mp->m_inode_cluster_size) + 437 xfs_calc_iunlink_remove_reservation(mp) +
397 xfs_calc_buf_res(1, 0) + 438 xfs_calc_buf_res(1, 0) +
398 xfs_calc_buf_res(2 + mp->m_ialloc_blks + 439 xfs_calc_buf_res(2 + mp->m_ialloc_blks +
399 mp->m_in_maxlevels, 0) + 440 mp->m_in_maxlevels, 0) +
@@ -736,6 +777,11 @@ xfs_trans_resv_calc(
736 resp->tr_create.tr_logcount = XFS_CREATE_LOG_COUNT; 777 resp->tr_create.tr_logcount = XFS_CREATE_LOG_COUNT;
737 resp->tr_create.tr_logflags |= XFS_TRANS_PERM_LOG_RES; 778 resp->tr_create.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
738 779
780 resp->tr_create_tmpfile.tr_logres =
781 xfs_calc_create_tmpfile_reservation(mp);
782 resp->tr_create_tmpfile.tr_logcount = XFS_CREATE_TMPFILE_LOG_COUNT;
783 resp->tr_create_tmpfile.tr_logflags |= XFS_TRANS_PERM_LOG_RES;
784
739 resp->tr_mkdir.tr_logres = xfs_calc_mkdir_reservation(mp); 785 resp->tr_mkdir.tr_logres = xfs_calc_mkdir_reservation(mp);
740 resp->tr_mkdir.tr_logcount = XFS_MKDIR_LOG_COUNT; 786 resp->tr_mkdir.tr_logcount = XFS_MKDIR_LOG_COUNT;
741 resp->tr_mkdir.tr_logflags |= XFS_TRANS_PERM_LOG_RES; 787 resp->tr_mkdir.tr_logflags |= XFS_TRANS_PERM_LOG_RES;