diff options
author | Tao Ma <tao.ma@oracle.com> | 2010-04-26 02:34:57 -0400 |
---|---|---|
committer | Joel Becker <joel.becker@oracle.com> | 2010-05-05 21:18:09 -0400 |
commit | c901fb00731e307c2c6e8c7d5eee005df5835f9d (patch) | |
tree | 4c68bf68590d04d1045ae5d66a9ae158c56019fa /fs/ocfs2/alloc.c | |
parent | 3e4218df3176657be72ad2fa199779be6c11fe4f (diff) |
ocfs2: Make ocfs2_extend_trans() really extend.
In ocfs2, we use ocfs2_extend_trans() to extend a journal handle's
blocks. But if jbd2_journal_extend() fails, it will only restart
with the the new number of blocks. This tends to be awkward since
in most cases we want additional reserved blocks. It makes our code
harder to mantain since the caller can't be sure all the original
blocks will not be accessed and dirtied again. There are 15 callers
of ocfs2_extend_trans() in fs/ocfs2, and 12 of them have to add
h_buffer_credits before they call ocfs2_extend_trans(). This makes
ocfs2_extend_trans() really extend atop the original block count.
Signed-off-by: Tao Ma <tao.ma@oracle.com>
Signed-off-by: Joel Becker <joel.becker@oracle.com>
Diffstat (limited to 'fs/ocfs2/alloc.c')
-rw-r--r-- | fs/ocfs2/alloc.c | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c index a74ea700ffdc..0cb2945eb817 100644 --- a/fs/ocfs2/alloc.c +++ b/fs/ocfs2/alloc.c | |||
@@ -1125,8 +1125,7 @@ static int ocfs2_adjust_rightmost_branch(handle_t *handle, | |||
1125 | goto out; | 1125 | goto out; |
1126 | } | 1126 | } |
1127 | 1127 | ||
1128 | status = ocfs2_extend_trans(handle, path_num_items(path) + | 1128 | status = ocfs2_extend_trans(handle, path_num_items(path)); |
1129 | handle->h_buffer_credits); | ||
1130 | if (status < 0) { | 1129 | if (status < 0) { |
1131 | mlog_errno(status); | 1130 | mlog_errno(status); |
1132 | goto out; | 1131 | goto out; |
@@ -2288,20 +2287,14 @@ static int ocfs2_extend_rotate_transaction(handle_t *handle, int subtree_depth, | |||
2288 | int op_credits, | 2287 | int op_credits, |
2289 | struct ocfs2_path *path) | 2288 | struct ocfs2_path *path) |
2290 | { | 2289 | { |
2291 | int ret; | 2290 | int ret = 0; |
2292 | int credits = (path->p_tree_depth - subtree_depth) * 2 + 1 + op_credits; | 2291 | int credits = (path->p_tree_depth - subtree_depth) * 2 + 1 + op_credits; |
2293 | 2292 | ||
2294 | if (handle->h_buffer_credits < credits) { | 2293 | if (handle->h_buffer_credits < credits) |
2295 | ret = ocfs2_extend_trans(handle, | 2294 | ret = ocfs2_extend_trans(handle, |
2296 | credits - handle->h_buffer_credits); | 2295 | credits - handle->h_buffer_credits); |
2297 | if (ret) | ||
2298 | return ret; | ||
2299 | |||
2300 | if (unlikely(handle->h_buffer_credits < credits)) | ||
2301 | return ocfs2_extend_trans(handle, credits); | ||
2302 | } | ||
2303 | 2296 | ||
2304 | return 0; | 2297 | return ret; |
2305 | } | 2298 | } |
2306 | 2299 | ||
2307 | /* | 2300 | /* |
@@ -2545,8 +2538,7 @@ static int ocfs2_update_edge_lengths(handle_t *handle, | |||
2545 | * records for all the bh in the path. | 2538 | * records for all the bh in the path. |
2546 | * So we have to allocate extra credits and access them. | 2539 | * So we have to allocate extra credits and access them. |
2547 | */ | 2540 | */ |
2548 | ret = ocfs2_extend_trans(handle, | 2541 | ret = ocfs2_extend_trans(handle, subtree_index); |
2549 | handle->h_buffer_credits + subtree_index); | ||
2550 | if (ret) { | 2542 | if (ret) { |
2551 | mlog_errno(ret); | 2543 | mlog_errno(ret); |
2552 | goto out; | 2544 | goto out; |
@@ -4141,17 +4133,13 @@ static int ocfs2_insert_path(handle_t *handle, | |||
4141 | struct buffer_head *leaf_bh = path_leaf_bh(right_path); | 4133 | struct buffer_head *leaf_bh = path_leaf_bh(right_path); |
4142 | 4134 | ||
4143 | if (left_path) { | 4135 | if (left_path) { |
4144 | int credits = handle->h_buffer_credits; | ||
4145 | |||
4146 | /* | 4136 | /* |
4147 | * There's a chance that left_path got passed back to | 4137 | * There's a chance that left_path got passed back to |
4148 | * us without being accounted for in the | 4138 | * us without being accounted for in the |
4149 | * journal. Extend our transaction here to be sure we | 4139 | * journal. Extend our transaction here to be sure we |
4150 | * can change those blocks. | 4140 | * can change those blocks. |
4151 | */ | 4141 | */ |
4152 | credits += left_path->p_tree_depth; | 4142 | ret = ocfs2_extend_trans(handle, left_path->p_tree_depth); |
4153 | |||
4154 | ret = ocfs2_extend_trans(handle, credits); | ||
4155 | if (ret < 0) { | 4143 | if (ret < 0) { |
4156 | mlog_errno(ret); | 4144 | mlog_errno(ret); |
4157 | goto out; | 4145 | goto out; |
@@ -5237,7 +5225,7 @@ static int ocfs2_split_tree(handle_t *handle, struct ocfs2_extent_tree *et, | |||
5237 | int index, u32 new_range, | 5225 | int index, u32 new_range, |
5238 | struct ocfs2_alloc_context *meta_ac) | 5226 | struct ocfs2_alloc_context *meta_ac) |
5239 | { | 5227 | { |
5240 | int ret, depth, credits = handle->h_buffer_credits; | 5228 | int ret, depth, credits; |
5241 | struct buffer_head *last_eb_bh = NULL; | 5229 | struct buffer_head *last_eb_bh = NULL; |
5242 | struct ocfs2_extent_block *eb; | 5230 | struct ocfs2_extent_block *eb; |
5243 | struct ocfs2_extent_list *rightmost_el, *el; | 5231 | struct ocfs2_extent_list *rightmost_el, *el; |
@@ -5268,8 +5256,8 @@ static int ocfs2_split_tree(handle_t *handle, struct ocfs2_extent_tree *et, | |||
5268 | } else | 5256 | } else |
5269 | rightmost_el = path_leaf_el(path); | 5257 | rightmost_el = path_leaf_el(path); |
5270 | 5258 | ||
5271 | credits += path->p_tree_depth + | 5259 | credits = path->p_tree_depth + |
5272 | ocfs2_extend_meta_needed(et->et_root_el); | 5260 | ocfs2_extend_meta_needed(et->et_root_el); |
5273 | ret = ocfs2_extend_trans(handle, credits); | 5261 | ret = ocfs2_extend_trans(handle, credits); |
5274 | if (ret) { | 5262 | if (ret) { |
5275 | mlog_errno(ret); | 5263 | mlog_errno(ret); |