aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ocfs2')
-rw-r--r--fs/ocfs2/alloc.c30
-rw-r--r--fs/ocfs2/journal.c15
-rw-r--r--fs/ocfs2/refcounttree.c2
-rw-r--r--fs/ocfs2/xattr.c17
4 files changed, 25 insertions, 39 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);
diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index cfd271c64da9..47878cf16418 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -402,9 +402,7 @@ int ocfs2_commit_trans(struct ocfs2_super *osb,
402} 402}
403 403
404/* 404/*
405 * 'nblocks' is what you want to add to the current 405 * 'nblocks' is what you want to add to the current transaction.
406 * transaction. extend_trans will either extend the current handle by
407 * nblocks, or commit it and start a new one with nblocks credits.
408 * 406 *
409 * This might call jbd2_journal_restart() which will commit dirty buffers 407 * This might call jbd2_journal_restart() which will commit dirty buffers
410 * and then restart the transaction. Before calling 408 * and then restart the transaction. Before calling
@@ -422,11 +420,15 @@ int ocfs2_commit_trans(struct ocfs2_super *osb,
422 */ 420 */
423int ocfs2_extend_trans(handle_t *handle, int nblocks) 421int ocfs2_extend_trans(handle_t *handle, int nblocks)
424{ 422{
425 int status; 423 int status, old_nblocks;
426 424
427 BUG_ON(!handle); 425 BUG_ON(!handle);
428 BUG_ON(!nblocks); 426 BUG_ON(nblocks < 0);
427
428 if (!nblocks)
429 return 0;
429 430
431 old_nblocks = handle->h_buffer_credits;
430 mlog_entry_void(); 432 mlog_entry_void();
431 433
432 mlog(0, "Trying to extend transaction by %d blocks\n", nblocks); 434 mlog(0, "Trying to extend transaction by %d blocks\n", nblocks);
@@ -445,7 +447,8 @@ int ocfs2_extend_trans(handle_t *handle, int nblocks)
445 mlog(0, 447 mlog(0,
446 "jbd2_journal_extend failed, trying " 448 "jbd2_journal_extend failed, trying "
447 "jbd2_journal_restart\n"); 449 "jbd2_journal_restart\n");
448 status = jbd2_journal_restart(handle, nblocks); 450 status = jbd2_journal_restart(handle,
451 old_nblocks + nblocks);
449 if (status < 0) { 452 if (status < 0) {
450 mlog_errno(status); 453 mlog_errno(status);
451 goto bail; 454 goto bail;
diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
index 4b0b4eb79352..33dd2a18cb74 100644
--- a/fs/ocfs2/refcounttree.c
+++ b/fs/ocfs2/refcounttree.c
@@ -1693,7 +1693,7 @@ static int ocfs2_adjust_refcount_rec(handle_t *handle,
1693 * 2 more credits, one for the leaf refcount block, one for 1693 * 2 more credits, one for the leaf refcount block, one for
1694 * the extent block contains the extent rec. 1694 * the extent block contains the extent rec.
1695 */ 1695 */
1696 ret = ocfs2_extend_trans(handle, handle->h_buffer_credits + 2); 1696 ret = ocfs2_extend_trans(handle, 2);
1697 if (ret < 0) { 1697 if (ret < 0) {
1698 mlog_errno(ret); 1698 mlog_errno(ret);
1699 goto out; 1699 goto out;
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index 4cf6fde71027..38a55ff45b3a 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -3295,8 +3295,7 @@ static int __ocfs2_xattr_set_handle(struct inode *inode,
3295 goto out; 3295 goto out;
3296 } 3296 }
3297 3297
3298 ret = ocfs2_extend_trans(ctxt->handle, credits + 3298 ret = ocfs2_extend_trans(ctxt->handle, credits);
3299 ctxt->handle->h_buffer_credits);
3300 if (ret) { 3299 if (ret) {
3301 mlog_errno(ret); 3300 mlog_errno(ret);
3302 goto out; 3301 goto out;
@@ -3326,8 +3325,7 @@ static int __ocfs2_xattr_set_handle(struct inode *inode,
3326 goto out; 3325 goto out;
3327 } 3326 }
3328 3327
3329 ret = ocfs2_extend_trans(ctxt->handle, credits + 3328 ret = ocfs2_extend_trans(ctxt->handle, credits);
3330 ctxt->handle->h_buffer_credits);
3331 if (ret) { 3329 if (ret) {
3332 mlog_errno(ret); 3330 mlog_errno(ret);
3333 goto out; 3331 goto out;
@@ -3361,8 +3359,7 @@ static int __ocfs2_xattr_set_handle(struct inode *inode,
3361 goto out; 3359 goto out;
3362 } 3360 }
3363 3361
3364 ret = ocfs2_extend_trans(ctxt->handle, credits + 3362 ret = ocfs2_extend_trans(ctxt->handle, credits);
3365 ctxt->handle->h_buffer_credits);
3366 if (ret) { 3363 if (ret) {
3367 mlog_errno(ret); 3364 mlog_errno(ret);
3368 goto out; 3365 goto out;
@@ -4870,8 +4867,7 @@ static int ocfs2_mv_xattr_buckets(struct inode *inode, handle_t *handle,
4870 * We need to update the first bucket of the old extent and all 4867 * We need to update the first bucket of the old extent and all
4871 * the buckets going to the new extent. 4868 * the buckets going to the new extent.
4872 */ 4869 */
4873 credits = ((num_buckets + 1) * blks_per_bucket) + 4870 credits = ((num_buckets + 1) * blks_per_bucket);
4874 handle->h_buffer_credits;
4875 ret = ocfs2_extend_trans(handle, credits); 4871 ret = ocfs2_extend_trans(handle, credits);
4876 if (ret) { 4872 if (ret) {
4877 mlog_errno(ret); 4873 mlog_errno(ret);
@@ -4941,7 +4937,7 @@ static int ocfs2_divide_xattr_cluster(struct inode *inode,
4941 u32 *first_hash) 4937 u32 *first_hash)
4942{ 4938{
4943 u16 blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb); 4939 u16 blk_per_bucket = ocfs2_blocks_per_xattr_bucket(inode->i_sb);
4944 int ret, credits = 2 * blk_per_bucket + handle->h_buffer_credits; 4940 int ret, credits = 2 * blk_per_bucket;
4945 4941
4946 BUG_ON(OCFS2_XATTR_BUCKET_SIZE < OCFS2_SB(inode->i_sb)->s_clustersize); 4942 BUG_ON(OCFS2_XATTR_BUCKET_SIZE < OCFS2_SB(inode->i_sb)->s_clustersize);
4947 4943
@@ -5181,8 +5177,7 @@ static int ocfs2_extend_xattr_bucket(struct inode *inode,
5181 * existing bucket. Then we add the last existing bucket, the 5177 * existing bucket. Then we add the last existing bucket, the
5182 * new bucket, and the first bucket (3 * blk_per_bucket). 5178 * new bucket, and the first bucket (3 * blk_per_bucket).
5183 */ 5179 */
5184 credits = (end_blk - target_blk) + (3 * blk_per_bucket) + 5180 credits = (end_blk - target_blk) + (3 * blk_per_bucket);
5185 handle->h_buffer_credits;
5186 ret = ocfs2_extend_trans(handle, credits); 5181 ret = ocfs2_extend_trans(handle, credits);
5187 if (ret) { 5182 if (ret) {
5188 mlog_errno(ret); 5183 mlog_errno(ret);