aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2/alloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ocfs2/alloc.c')
-rw-r--r--fs/ocfs2/alloc.c56
1 files changed, 19 insertions, 37 deletions
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index 7dabbc31060e..f165f867f332 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -5922,7 +5922,6 @@ bail:
5922} 5922}
5923 5923
5924static int ocfs2_replay_truncate_records(struct ocfs2_super *osb, 5924static int ocfs2_replay_truncate_records(struct ocfs2_super *osb,
5925 handle_t *handle,
5926 struct inode *data_alloc_inode, 5925 struct inode *data_alloc_inode,
5927 struct buffer_head *data_alloc_bh) 5926 struct buffer_head *data_alloc_bh)
5928{ 5927{
@@ -5935,11 +5934,19 @@ static int ocfs2_replay_truncate_records(struct ocfs2_super *osb,
5935 struct ocfs2_truncate_log *tl; 5934 struct ocfs2_truncate_log *tl;
5936 struct inode *tl_inode = osb->osb_tl_inode; 5935 struct inode *tl_inode = osb->osb_tl_inode;
5937 struct buffer_head *tl_bh = osb->osb_tl_bh; 5936 struct buffer_head *tl_bh = osb->osb_tl_bh;
5937 handle_t *handle;
5938 5938
5939 di = (struct ocfs2_dinode *) tl_bh->b_data; 5939 di = (struct ocfs2_dinode *) tl_bh->b_data;
5940 tl = &di->id2.i_dealloc; 5940 tl = &di->id2.i_dealloc;
5941 i = le16_to_cpu(tl->tl_used) - 1; 5941 i = le16_to_cpu(tl->tl_used) - 1;
5942 while (i >= 0) { 5942 while (i >= 0) {
5943 handle = ocfs2_start_trans(osb, OCFS2_TRUNCATE_LOG_FLUSH_ONE_REC);
5944 if (IS_ERR(handle)) {
5945 status = PTR_ERR(handle);
5946 mlog_errno(status);
5947 goto bail;
5948 }
5949
5943 /* Caller has given us at least enough credits to 5950 /* Caller has given us at least enough credits to
5944 * update the truncate log dinode */ 5951 * update the truncate log dinode */
5945 status = ocfs2_journal_access_di(handle, INODE_CACHE(tl_inode), tl_bh, 5952 status = ocfs2_journal_access_di(handle, INODE_CACHE(tl_inode), tl_bh,
@@ -5974,12 +5981,7 @@ static int ocfs2_replay_truncate_records(struct ocfs2_super *osb,
5974 } 5981 }
5975 } 5982 }
5976 5983
5977 status = ocfs2_extend_trans(handle, 5984 ocfs2_commit_trans(osb, handle);
5978 OCFS2_TRUNCATE_LOG_FLUSH_ONE_REC);
5979 if (status < 0) {
5980 mlog_errno(status);
5981 goto bail;
5982 }
5983 i--; 5985 i--;
5984 } 5986 }
5985 5987
@@ -5994,7 +5996,6 @@ int __ocfs2_flush_truncate_log(struct ocfs2_super *osb)
5994{ 5996{
5995 int status; 5997 int status;
5996 unsigned int num_to_flush; 5998 unsigned int num_to_flush;
5997 handle_t *handle;
5998 struct inode *tl_inode = osb->osb_tl_inode; 5999 struct inode *tl_inode = osb->osb_tl_inode;
5999 struct inode *data_alloc_inode = NULL; 6000 struct inode *data_alloc_inode = NULL;
6000 struct buffer_head *tl_bh = osb->osb_tl_bh; 6001 struct buffer_head *tl_bh = osb->osb_tl_bh;
@@ -6038,21 +6039,11 @@ int __ocfs2_flush_truncate_log(struct ocfs2_super *osb)
6038 goto out_mutex; 6039 goto out_mutex;
6039 } 6040 }
6040 6041
6041 handle = ocfs2_start_trans(osb, OCFS2_TRUNCATE_LOG_FLUSH_ONE_REC); 6042 status = ocfs2_replay_truncate_records(osb, data_alloc_inode,
6042 if (IS_ERR(handle)) {
6043 status = PTR_ERR(handle);
6044 mlog_errno(status);
6045 goto out_unlock;
6046 }
6047
6048 status = ocfs2_replay_truncate_records(osb, handle, data_alloc_inode,
6049 data_alloc_bh); 6043 data_alloc_bh);
6050 if (status < 0) 6044 if (status < 0)
6051 mlog_errno(status); 6045 mlog_errno(status);
6052 6046
6053 ocfs2_commit_trans(osb, handle);
6054
6055out_unlock:
6056 brelse(data_alloc_bh); 6047 brelse(data_alloc_bh);
6057 ocfs2_inode_unlock(data_alloc_inode, 1); 6048 ocfs2_inode_unlock(data_alloc_inode, 1);
6058 6049
@@ -6413,43 +6404,34 @@ static int ocfs2_free_cached_blocks(struct ocfs2_super *osb,
6413 goto out_mutex; 6404 goto out_mutex;
6414 } 6405 }
6415 6406
6416 handle = ocfs2_start_trans(osb, OCFS2_SUBALLOC_FREE);
6417 if (IS_ERR(handle)) {
6418 ret = PTR_ERR(handle);
6419 mlog_errno(ret);
6420 goto out_unlock;
6421 }
6422
6423 while (head) { 6407 while (head) {
6424 if (head->free_bg) 6408 if (head->free_bg)
6425 bg_blkno = head->free_bg; 6409 bg_blkno = head->free_bg;
6426 else 6410 else
6427 bg_blkno = ocfs2_which_suballoc_group(head->free_blk, 6411 bg_blkno = ocfs2_which_suballoc_group(head->free_blk,
6428 head->free_bit); 6412 head->free_bit);
6413 handle = ocfs2_start_trans(osb, OCFS2_SUBALLOC_FREE);
6414 if (IS_ERR(handle)) {
6415 ret = PTR_ERR(handle);
6416 mlog_errno(ret);
6417 goto out_unlock;
6418 }
6419
6429 trace_ocfs2_free_cached_blocks( 6420 trace_ocfs2_free_cached_blocks(
6430 (unsigned long long)head->free_blk, head->free_bit); 6421 (unsigned long long)head->free_blk, head->free_bit);
6431 6422
6432 ret = ocfs2_free_suballoc_bits(handle, inode, di_bh, 6423 ret = ocfs2_free_suballoc_bits(handle, inode, di_bh,
6433 head->free_bit, bg_blkno, 1); 6424 head->free_bit, bg_blkno, 1);
6434 if (ret) { 6425 if (ret)
6435 mlog_errno(ret); 6426 mlog_errno(ret);
6436 goto out_journal;
6437 }
6438 6427
6439 ret = ocfs2_extend_trans(handle, OCFS2_SUBALLOC_FREE); 6428 ocfs2_commit_trans(osb, handle);
6440 if (ret) {
6441 mlog_errno(ret);
6442 goto out_journal;
6443 }
6444 6429
6445 tmp = head; 6430 tmp = head;
6446 head = head->free_next; 6431 head = head->free_next;
6447 kfree(tmp); 6432 kfree(tmp);
6448 } 6433 }
6449 6434
6450out_journal:
6451 ocfs2_commit_trans(osb, handle);
6452
6453out_unlock: 6435out_unlock:
6454 ocfs2_inode_unlock(inode, 1); 6436 ocfs2_inode_unlock(inode, 1);
6455 brelse(di_bh); 6437 brelse(di_bh);