aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorJie Liu <jeff.liu@oracle.com>2013-08-12 06:49:59 -0400
committerBen Myers <bpm@sgi.com>2013-08-12 18:47:34 -0400
commit3d3c8b5222b92447bffaa4127ee18c757f32a460 (patch)
tree250f3b61679231944b5272d18d17e6ceabfc62d1 /fs/xfs
parent783cb6d172358892d6af394ebe2876bcbfcc6499 (diff)
xfs: refactor xfs_trans_reserve() interface
With the new xfs_trans_res structure has been introduced, the log reservation size, log count as well as log flags are pre-initialized at mount time. So it's time to refine xfs_trans_reserve() interface to be more neat. Also, introduce a new helper M_RES() to return a pointer to the mp->m_resv structure to simplify the input. Signed-off-by: Jie Liu <jeff.liu@oracle.com> Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Mark Tinguely <tinguely@sgi.com> Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/xfs_aops.c2
-rw-r--r--fs/xfs/xfs_attr.c33
-rw-r--r--fs/xfs/xfs_attr_inactive.c5
-rw-r--r--fs/xfs/xfs_bmap.c4
-rw-r--r--fs/xfs/xfs_bmap_util.c42
-rw-r--r--fs/xfs/xfs_dquot.c6
-rw-r--r--fs/xfs/xfs_fsops.c8
-rw-r--r--fs/xfs/xfs_inode.c88
-rw-r--r--fs/xfs/xfs_ioctl.c4
-rw-r--r--fs/xfs/xfs_iomap.c18
-rw-r--r--fs/xfs/xfs_iops.c8
-rw-r--r--fs/xfs/xfs_log_recover.c5
-rw-r--r--fs/xfs/xfs_mount.c9
-rw-r--r--fs/xfs/xfs_qm.c11
-rw-r--r--fs/xfs/xfs_qm_syscalls.c13
-rw-r--r--fs/xfs/xfs_rtalloc.c17
-rw-r--r--fs/xfs/xfs_symlink.c10
-rw-r--r--fs/xfs/xfs_trans.c51
-rw-r--r--fs/xfs/xfs_trans.h3
-rw-r--r--fs/xfs/xfs_trans_resv.c7
-rw-r--r--fs/xfs/xfs_trans_resv.h3
21 files changed, 150 insertions, 197 deletions
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index a82c83707324..1269434ceec1 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -116,7 +116,7 @@ xfs_setfilesize_trans_alloc(
116 116
117 tp = xfs_trans_alloc(mp, XFS_TRANS_FSYNC_TS); 117 tp = xfs_trans_alloc(mp, XFS_TRANS_FSYNC_TS);
118 118
119 error = xfs_trans_reserve(tp, 0, XFS_FSYNC_TS_LOG_RES(mp), 0, 0, 0); 119 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_fsyncts, 0, 0);
120 if (error) { 120 if (error) {
121 xfs_trans_cancel(tp, 0); 121 xfs_trans_cancel(tp, 0);
122 return error; 122 return error;
diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c
index 046cf3d7f52f..176dbb66282d 100644
--- a/fs/xfs/xfs_attr.c
+++ b/fs/xfs/xfs_attr.c
@@ -226,13 +226,14 @@ xfs_attr_set_int(
226 int valuelen, 226 int valuelen,
227 int flags) 227 int flags)
228{ 228{
229 xfs_da_args_t args; 229 xfs_da_args_t args;
230 xfs_fsblock_t firstblock; 230 xfs_fsblock_t firstblock;
231 xfs_bmap_free_t flist; 231 xfs_bmap_free_t flist;
232 int error, err2, committed; 232 int error, err2, committed;
233 xfs_mount_t *mp = dp->i_mount; 233 struct xfs_mount *mp = dp->i_mount;
234 int rsvd = (flags & ATTR_ROOT) != 0; 234 struct xfs_trans_res tres;
235 int local; 235 int rsvd = (flags & ATTR_ROOT) != 0;
236 int local;
236 237
237 /* 238 /*
238 * Attach the dquots to the inode. 239 * Attach the dquots to the inode.
@@ -292,11 +293,11 @@ xfs_attr_set_int(
292 if (rsvd) 293 if (rsvd)
293 args.trans->t_flags |= XFS_TRANS_RESERVE; 294 args.trans->t_flags |= XFS_TRANS_RESERVE;
294 295
295 error = xfs_trans_reserve(args.trans, args.total, 296 tres.tr_logres = M_RES(mp)->tr_attrsetm.tr_logres +
296 XFS_ATTRSETM_LOG_RES(mp) + 297 M_RES(mp)->tr_attrsetrt.tr_logres * args.total;
297 XFS_ATTRSETRT_LOG_RES(mp) * args.total, 298 tres.tr_logcount = XFS_ATTRSET_LOG_COUNT;
298 0, XFS_TRANS_PERM_LOG_RES, 299 tres.tr_logflags = XFS_TRANS_PERM_LOG_RES;
299 XFS_ATTRSET_LOG_COUNT); 300 error = xfs_trans_reserve(args.trans, &tres, args.total, 0);
300 if (error) { 301 if (error) {
301 xfs_trans_cancel(args.trans, 0); 302 xfs_trans_cancel(args.trans, 0);
302 return(error); 303 return(error);
@@ -516,11 +517,9 @@ xfs_attr_remove_int(xfs_inode_t *dp, struct xfs_name *name, int flags)
516 if (flags & ATTR_ROOT) 517 if (flags & ATTR_ROOT)
517 args.trans->t_flags |= XFS_TRANS_RESERVE; 518 args.trans->t_flags |= XFS_TRANS_RESERVE;
518 519
519 if ((error = xfs_trans_reserve(args.trans, 520 error = xfs_trans_reserve(args.trans, &M_RES(mp)->tr_attrrm,
520 XFS_ATTRRM_SPACE_RES(mp), 521 XFS_ATTRRM_SPACE_RES(mp), 0);
521 XFS_ATTRRM_LOG_RES(mp), 522 if (error) {
522 0, XFS_TRANS_PERM_LOG_RES,
523 XFS_ATTRRM_LOG_COUNT))) {
524 xfs_trans_cancel(args.trans, 0); 523 xfs_trans_cancel(args.trans, 0);
525 return(error); 524 return(error);
526 } 525 }
diff --git a/fs/xfs/xfs_attr_inactive.c b/fs/xfs/xfs_attr_inactive.c
index ace95e791311..bb24b07cbedb 100644
--- a/fs/xfs/xfs_attr_inactive.c
+++ b/fs/xfs/xfs_attr_inactive.c
@@ -412,9 +412,8 @@ xfs_attr_inactive(xfs_inode_t *dp)
412 * the log. 412 * the log.
413 */ 413 */
414 trans = xfs_trans_alloc(mp, XFS_TRANS_ATTRINVAL); 414 trans = xfs_trans_alloc(mp, XFS_TRANS_ATTRINVAL);
415 if ((error = xfs_trans_reserve(trans, 0, XFS_ATTRINVAL_LOG_RES(mp), 0, 415 error = xfs_trans_reserve(trans, &M_RES(mp)->tr_attrinval, 0, 0);
416 XFS_TRANS_PERM_LOG_RES, 416 if (error) {
417 XFS_ATTRINVAL_LOG_COUNT))) {
418 xfs_trans_cancel(trans, 0); 417 xfs_trans_cancel(trans, 0);
419 return(error); 418 return(error);
420 } 419 }
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
index 51e07e7a0092..6c2d89eedb83 100644
--- a/fs/xfs/xfs_bmap.c
+++ b/fs/xfs/xfs_bmap.c
@@ -1148,8 +1148,8 @@ xfs_bmap_add_attrfork(
1148 blks = XFS_ADDAFORK_SPACE_RES(mp); 1148 blks = XFS_ADDAFORK_SPACE_RES(mp);
1149 if (rsvd) 1149 if (rsvd)
1150 tp->t_flags |= XFS_TRANS_RESERVE; 1150 tp->t_flags |= XFS_TRANS_RESERVE;
1151 if ((error = xfs_trans_reserve(tp, blks, XFS_ADDAFORK_LOG_RES(mp), 0, 1151 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_addafork, blks, 0);
1152 XFS_TRANS_PERM_LOG_RES, XFS_ADDAFORK_LOG_COUNT))) 1152 if (error)
1153 goto error0; 1153 goto error0;
1154 xfs_ilock(ip, XFS_ILOCK_EXCL); 1154 xfs_ilock(ip, XFS_ILOCK_EXCL);
1155 error = xfs_trans_reserve_quota_nblks(tp, ip, blks, 0, rsvd ? 1155 error = xfs_trans_reserve_quota_nblks(tp, ip, blks, 0, rsvd ?
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c
index b5232d094418..cc2ab9b776b7 100644
--- a/fs/xfs/xfs_bmap_util.c
+++ b/fs/xfs/xfs_bmap_util.c
@@ -78,8 +78,7 @@ xfs_bmap_finish(
78 xfs_efi_log_item_t *efi; /* extent free intention */ 78 xfs_efi_log_item_t *efi; /* extent free intention */
79 int error; /* error return value */ 79 int error; /* error return value */
80 xfs_bmap_free_item_t *free; /* free extent item */ 80 xfs_bmap_free_item_t *free; /* free extent item */
81 unsigned int logres; /* new log reservation */ 81 struct xfs_trans_res tres; /* new log reservation */
82 unsigned int logcount; /* new log count */
83 xfs_mount_t *mp; /* filesystem mount structure */ 82 xfs_mount_t *mp; /* filesystem mount structure */
84 xfs_bmap_free_item_t *next; /* next item on free list */ 83 xfs_bmap_free_item_t *next; /* next item on free list */
85 xfs_trans_t *ntp; /* new transaction pointer */ 84 xfs_trans_t *ntp; /* new transaction pointer */
@@ -94,8 +93,10 @@ xfs_bmap_finish(
94 for (free = flist->xbf_first; free; free = free->xbfi_next) 93 for (free = flist->xbf_first; free; free = free->xbfi_next)
95 xfs_trans_log_efi_extent(ntp, efi, free->xbfi_startblock, 94 xfs_trans_log_efi_extent(ntp, efi, free->xbfi_startblock,
96 free->xbfi_blockcount); 95 free->xbfi_blockcount);
97 logres = ntp->t_log_res; 96
98 logcount = ntp->t_log_count; 97 tres.tr_logres = ntp->t_log_res;
98 tres.tr_logcount = ntp->t_log_count;
99 tres.tr_logflags = XFS_TRANS_PERM_LOG_RES;
99 ntp = xfs_trans_dup(*tp); 100 ntp = xfs_trans_dup(*tp);
100 error = xfs_trans_commit(*tp, 0); 101 error = xfs_trans_commit(*tp, 0);
101 *tp = ntp; 102 *tp = ntp;
@@ -113,8 +114,8 @@ xfs_bmap_finish(
113 */ 114 */
114 xfs_log_ticket_put(ntp->t_ticket); 115 xfs_log_ticket_put(ntp->t_ticket);
115 116
116 if ((error = xfs_trans_reserve(ntp, 0, logres, 0, XFS_TRANS_PERM_LOG_RES, 117 error = xfs_trans_reserve(ntp, &tres, 0, 0);
117 logcount))) 118 if (error)
118 return error; 119 return error;
119 efd = xfs_trans_get_efd(ntp, efi, flist->xbf_count); 120 efd = xfs_trans_get_efd(ntp, efi, flist->xbf_count);
120 for (free = flist->xbf_first; free != NULL; free = next) { 121 for (free = flist->xbf_first; free != NULL; free = next) {
@@ -929,10 +930,7 @@ xfs_free_eofblocks(
929 } 930 }
930 } 931 }
931 932
932 error = xfs_trans_reserve(tp, 0, 933 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_itruncate, 0, 0);
933 XFS_ITRUNCATE_LOG_RES(mp),
934 0, XFS_TRANS_PERM_LOG_RES,
935 XFS_ITRUNCATE_LOG_COUNT);
936 if (error) { 934 if (error) {
937 ASSERT(XFS_FORCED_SHUTDOWN(mp)); 935 ASSERT(XFS_FORCED_SHUTDOWN(mp));
938 xfs_trans_cancel(tp, 0); 936 xfs_trans_cancel(tp, 0);
@@ -1085,10 +1083,8 @@ xfs_alloc_file_space(
1085 * Allocate and setup the transaction. 1083 * Allocate and setup the transaction.
1086 */ 1084 */
1087 tp = xfs_trans_alloc(mp, XFS_TRANS_DIOSTRAT); 1085 tp = xfs_trans_alloc(mp, XFS_TRANS_DIOSTRAT);
1088 error = xfs_trans_reserve(tp, resblks, 1086 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_write,
1089 XFS_WRITE_LOG_RES(mp), resrtextents, 1087 resblks, resrtextents);
1090 XFS_TRANS_PERM_LOG_RES,
1091 XFS_WRITE_LOG_COUNT);
1092 /* 1088 /*
1093 * Check for running out of space 1089 * Check for running out of space
1094 */ 1090 */
@@ -1378,12 +1374,7 @@ xfs_free_file_space(
1378 */ 1374 */
1379 tp = xfs_trans_alloc(mp, XFS_TRANS_DIOSTRAT); 1375 tp = xfs_trans_alloc(mp, XFS_TRANS_DIOSTRAT);
1380 tp->t_flags |= XFS_TRANS_RESERVE; 1376 tp->t_flags |= XFS_TRANS_RESERVE;
1381 error = xfs_trans_reserve(tp, 1377 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_write, resblks, 0);
1382 resblks,
1383 XFS_WRITE_LOG_RES(mp),
1384 0,
1385 XFS_TRANS_PERM_LOG_RES,
1386 XFS_WRITE_LOG_COUNT);
1387 1378
1388 /* 1379 /*
1389 * check for running out of space 1380 * check for running out of space
@@ -1657,10 +1648,8 @@ xfs_change_file_space(
1657 * update the inode timestamp, mode, and prealloc flag bits 1648 * update the inode timestamp, mode, and prealloc flag bits
1658 */ 1649 */
1659 tp = xfs_trans_alloc(mp, XFS_TRANS_WRITEID); 1650 tp = xfs_trans_alloc(mp, XFS_TRANS_WRITEID);
1660 1651 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_writeid, 0, 0);
1661 if ((error = xfs_trans_reserve(tp, 0, XFS_WRITEID_LOG_RES(mp), 1652 if (error) {
1662 0, 0, 0))) {
1663 /* ASSERT(0); */
1664 xfs_trans_cancel(tp, 0); 1653 xfs_trans_cancel(tp, 0);
1665 return error; 1654 return error;
1666 } 1655 }
@@ -1905,9 +1894,8 @@ xfs_swap_extents(
1905 truncate_pagecache_range(VFS_I(ip), 0, -1); 1894 truncate_pagecache_range(VFS_I(ip), 0, -1);
1906 1895
1907 tp = xfs_trans_alloc(mp, XFS_TRANS_SWAPEXT); 1896 tp = xfs_trans_alloc(mp, XFS_TRANS_SWAPEXT);
1908 if ((error = xfs_trans_reserve(tp, 0, 1897 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_ichange, 0, 0);
1909 XFS_ICHANGE_LOG_RES(mp), 0, 1898 if (error) {
1910 0, 0))) {
1911 xfs_iunlock(ip, XFS_IOLOCK_EXCL); 1899 xfs_iunlock(ip, XFS_IOLOCK_EXCL);
1912 xfs_iunlock(tip, XFS_IOLOCK_EXCL); 1900 xfs_iunlock(tip, XFS_IOLOCK_EXCL);
1913 xfs_trans_cancel(tp, 0); 1901 xfs_trans_cancel(tp, 0);
diff --git a/fs/xfs/xfs_dquot.c b/fs/xfs/xfs_dquot.c
index e90e123b0085..251c66632e5e 100644
--- a/fs/xfs/xfs_dquot.c
+++ b/fs/xfs/xfs_dquot.c
@@ -712,10 +712,8 @@ xfs_qm_dqread(
712 712
713 if (flags & XFS_QMOPT_DQALLOC) { 713 if (flags & XFS_QMOPT_DQALLOC) {
714 tp = xfs_trans_alloc(mp, XFS_TRANS_QM_DQALLOC); 714 tp = xfs_trans_alloc(mp, XFS_TRANS_QM_DQALLOC);
715 error = xfs_trans_reserve(tp, XFS_QM_DQALLOC_SPACE_RES(mp), 715 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_attrsetm,
716 XFS_QM_DQALLOC_LOG_RES(mp), 0, 716 XFS_QM_DQALLOC_SPACE_RES(mp), 0);
717 XFS_TRANS_PERM_LOG_RES,
718 XFS_WRITE_LOG_COUNT);
719 if (error) 717 if (error)
720 goto error1; 718 goto error1;
721 cancelflags = XFS_TRANS_RELEASE_LOG_RES; 719 cancelflags = XFS_TRANS_RELEASE_LOG_RES;
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
index 614eb0cc3608..e64ee5288b86 100644
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -203,8 +203,9 @@ xfs_growfs_data_private(
203 203
204 tp = xfs_trans_alloc(mp, XFS_TRANS_GROWFS); 204 tp = xfs_trans_alloc(mp, XFS_TRANS_GROWFS);
205 tp->t_flags |= XFS_TRANS_RESERVE; 205 tp->t_flags |= XFS_TRANS_RESERVE;
206 if ((error = xfs_trans_reserve(tp, XFS_GROWFS_SPACE_RES(mp), 206 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_growdata,
207 XFS_GROWDATA_LOG_RES(mp), 0, 0, 0))) { 207 XFS_GROWFS_SPACE_RES(mp), 0);
208 if (error) {
208 xfs_trans_cancel(tp, 0); 209 xfs_trans_cancel(tp, 0);
209 return error; 210 return error;
210 } 211 }
@@ -739,8 +740,7 @@ xfs_fs_log_dummy(
739 int error; 740 int error;
740 741
741 tp = _xfs_trans_alloc(mp, XFS_TRANS_DUMMY1, KM_SLEEP); 742 tp = _xfs_trans_alloc(mp, XFS_TRANS_DUMMY1, KM_SLEEP);
742 error = xfs_trans_reserve(tp, 0, XFS_SB_LOG_RES(mp), 0, 0, 743 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_sb, 0, 0);
743 XFS_DEFAULT_LOG_COUNT);
744 if (error) { 744 if (error) {
745 xfs_trans_cancel(tp, 0); 745 xfs_trans_cancel(tp, 0);
746 return error; 746 return error;
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index e83d3af3dfd4..2f41a1a2f888 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -892,8 +892,6 @@ xfs_dir_ialloc(
892 xfs_inode_t *ip; 892 xfs_inode_t *ip;
893 xfs_buf_t *ialloc_context = NULL; 893 xfs_buf_t *ialloc_context = NULL;
894 int code; 894 int code;
895 uint log_res;
896 uint log_count;
897 void *dqinfo; 895 void *dqinfo;
898 uint tflags; 896 uint tflags;
899 897
@@ -939,6 +937,8 @@ xfs_dir_ialloc(
939 * to succeed the second time. 937 * to succeed the second time.
940 */ 938 */
941 if (ialloc_context) { 939 if (ialloc_context) {
940 struct xfs_trans_res tres;
941
942 /* 942 /*
943 * Normally, xfs_trans_commit releases all the locks. 943 * Normally, xfs_trans_commit releases all the locks.
944 * We call bhold to hang on to the ialloc_context across 944 * We call bhold to hang on to the ialloc_context across
@@ -951,8 +951,8 @@ xfs_dir_ialloc(
951 * Save the log reservation so we can use 951 * Save the log reservation so we can use
952 * them in the next transaction. 952 * them in the next transaction.
953 */ 953 */
954 log_res = xfs_trans_get_log_res(tp); 954 tres.tr_logres = xfs_trans_get_log_res(tp);
955 log_count = xfs_trans_get_log_count(tp); 955 tres.tr_logcount = xfs_trans_get_log_count(tp);
956 956
957 /* 957 /*
958 * We want the quota changes to be associated with the next 958 * We want the quota changes to be associated with the next
@@ -995,8 +995,9 @@ xfs_dir_ialloc(
995 * reference that we gained in xfs_trans_dup() 995 * reference that we gained in xfs_trans_dup()
996 */ 996 */
997 xfs_log_ticket_put(tp->t_ticket); 997 xfs_log_ticket_put(tp->t_ticket);
998 code = xfs_trans_reserve(tp, 0, log_res, 0, 998 tres.tr_logflags = XFS_TRANS_PERM_LOG_RES;
999 XFS_TRANS_PERM_LOG_RES, log_count); 999 code = xfs_trans_reserve(tp, &tres, 0, 0);
1000
1000 /* 1001 /*
1001 * Re-attach the quota info that we detached from prev trx. 1002 * Re-attach the quota info that we detached from prev trx.
1002 */ 1003 */
@@ -1161,9 +1162,8 @@ xfs_create(
1161 struct xfs_dquot *udqp = NULL; 1162 struct xfs_dquot *udqp = NULL;
1162 struct xfs_dquot *gdqp = NULL; 1163 struct xfs_dquot *gdqp = NULL;
1163 struct xfs_dquot *pdqp = NULL; 1164 struct xfs_dquot *pdqp = NULL;
1165 struct xfs_trans_res tres;
1164 uint resblks; 1166 uint resblks;
1165 uint log_res;
1166 uint log_count;
1167 1167
1168 trace_xfs_create(dp, name); 1168 trace_xfs_create(dp, name);
1169 1169
@@ -1187,13 +1187,13 @@ xfs_create(
1187 if (is_dir) { 1187 if (is_dir) {
1188 rdev = 0; 1188 rdev = 0;
1189 resblks = XFS_MKDIR_SPACE_RES(mp, name->len); 1189 resblks = XFS_MKDIR_SPACE_RES(mp, name->len);
1190 log_res = XFS_MKDIR_LOG_RES(mp); 1190 tres.tr_logres = M_RES(mp)->tr_mkdir.tr_logres;
1191 log_count = XFS_MKDIR_LOG_COUNT; 1191 tres.tr_logcount = XFS_MKDIR_LOG_COUNT;
1192 tp = xfs_trans_alloc(mp, XFS_TRANS_MKDIR); 1192 tp = xfs_trans_alloc(mp, XFS_TRANS_MKDIR);
1193 } else { 1193 } else {
1194 resblks = XFS_CREATE_SPACE_RES(mp, name->len); 1194 resblks = XFS_CREATE_SPACE_RES(mp, name->len);
1195 log_res = XFS_CREATE_LOG_RES(mp); 1195 tres.tr_logres = M_RES(mp)->tr_create.tr_logres;
1196 log_count = XFS_CREATE_LOG_COUNT; 1196 tres.tr_logcount = XFS_CREATE_LOG_COUNT;
1197 tp = xfs_trans_alloc(mp, XFS_TRANS_CREATE); 1197 tp = xfs_trans_alloc(mp, XFS_TRANS_CREATE);
1198 } 1198 }
1199 1199
@@ -1205,19 +1205,17 @@ xfs_create(
1205 * the case we'll drop the one we have and get a more 1205 * the case we'll drop the one we have and get a more
1206 * appropriate transaction later. 1206 * appropriate transaction later.
1207 */ 1207 */
1208 error = xfs_trans_reserve(tp, resblks, log_res, 0, 1208 tres.tr_logflags = XFS_TRANS_PERM_LOG_RES;
1209 XFS_TRANS_PERM_LOG_RES, log_count); 1209 error = xfs_trans_reserve(tp, &tres, resblks, 0);
1210 if (error == ENOSPC) { 1210 if (error == ENOSPC) {
1211 /* flush outstanding delalloc blocks and retry */ 1211 /* flush outstanding delalloc blocks and retry */
1212 xfs_flush_inodes(mp); 1212 xfs_flush_inodes(mp);
1213 error = xfs_trans_reserve(tp, resblks, log_res, 0, 1213 error = xfs_trans_reserve(tp, &tres, resblks, 0);
1214 XFS_TRANS_PERM_LOG_RES, log_count);
1215 } 1214 }
1216 if (error == ENOSPC) { 1215 if (error == ENOSPC) {
1217 /* No space at all so try a "no-allocation" reservation */ 1216 /* No space at all so try a "no-allocation" reservation */
1218 resblks = 0; 1217 resblks = 0;
1219 error = xfs_trans_reserve(tp, 0, log_res, 0, 1218 error = xfs_trans_reserve(tp, &tres, 0, 0);
1220 XFS_TRANS_PERM_LOG_RES, log_count);
1221 } 1219 }
1222 if (error) { 1220 if (error) {
1223 cancel_flags = 0; 1221 cancel_flags = 0;
@@ -1371,12 +1369,10 @@ xfs_link(
1371 tp = xfs_trans_alloc(mp, XFS_TRANS_LINK); 1369 tp = xfs_trans_alloc(mp, XFS_TRANS_LINK);
1372 cancel_flags = XFS_TRANS_RELEASE_LOG_RES; 1370 cancel_flags = XFS_TRANS_RELEASE_LOG_RES;
1373 resblks = XFS_LINK_SPACE_RES(mp, target_name->len); 1371 resblks = XFS_LINK_SPACE_RES(mp, target_name->len);
1374 error = xfs_trans_reserve(tp, resblks, XFS_LINK_LOG_RES(mp), 0, 1372 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_link, resblks, 0);
1375 XFS_TRANS_PERM_LOG_RES, XFS_LINK_LOG_COUNT);
1376 if (error == ENOSPC) { 1373 if (error == ENOSPC) {
1377 resblks = 0; 1374 resblks = 0;
1378 error = xfs_trans_reserve(tp, 0, XFS_LINK_LOG_RES(mp), 0, 1375 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_link, 0, 0);
1379 XFS_TRANS_PERM_LOG_RES, XFS_LINK_LOG_COUNT);
1380 } 1376 }
1381 if (error) { 1377 if (error) {
1382 cancel_flags = 0; 1378 cancel_flags = 0;
@@ -1551,10 +1547,7 @@ xfs_itruncate_extents(
1551 * reference that we gained in xfs_trans_dup() 1547 * reference that we gained in xfs_trans_dup()
1552 */ 1548 */
1553 xfs_log_ticket_put(tp->t_ticket); 1549 xfs_log_ticket_put(tp->t_ticket);
1554 error = xfs_trans_reserve(tp, 0, 1550 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_itruncate, 0, 0);
1555 XFS_ITRUNCATE_LOG_RES(mp), 0,
1556 XFS_TRANS_PERM_LOG_RES,
1557 XFS_ITRUNCATE_LOG_COUNT);
1558 if (error) 1551 if (error)
1559 goto out; 1552 goto out;
1560 } 1553 }
@@ -1680,13 +1673,14 @@ int
1680xfs_inactive( 1673xfs_inactive(
1681 xfs_inode_t *ip) 1674 xfs_inode_t *ip)
1682{ 1675{
1683 xfs_bmap_free_t free_list; 1676 xfs_bmap_free_t free_list;
1684 xfs_fsblock_t first_block; 1677 xfs_fsblock_t first_block;
1685 int committed; 1678 int committed;
1686 xfs_trans_t *tp; 1679 struct xfs_trans *tp;
1687 xfs_mount_t *mp; 1680 struct xfs_mount *mp;
1688 int error; 1681 struct xfs_trans_res *resp;
1689 int truncate = 0; 1682 int error;
1683 int truncate = 0;
1690 1684
1691 /* 1685 /*
1692 * If the inode is already free, then there can be nothing 1686 * If the inode is already free, then there can be nothing
@@ -1730,13 +1724,10 @@ xfs_inactive(
1730 return VN_INACTIVE_CACHE; 1724 return VN_INACTIVE_CACHE;
1731 1725
1732 tp = xfs_trans_alloc(mp, XFS_TRANS_INACTIVE); 1726 tp = xfs_trans_alloc(mp, XFS_TRANS_INACTIVE);
1733 error = xfs_trans_reserve(tp, 0, 1727 resp = (truncate || S_ISLNK(ip->i_d.di_mode)) ?
1734 (truncate || S_ISLNK(ip->i_d.di_mode)) ? 1728 &M_RES(mp)->tr_itruncate : &M_RES(mp)->tr_ifree;
1735 XFS_ITRUNCATE_LOG_RES(mp) : 1729
1736 XFS_IFREE_LOG_RES(mp), 1730 error = xfs_trans_reserve(tp, resp, 0, 0);
1737 0,
1738 XFS_TRANS_PERM_LOG_RES,
1739 XFS_ITRUNCATE_LOG_COUNT);
1740 if (error) { 1731 if (error) {
1741 ASSERT(XFS_FORCED_SHUTDOWN(mp)); 1732 ASSERT(XFS_FORCED_SHUTDOWN(mp));
1742 xfs_trans_cancel(tp, 0); 1733 xfs_trans_cancel(tp, 0);
@@ -1781,10 +1772,7 @@ xfs_inactive(
1781 goto out; 1772 goto out;
1782 1773
1783 tp = xfs_trans_alloc(mp, XFS_TRANS_INACTIVE); 1774 tp = xfs_trans_alloc(mp, XFS_TRANS_INACTIVE);
1784 error = xfs_trans_reserve(tp, 0, 1775 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_ifree, 0, 0);
1785 XFS_IFREE_LOG_RES(mp),
1786 0, XFS_TRANS_PERM_LOG_RES,
1787 XFS_INACTIVE_LOG_COUNT);
1788 if (error) { 1776 if (error) {
1789 xfs_trans_cancel(tp, 0); 1777 xfs_trans_cancel(tp, 0);
1790 goto out; 1778 goto out;
@@ -2431,12 +2419,10 @@ xfs_remove(
2431 * block from the directory. 2419 * block from the directory.
2432 */ 2420 */
2433 resblks = XFS_REMOVE_SPACE_RES(mp); 2421 resblks = XFS_REMOVE_SPACE_RES(mp);
2434 error = xfs_trans_reserve(tp, resblks, XFS_REMOVE_LOG_RES(mp), 0, 2422 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_remove, resblks, 0);
2435 XFS_TRANS_PERM_LOG_RES, log_count);
2436 if (error == ENOSPC) { 2423 if (error == ENOSPC) {
2437 resblks = 0; 2424 resblks = 0;
2438 error = xfs_trans_reserve(tp, 0, XFS_REMOVE_LOG_RES(mp), 0, 2425 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_remove, 0, 0);
2439 XFS_TRANS_PERM_LOG_RES, log_count);
2440 } 2426 }
2441 if (error) { 2427 if (error) {
2442 ASSERT(error != ENOSPC); 2428 ASSERT(error != ENOSPC);
@@ -2631,12 +2617,10 @@ xfs_rename(
2631 tp = xfs_trans_alloc(mp, XFS_TRANS_RENAME); 2617 tp = xfs_trans_alloc(mp, XFS_TRANS_RENAME);
2632 cancel_flags = XFS_TRANS_RELEASE_LOG_RES; 2618 cancel_flags = XFS_TRANS_RELEASE_LOG_RES;
2633 spaceres = XFS_RENAME_SPACE_RES(mp, target_name->len); 2619 spaceres = XFS_RENAME_SPACE_RES(mp, target_name->len);
2634 error = xfs_trans_reserve(tp, spaceres, XFS_RENAME_LOG_RES(mp), 0, 2620 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_rename, spaceres, 0);
2635 XFS_TRANS_PERM_LOG_RES, XFS_RENAME_LOG_COUNT);
2636 if (error == ENOSPC) { 2621 if (error == ENOSPC) {
2637 spaceres = 0; 2622 spaceres = 0;
2638 error = xfs_trans_reserve(tp, 0, XFS_RENAME_LOG_RES(mp), 0, 2623 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_rename, 0, 0);
2639 XFS_TRANS_PERM_LOG_RES, XFS_RENAME_LOG_COUNT);
2640 } 2624 }
2641 if (error) { 2625 if (error) {
2642 xfs_trans_cancel(tp, 0); 2626 xfs_trans_cancel(tp, 0);
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index efb216de5f69..e9c17e2ed6d7 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -367,7 +367,7 @@ xfs_set_dmattrs(
367 return XFS_ERROR(EIO); 367 return XFS_ERROR(EIO);
368 368
369 tp = xfs_trans_alloc(mp, XFS_TRANS_SET_DMATTRS); 369 tp = xfs_trans_alloc(mp, XFS_TRANS_SET_DMATTRS);
370 error = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES (mp), 0, 0, 0); 370 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_ichange, 0, 0);
371 if (error) { 371 if (error) {
372 xfs_trans_cancel(tp, 0); 372 xfs_trans_cancel(tp, 0);
373 return error; 373 return error;
@@ -1001,7 +1001,7 @@ xfs_ioctl_setattr(
1001 * first do an error checking pass. 1001 * first do an error checking pass.
1002 */ 1002 */
1003 tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE); 1003 tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
1004 code = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0); 1004 code = xfs_trans_reserve(tp, &M_RES(mp)->tr_ichange, 0, 0);
1005 if (code) 1005 if (code)
1006 goto error_return; 1006 goto error_return;
1007 1007
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index cf8f74407660..8d4d49b6fbf3 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -188,10 +188,8 @@ xfs_iomap_write_direct(
188 * Allocate and setup the transaction 188 * Allocate and setup the transaction
189 */ 189 */
190 tp = xfs_trans_alloc(mp, XFS_TRANS_DIOSTRAT); 190 tp = xfs_trans_alloc(mp, XFS_TRANS_DIOSTRAT);
191 error = xfs_trans_reserve(tp, resblks, 191 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_write,
192 XFS_WRITE_LOG_RES(mp), resrtextents, 192 resblks, resrtextents);
193 XFS_TRANS_PERM_LOG_RES,
194 XFS_WRITE_LOG_COUNT);
195 /* 193 /*
196 * Check for running out of space, note: need lock to return 194 * Check for running out of space, note: need lock to return
197 */ 195 */
@@ -699,10 +697,8 @@ xfs_iomap_write_allocate(
699 tp = xfs_trans_alloc(mp, XFS_TRANS_STRAT_WRITE); 697 tp = xfs_trans_alloc(mp, XFS_TRANS_STRAT_WRITE);
700 tp->t_flags |= XFS_TRANS_RESERVE; 698 tp->t_flags |= XFS_TRANS_RESERVE;
701 nres = XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK); 699 nres = XFS_EXTENTADD_SPACE_RES(mp, XFS_DATA_FORK);
702 error = xfs_trans_reserve(tp, nres, 700 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_write,
703 XFS_WRITE_LOG_RES(mp), 701 nres, 0);
704 0, XFS_TRANS_PERM_LOG_RES,
705 XFS_WRITE_LOG_COUNT);
706 if (error) { 702 if (error) {
707 xfs_trans_cancel(tp, 0); 703 xfs_trans_cancel(tp, 0);
708 return XFS_ERROR(error); 704 return XFS_ERROR(error);
@@ -865,10 +861,8 @@ xfs_iomap_write_unwritten(
865 sb_start_intwrite(mp->m_super); 861 sb_start_intwrite(mp->m_super);
866 tp = _xfs_trans_alloc(mp, XFS_TRANS_STRAT_WRITE, KM_NOFS); 862 tp = _xfs_trans_alloc(mp, XFS_TRANS_STRAT_WRITE, KM_NOFS);
867 tp->t_flags |= XFS_TRANS_RESERVE | XFS_TRANS_FREEZE_PROT; 863 tp->t_flags |= XFS_TRANS_RESERVE | XFS_TRANS_FREEZE_PROT;
868 error = xfs_trans_reserve(tp, resblks, 864 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_write,
869 XFS_WRITE_LOG_RES(mp), 0, 865 resblks, 0);
870 XFS_TRANS_PERM_LOG_RES,
871 XFS_WRITE_LOG_COUNT);
872 if (error) { 866 if (error) {
873 xfs_trans_cancel(tp, 0); 867 xfs_trans_cancel(tp, 0);
874 return XFS_ERROR(error); 868 return XFS_ERROR(error);
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 24be68d82f11..82c5a5d8677d 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -546,7 +546,7 @@ xfs_setattr_nonsize(
546 } 546 }
547 547
548 tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE); 548 tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_NOT_SIZE);
549 error = xfs_trans_reserve(tp, 0, XFS_ICHANGE_LOG_RES(mp), 0, 0, 0); 549 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_ichange, 0, 0);
550 if (error) 550 if (error)
551 goto out_dqrele; 551 goto out_dqrele;
552 552
@@ -808,9 +808,7 @@ xfs_setattr_size(
808 goto out_unlock; 808 goto out_unlock;
809 809
810 tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_SIZE); 810 tp = xfs_trans_alloc(mp, XFS_TRANS_SETATTR_SIZE);
811 error = xfs_trans_reserve(tp, 0, XFS_ITRUNCATE_LOG_RES(mp), 0, 811 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_itruncate, 0, 0);
812 XFS_TRANS_PERM_LOG_RES,
813 XFS_ITRUNCATE_LOG_COUNT);
814 if (error) 812 if (error)
815 goto out_trans_cancel; 813 goto out_trans_cancel;
816 814
@@ -933,7 +931,7 @@ xfs_vn_update_time(
933 trace_xfs_update_time(ip); 931 trace_xfs_update_time(ip);
934 932
935 tp = xfs_trans_alloc(mp, XFS_TRANS_FSYNC_TS); 933 tp = xfs_trans_alloc(mp, XFS_TRANS_FSYNC_TS);
936 error = xfs_trans_reserve(tp, 0, XFS_FSYNC_TS_LOG_RES(mp), 0, 0, 0); 934 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_fsyncts, 0, 0);
937 if (error) { 935 if (error) {
938 xfs_trans_cancel(tp, 0); 936 xfs_trans_cancel(tp, 0);
939 return -error; 937 return -error;
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 81c04eb90521..217e7fba734b 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -3377,7 +3377,7 @@ xlog_recover_process_efi(
3377 } 3377 }
3378 3378
3379 tp = xfs_trans_alloc(mp, 0); 3379 tp = xfs_trans_alloc(mp, 0);
3380 error = xfs_trans_reserve(tp, 0, XFS_ITRUNCATE_LOG_RES(mp), 0, 0, 0); 3380 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_itruncate, 0, 0);
3381 if (error) 3381 if (error)
3382 goto abort_error; 3382 goto abort_error;
3383 efdp = xfs_trans_get_efd(tp, efip, efip->efi_format.efi_nextents); 3383 efdp = xfs_trans_get_efd(tp, efip, efip->efi_format.efi_nextents);
@@ -3483,8 +3483,7 @@ xlog_recover_clear_agi_bucket(
3483 int error; 3483 int error;
3484 3484
3485 tp = xfs_trans_alloc(mp, XFS_TRANS_CLEAR_AGI_BUCKET); 3485 tp = xfs_trans_alloc(mp, XFS_TRANS_CLEAR_AGI_BUCKET);
3486 error = xfs_trans_reserve(tp, 0, XFS_CLEAR_AGI_BUCKET_LOG_RES(mp), 3486 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_clearagi, 0, 0);
3487 0, 0, 0);
3488 if (error) 3487 if (error)
3489 goto out_abort; 3488 goto out_abort;
3490 3489
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 7a9986db47e2..85b6aaa89e51 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -597,8 +597,7 @@ xfs_mount_reset_sbqflags(
597 return 0; 597 return 0;
598 598
599 tp = xfs_trans_alloc(mp, XFS_TRANS_QM_SBCHANGE); 599 tp = xfs_trans_alloc(mp, XFS_TRANS_QM_SBCHANGE);
600 error = xfs_trans_reserve(tp, 0, XFS_QM_SBCHANGE_LOG_RES(mp), 600 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_qm_sbchange, 0, 0);
601 0, 0, XFS_DEFAULT_LOG_COUNT);
602 if (error) { 601 if (error) {
603 xfs_trans_cancel(tp, 0); 602 xfs_trans_cancel(tp, 0);
604 xfs_alert(mp, "%s: Superblock update failed!", __func__); 603 xfs_alert(mp, "%s: Superblock update failed!", __func__);
@@ -1071,8 +1070,7 @@ xfs_log_sbcount(xfs_mount_t *mp)
1071 return 0; 1070 return 0;
1072 1071
1073 tp = _xfs_trans_alloc(mp, XFS_TRANS_SB_COUNT, KM_SLEEP); 1072 tp = _xfs_trans_alloc(mp, XFS_TRANS_SB_COUNT, KM_SLEEP);
1074 error = xfs_trans_reserve(tp, 0, XFS_SB_LOG_RES(mp), 0, 0, 1073 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_sb, 0, 0);
1075 XFS_DEFAULT_LOG_COUNT);
1076 if (error) { 1074 if (error) {
1077 xfs_trans_cancel(tp, 0); 1075 xfs_trans_cancel(tp, 0);
1078 return error; 1076 return error;
@@ -1392,8 +1390,7 @@ xfs_mount_log_sb(
1392 XFS_SB_VERSIONNUM)); 1390 XFS_SB_VERSIONNUM));
1393 1391
1394 tp = xfs_trans_alloc(mp, XFS_TRANS_SB_UNIT); 1392 tp = xfs_trans_alloc(mp, XFS_TRANS_SB_UNIT);
1395 error = xfs_trans_reserve(tp, 0, XFS_SB_LOG_RES(mp), 0, 0, 1393 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_sb, 0, 0);
1396 XFS_DEFAULT_LOG_COUNT);
1397 if (error) { 1394 if (error) {
1398 xfs_trans_cancel(tp, 0); 1395 xfs_trans_cancel(tp, 0);
1399 return error; 1396 return error;
diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
index 35a6f568e9c9..479c933d7cdf 100644
--- a/fs/xfs/xfs_qm.c
+++ b/fs/xfs/xfs_qm.c
@@ -865,11 +865,9 @@ xfs_qm_qino_alloc(
865 } 865 }
866 866
867 tp = xfs_trans_alloc(mp, XFS_TRANS_QM_QINOCREATE); 867 tp = xfs_trans_alloc(mp, XFS_TRANS_QM_QINOCREATE);
868 if ((error = xfs_trans_reserve(tp, 868 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_create,
869 XFS_QM_QINOCREATE_SPACE_RES(mp), 869 XFS_QM_QINOCREATE_SPACE_RES(mp), 0);
870 XFS_CREATE_LOG_RES(mp), 0, 870 if (error) {
871 XFS_TRANS_PERM_LOG_RES,
872 XFS_CREATE_LOG_COUNT))) {
873 xfs_trans_cancel(tp, 0); 871 xfs_trans_cancel(tp, 0);
874 return error; 872 return error;
875 } 873 }
@@ -1740,8 +1738,7 @@ xfs_qm_write_sb_changes(
1740 int error; 1738 int error;
1741 1739
1742 tp = xfs_trans_alloc(mp, XFS_TRANS_QM_SBCHANGE); 1740 tp = xfs_trans_alloc(mp, XFS_TRANS_QM_SBCHANGE);
1743 error = xfs_trans_reserve(tp, 0, XFS_QM_SBCHANGE_LOG_RES(mp), 1741 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_qm_sbchange, 0, 0);
1744 0, 0, XFS_DEFAULT_LOG_COUNT);
1745 if (error) { 1742 if (error) {
1746 xfs_trans_cancel(tp, 0); 1743 xfs_trans_cancel(tp, 0);
1747 return error; 1744 return error;
diff --git a/fs/xfs/xfs_qm_syscalls.c b/fs/xfs/xfs_qm_syscalls.c
index 6fdccc324f7e..5290af2411c4 100644
--- a/fs/xfs/xfs_qm_syscalls.c
+++ b/fs/xfs/xfs_qm_syscalls.c
@@ -247,9 +247,7 @@ xfs_qm_scall_trunc_qfile(
247 xfs_ilock(ip, XFS_IOLOCK_EXCL); 247 xfs_ilock(ip, XFS_IOLOCK_EXCL);
248 248
249 tp = xfs_trans_alloc(mp, XFS_TRANS_TRUNCATE_FILE); 249 tp = xfs_trans_alloc(mp, XFS_TRANS_TRUNCATE_FILE);
250 error = xfs_trans_reserve(tp, 0, XFS_ITRUNCATE_LOG_RES(mp), 0, 250 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_itruncate, 0, 0);
251 XFS_TRANS_PERM_LOG_RES,
252 XFS_ITRUNCATE_LOG_COUNT);
253 if (error) { 251 if (error) {
254 xfs_trans_cancel(tp, 0); 252 xfs_trans_cancel(tp, 0);
255 xfs_iunlock(ip, XFS_IOLOCK_EXCL); 253 xfs_iunlock(ip, XFS_IOLOCK_EXCL);
@@ -540,8 +538,7 @@ xfs_qm_scall_setqlim(
540 xfs_dqunlock(dqp); 538 xfs_dqunlock(dqp);
541 539
542 tp = xfs_trans_alloc(mp, XFS_TRANS_QM_SETQLIM); 540 tp = xfs_trans_alloc(mp, XFS_TRANS_QM_SETQLIM);
543 error = xfs_trans_reserve(tp, 0, XFS_QM_SETQLIM_LOG_RES(mp), 541 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_qm_setqlim, 0, 0);
544 0, 0, XFS_DEFAULT_LOG_COUNT);
545 if (error) { 542 if (error) {
546 xfs_trans_cancel(tp, 0); 543 xfs_trans_cancel(tp, 0);
547 goto out_rele; 544 goto out_rele;
@@ -675,8 +672,7 @@ xfs_qm_log_quotaoff_end(
675 672
676 tp = xfs_trans_alloc(mp, XFS_TRANS_QM_QUOTAOFF_END); 673 tp = xfs_trans_alloc(mp, XFS_TRANS_QM_QUOTAOFF_END);
677 674
678 error = xfs_trans_reserve(tp, 0, XFS_QM_QUOTAOFF_END_LOG_RES(mp), 675 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_qm_equotaoff, 0, 0);
679 0, 0, XFS_DEFAULT_LOG_COUNT);
680 if (error) { 676 if (error) {
681 xfs_trans_cancel(tp, 0); 677 xfs_trans_cancel(tp, 0);
682 return (error); 678 return (error);
@@ -709,8 +705,7 @@ xfs_qm_log_quotaoff(
709 uint oldsbqflag=0; 705 uint oldsbqflag=0;
710 706
711 tp = xfs_trans_alloc(mp, XFS_TRANS_QM_QUOTAOFF); 707 tp = xfs_trans_alloc(mp, XFS_TRANS_QM_QUOTAOFF);
712 error = xfs_trans_reserve(tp, 0, XFS_QM_QUOTAOFF_LOG_RES(mp), 708 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_qm_quotaoff, 0, 0);
713 0, 0, XFS_DEFAULT_LOG_COUNT);
714 if (error) 709 if (error)
715 goto error0; 710 goto error0;
716 711
diff --git a/fs/xfs/xfs_rtalloc.c b/fs/xfs/xfs_rtalloc.c
index 6dbcb5e9fb5d..6f9e63c9fc26 100644
--- a/fs/xfs/xfs_rtalloc.c
+++ b/fs/xfs/xfs_rtalloc.c
@@ -100,10 +100,9 @@ xfs_growfs_rt_alloc(
100 /* 100 /*
101 * Reserve space & log for one extent added to the file. 101 * Reserve space & log for one extent added to the file.
102 */ 102 */
103 if ((error = xfs_trans_reserve(tp, resblks, 103 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_growdata,
104 XFS_GROWRTALLOC_LOG_RES(mp), 0, 104 resblks, 0);
105 XFS_TRANS_PERM_LOG_RES, 105 if (error)
106 XFS_DEFAULT_PERM_LOG_COUNT)))
107 goto error_cancel; 106 goto error_cancel;
108 cancelflags = XFS_TRANS_RELEASE_LOG_RES; 107 cancelflags = XFS_TRANS_RELEASE_LOG_RES;
109 /* 108 /*
@@ -146,8 +145,9 @@ xfs_growfs_rt_alloc(
146 /* 145 /*
147 * Reserve log for one block zeroing. 146 * Reserve log for one block zeroing.
148 */ 147 */
149 if ((error = xfs_trans_reserve(tp, 0, 148 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_growrtzero,
150 XFS_GROWRTZERO_LOG_RES(mp), 0, 0, 0))) 149 0, 0);
150 if (error)
151 goto error_cancel; 151 goto error_cancel;
152 /* 152 /*
153 * Lock the bitmap inode. 153 * Lock the bitmap inode.
@@ -1957,8 +1957,9 @@ xfs_growfs_rt(
1957 * Start a transaction, get the log reservation. 1957 * Start a transaction, get the log reservation.
1958 */ 1958 */
1959 tp = xfs_trans_alloc(mp, XFS_TRANS_GROWFSRT_FREE); 1959 tp = xfs_trans_alloc(mp, XFS_TRANS_GROWFSRT_FREE);
1960 if ((error = xfs_trans_reserve(tp, 0, 1960 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_growrtfree,
1961 XFS_GROWRTFREE_LOG_RES(nmp), 0, 0, 0))) 1961 0, 0);
1962 if (error)
1962 goto error_cancel; 1963 goto error_cancel;
1963 /* 1964 /*
1964 * Lock out other callers by grabbing the bitmap inode lock. 1965 * Lock out other callers by grabbing the bitmap inode lock.
diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c
index e6facbf7043e..7676fe3d706d 100644
--- a/fs/xfs/xfs_symlink.c
+++ b/fs/xfs/xfs_symlink.c
@@ -231,12 +231,10 @@ xfs_symlink(
231 else 231 else
232 fs_blocks = xfs_symlink_blocks(mp, pathlen); 232 fs_blocks = xfs_symlink_blocks(mp, pathlen);
233 resblks = XFS_SYMLINK_SPACE_RES(mp, link_name->len, fs_blocks); 233 resblks = XFS_SYMLINK_SPACE_RES(mp, link_name->len, fs_blocks);
234 error = xfs_trans_reserve(tp, resblks, XFS_SYMLINK_LOG_RES(mp), 0, 234 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_symlink, resblks, 0);
235 XFS_TRANS_PERM_LOG_RES, XFS_SYMLINK_LOG_COUNT);
236 if (error == ENOSPC && fs_blocks == 0) { 235 if (error == ENOSPC && fs_blocks == 0) {
237 resblks = 0; 236 resblks = 0;
238 error = xfs_trans_reserve(tp, 0, XFS_SYMLINK_LOG_RES(mp), 0, 237 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_symlink, 0, 0);
239 XFS_TRANS_PERM_LOG_RES, XFS_SYMLINK_LOG_COUNT);
240 } 238 }
241 if (error) { 239 if (error) {
242 cancel_flags = 0; 240 cancel_flags = 0;
@@ -539,8 +537,8 @@ xfs_inactive_symlink_rmt(
539 * Put an itruncate log reservation in the new transaction 537 * Put an itruncate log reservation in the new transaction
540 * for our caller. 538 * for our caller.
541 */ 539 */
542 if ((error = xfs_trans_reserve(tp, 0, XFS_ITRUNCATE_LOG_RES(mp), 0, 540 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_itruncate, 0, 0);
543 XFS_TRANS_PERM_LOG_RES, XFS_ITRUNCATE_LOG_COUNT))) { 541 if (error) {
544 ASSERT(XFS_FORCED_SHUTDOWN(mp)); 542 ASSERT(XFS_FORCED_SHUTDOWN(mp));
545 goto error0; 543 goto error0;
546 } 544 }
diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
index e0f93f957c5c..b986400ea728 100644
--- a/fs/xfs/xfs_trans.c
+++ b/fs/xfs/xfs_trans.c
@@ -56,7 +56,7 @@ void
56xfs_trans_init( 56xfs_trans_init(
57 struct xfs_mount *mp) 57 struct xfs_mount *mp)
58{ 58{
59 xfs_trans_resv_calc(mp, &mp->m_resv); 59 xfs_trans_resv_calc(mp, M_RES(mp));
60} 60}
61 61
62/* 62/*
@@ -180,12 +180,10 @@ xfs_trans_dup(
180 */ 180 */
181int 181int
182xfs_trans_reserve( 182xfs_trans_reserve(
183 xfs_trans_t *tp, 183 struct xfs_trans *tp,
184 uint blocks, 184 struct xfs_trans_res *resp,
185 uint logspace, 185 uint blocks,
186 uint rtextents, 186 uint rtextents)
187 uint flags,
188 uint logcount)
189{ 187{
190 int error = 0; 188 int error = 0;
191 int rsvd = (tp->t_flags & XFS_TRANS_RESERVE) != 0; 189 int rsvd = (tp->t_flags & XFS_TRANS_RESERVE) != 0;
@@ -211,13 +209,15 @@ xfs_trans_reserve(
211 /* 209 /*
212 * Reserve the log space needed for this transaction. 210 * Reserve the log space needed for this transaction.
213 */ 211 */
214 if (logspace > 0) { 212 if (resp->tr_logres > 0) {
215 bool permanent = false; 213 bool permanent = false;
216 214
217 ASSERT(tp->t_log_res == 0 || tp->t_log_res == logspace); 215 ASSERT(tp->t_log_res == 0 ||
218 ASSERT(tp->t_log_count == 0 || tp->t_log_count == logcount); 216 tp->t_log_res == resp->tr_logres);
217 ASSERT(tp->t_log_count == 0 ||
218 tp->t_log_count == resp->tr_logcount);
219 219
220 if (flags & XFS_TRANS_PERM_LOG_RES) { 220 if (resp->tr_logflags & XFS_TRANS_PERM_LOG_RES) {
221 tp->t_flags |= XFS_TRANS_PERM_LOG_RES; 221 tp->t_flags |= XFS_TRANS_PERM_LOG_RES;
222 permanent = true; 222 permanent = true;
223 } else { 223 } else {
@@ -226,20 +226,21 @@ xfs_trans_reserve(
226 } 226 }
227 227
228 if (tp->t_ticket != NULL) { 228 if (tp->t_ticket != NULL) {
229 ASSERT(flags & XFS_TRANS_PERM_LOG_RES); 229 ASSERT(resp->tr_logflags & XFS_TRANS_PERM_LOG_RES);
230 error = xfs_log_regrant(tp->t_mountp, tp->t_ticket); 230 error = xfs_log_regrant(tp->t_mountp, tp->t_ticket);
231 } else { 231 } else {
232 error = xfs_log_reserve(tp->t_mountp, logspace, 232 error = xfs_log_reserve(tp->t_mountp,
233 logcount, &tp->t_ticket, 233 resp->tr_logres,
234 XFS_TRANSACTION, permanent, 234 resp->tr_logcount,
235 tp->t_type); 235 &tp->t_ticket, XFS_TRANSACTION,
236 permanent, tp->t_type);
236 } 237 }
237 238
238 if (error) 239 if (error)
239 goto undo_blocks; 240 goto undo_blocks;
240 241
241 tp->t_log_res = logspace; 242 tp->t_log_res = resp->tr_logres;
242 tp->t_log_count = logcount; 243 tp->t_log_count = resp->tr_logcount;
243 } 244 }
244 245
245 /* 246 /*
@@ -264,10 +265,10 @@ xfs_trans_reserve(
264 * reservations which have already been performed. 265 * reservations which have already been performed.
265 */ 266 */
266undo_log: 267undo_log:
267 if (logspace > 0) { 268 if (resp->tr_logres > 0) {
268 int log_flags; 269 int log_flags;
269 270
270 if (flags & XFS_TRANS_PERM_LOG_RES) { 271 if (resp->tr_logflags & XFS_TRANS_PERM_LOG_RES) {
271 log_flags = XFS_LOG_REL_PERM_RESERV; 272 log_flags = XFS_LOG_REL_PERM_RESERV;
272 } else { 273 } else {
273 log_flags = 0; 274 log_flags = 0;
@@ -1014,7 +1015,7 @@ xfs_trans_roll(
1014 struct xfs_inode *dp) 1015 struct xfs_inode *dp)
1015{ 1016{
1016 struct xfs_trans *trans; 1017 struct xfs_trans *trans;
1017 unsigned int logres, count; 1018 struct xfs_trans_res tres;
1018 int error; 1019 int error;
1019 1020
1020 /* 1021 /*
@@ -1026,8 +1027,8 @@ xfs_trans_roll(
1026 /* 1027 /*
1027 * Copy the critical parameters from one trans to the next. 1028 * Copy the critical parameters from one trans to the next.
1028 */ 1029 */
1029 logres = trans->t_log_res; 1030 tres.tr_logres = trans->t_log_res;
1030 count = trans->t_log_count; 1031 tres.tr_logcount = trans->t_log_count;
1031 *tpp = xfs_trans_dup(trans); 1032 *tpp = xfs_trans_dup(trans);
1032 1033
1033 /* 1034 /*
@@ -1058,8 +1059,8 @@ xfs_trans_roll(
1058 * across this call, or that anything that is locked be logged in 1059 * across this call, or that anything that is locked be logged in
1059 * the prior and the next transactions. 1060 * the prior and the next transactions.
1060 */ 1061 */
1061 error = xfs_trans_reserve(trans, 0, logres, 0, 1062 tres.tr_logflags = XFS_TRANS_PERM_LOG_RES;
1062 XFS_TRANS_PERM_LOG_RES, count); 1063 error = xfs_trans_reserve(trans, &tres, 0, 0);
1063 /* 1064 /*
1064 * Ensure that the inode is in the new transaction and locked. 1065 * Ensure that the inode is in the new transaction and locked.
1065 */ 1066 */
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
index b5dc61e3e56b..7eb81ccd826d 100644
--- a/fs/xfs/xfs_trans.h
+++ b/fs/xfs/xfs_trans.h
@@ -34,6 +34,7 @@ struct xfs_log_iovec;
34struct xfs_log_item_desc; 34struct xfs_log_item_desc;
35struct xfs_mount; 35struct xfs_mount;
36struct xfs_trans; 36struct xfs_trans;
37struct xfs_trans_res;
37struct xfs_dquot_acct; 38struct xfs_dquot_acct;
38struct xfs_busy_extent; 39struct xfs_busy_extent;
39 40
@@ -170,7 +171,7 @@ typedef struct xfs_trans {
170xfs_trans_t *xfs_trans_alloc(struct xfs_mount *, uint); 171xfs_trans_t *xfs_trans_alloc(struct xfs_mount *, uint);
171xfs_trans_t *_xfs_trans_alloc(struct xfs_mount *, uint, xfs_km_flags_t); 172xfs_trans_t *_xfs_trans_alloc(struct xfs_mount *, uint, xfs_km_flags_t);
172xfs_trans_t *xfs_trans_dup(xfs_trans_t *); 173xfs_trans_t *xfs_trans_dup(xfs_trans_t *);
173int xfs_trans_reserve(xfs_trans_t *, uint, uint, uint, 174int xfs_trans_reserve(struct xfs_trans *, struct xfs_trans_res *,
174 uint, uint); 175 uint, uint);
175void xfs_trans_mod_sb(xfs_trans_t *, uint, int64_t); 176void xfs_trans_mod_sb(xfs_trans_t *, uint, int64_t);
176 177
diff --git a/fs/xfs/xfs_trans_resv.c b/fs/xfs/xfs_trans_resv.c
index e9211add5183..24110f36f729 100644
--- a/fs/xfs/xfs_trans_resv.c
+++ b/fs/xfs/xfs_trans_resv.c
@@ -547,7 +547,8 @@ xfs_calc_attrsetm_reservation(
547 * Since the runtime attribute transaction space is dependent on the total 547 * Since the runtime attribute transaction space is dependent on the total
548 * blocks needed for the 1st bmap, here we calculate out the space unit for 548 * blocks needed for the 1st bmap, here we calculate out the space unit for
549 * one block so that the caller could figure out the total space according 549 * one block so that the caller could figure out the total space according
550 * to the attibute extent length in blocks by: ext * XFS_ATTRSETRT_LOG_RES(mp). 550 * to the attibute extent length in blocks by:
551 * ext * M_RES(mp)->tr_attrsetrt.tr_logres
551 */ 552 */
552STATIC uint 553STATIC uint
553xfs_calc_attrsetrt_reservation( 554xfs_calc_attrsetrt_reservation(
@@ -619,14 +620,14 @@ xfs_calc_qm_setqlim_reservation(
619 620
620/* 621/*
621 * Allocating quota on disk if needed. 622 * Allocating quota on disk if needed.
622 * the write transaction log space: XFS_WRITE_LOG_RES(mp) 623 * the write transaction log space: M_RES(mp)->tr_write.tr_logres
623 * the unit of quota allocation: one system block size 624 * the unit of quota allocation: one system block size
624 */ 625 */
625STATIC uint 626STATIC uint
626xfs_calc_qm_dqalloc_reservation( 627xfs_calc_qm_dqalloc_reservation(
627 struct xfs_mount *mp) 628 struct xfs_mount *mp)
628{ 629{
629 return XFS_WRITE_LOG_RES(mp) + 630 return M_RES(mp)->tr_write.tr_logres +
630 xfs_calc_buf_res(1, 631 xfs_calc_buf_res(1,
631 XFS_FSB_TO_B(mp, XFS_DQUOT_CLUSTER_SIZE_FSB) - 1); 632 XFS_FSB_TO_B(mp, XFS_DQUOT_CLUSTER_SIZE_FSB) - 1);
632} 633}
diff --git a/fs/xfs/xfs_trans_resv.h b/fs/xfs/xfs_trans_resv.h
index b8d5666990fe..140d3f367284 100644
--- a/fs/xfs/xfs_trans_resv.h
+++ b/fs/xfs/xfs_trans_resv.h
@@ -65,6 +65,9 @@ struct xfs_trans_resv {
65 struct xfs_trans_res tr_fsyncts; /* update timestamps on fsync */ 65 struct xfs_trans_res tr_fsyncts; /* update timestamps on fsync */
66}; 66};
67 67
68/* shorthand way of accessing reservation structure */
69#define M_RES(mp) (&(mp)->m_resv)
70
68/* 71/*
69 * Per-extent log reservation for the allocation btree changes 72 * Per-extent log reservation for the allocation btree changes
70 * involved in freeing or allocating an extent. 73 * involved in freeing or allocating an extent.