diff options
author | Jie Liu <jeff.liu@oracle.com> | 2013-08-12 06:49:59 -0400 |
---|---|---|
committer | Ben Myers <bpm@sgi.com> | 2013-08-12 18:47:34 -0400 |
commit | 3d3c8b5222b92447bffaa4127ee18c757f32a460 (patch) | |
tree | 250f3b61679231944b5272d18d17e6ceabfc62d1 /fs/xfs/xfs_bmap_util.c | |
parent | 783cb6d172358892d6af394ebe2876bcbfcc6499 (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/xfs_bmap_util.c')
-rw-r--r-- | fs/xfs/xfs_bmap_util.c | 42 |
1 files changed, 15 insertions, 27 deletions
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); |