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_trans.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_trans.c')
-rw-r--r-- | fs/xfs/xfs_trans.c | 51 |
1 files changed, 26 insertions, 25 deletions
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 | |||
56 | xfs_trans_init( | 56 | xfs_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 | */ |
181 | int | 181 | int |
182 | xfs_trans_reserve( | 182 | xfs_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 | */ |
266 | undo_log: | 267 | undo_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 | */ |