aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/relocation.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/relocation.c')
-rw-r--r--fs/btrfs/relocation.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 045c9c2b2d7e..1f5556acb530 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -2028,6 +2028,7 @@ static noinline_for_stack int merge_reloc_root(struct reloc_control *rc,
2028 2028
2029 while (1) { 2029 while (1) {
2030 trans = btrfs_start_transaction(root, 0); 2030 trans = btrfs_start_transaction(root, 0);
2031 BUG_ON(IS_ERR(trans));
2031 trans->block_rsv = rc->block_rsv; 2032 trans->block_rsv = rc->block_rsv;
2032 2033
2033 ret = btrfs_block_rsv_check(trans, root, rc->block_rsv, 2034 ret = btrfs_block_rsv_check(trans, root, rc->block_rsv,
@@ -2147,6 +2148,12 @@ again:
2147 } 2148 }
2148 2149
2149 trans = btrfs_join_transaction(rc->extent_root, 1); 2150 trans = btrfs_join_transaction(rc->extent_root, 1);
2151 if (IS_ERR(trans)) {
2152 if (!err)
2153 btrfs_block_rsv_release(rc->extent_root,
2154 rc->block_rsv, num_bytes);
2155 return PTR_ERR(trans);
2156 }
2150 2157
2151 if (!err) { 2158 if (!err) {
2152 if (num_bytes != rc->merging_rsv_size) { 2159 if (num_bytes != rc->merging_rsv_size) {
@@ -3222,6 +3229,7 @@ truncate:
3222 trans = btrfs_join_transaction(root, 0); 3229 trans = btrfs_join_transaction(root, 0);
3223 if (IS_ERR(trans)) { 3230 if (IS_ERR(trans)) {
3224 btrfs_free_path(path); 3231 btrfs_free_path(path);
3232 ret = PTR_ERR(trans);
3225 goto out; 3233 goto out;
3226 } 3234 }
3227 3235
@@ -3628,6 +3636,7 @@ int prepare_to_relocate(struct reloc_control *rc)
3628 set_reloc_control(rc); 3636 set_reloc_control(rc);
3629 3637
3630 trans = btrfs_join_transaction(rc->extent_root, 1); 3638 trans = btrfs_join_transaction(rc->extent_root, 1);
3639 BUG_ON(IS_ERR(trans));
3631 btrfs_commit_transaction(trans, rc->extent_root); 3640 btrfs_commit_transaction(trans, rc->extent_root);
3632 return 0; 3641 return 0;
3633} 3642}
@@ -3657,6 +3666,7 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
3657 3666
3658 while (1) { 3667 while (1) {
3659 trans = btrfs_start_transaction(rc->extent_root, 0); 3668 trans = btrfs_start_transaction(rc->extent_root, 0);
3669 BUG_ON(IS_ERR(trans));
3660 3670
3661 if (update_backref_cache(trans, &rc->backref_cache)) { 3671 if (update_backref_cache(trans, &rc->backref_cache)) {
3662 btrfs_end_transaction(trans, rc->extent_root); 3672 btrfs_end_transaction(trans, rc->extent_root);
@@ -3804,7 +3814,10 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
3804 3814
3805 /* get rid of pinned extents */ 3815 /* get rid of pinned extents */
3806 trans = btrfs_join_transaction(rc->extent_root, 1); 3816 trans = btrfs_join_transaction(rc->extent_root, 1);
3807 btrfs_commit_transaction(trans, rc->extent_root); 3817 if (IS_ERR(trans))
3818 err = PTR_ERR(trans);
3819 else
3820 btrfs_commit_transaction(trans, rc->extent_root);
3808out_free: 3821out_free:
3809 btrfs_free_block_rsv(rc->extent_root, rc->block_rsv); 3822 btrfs_free_block_rsv(rc->extent_root, rc->block_rsv);
3810 btrfs_free_path(path); 3823 btrfs_free_path(path);
@@ -4022,6 +4035,7 @@ static noinline_for_stack int mark_garbage_root(struct btrfs_root *root)
4022 int ret; 4035 int ret;
4023 4036
4024 trans = btrfs_start_transaction(root->fs_info->tree_root, 0); 4037 trans = btrfs_start_transaction(root->fs_info->tree_root, 0);
4038 BUG_ON(IS_ERR(trans));
4025 4039
4026 memset(&root->root_item.drop_progress, 0, 4040 memset(&root->root_item.drop_progress, 0,
4027 sizeof(root->root_item.drop_progress)); 4041 sizeof(root->root_item.drop_progress));
@@ -4125,6 +4139,11 @@ int btrfs_recover_relocation(struct btrfs_root *root)
4125 set_reloc_control(rc); 4139 set_reloc_control(rc);
4126 4140
4127 trans = btrfs_join_transaction(rc->extent_root, 1); 4141 trans = btrfs_join_transaction(rc->extent_root, 1);
4142 if (IS_ERR(trans)) {
4143 unset_reloc_control(rc);
4144 err = PTR_ERR(trans);
4145 goto out_free;
4146 }
4128 4147
4129 rc->merge_reloc_tree = 1; 4148 rc->merge_reloc_tree = 1;
4130 4149
@@ -4154,9 +4173,13 @@ int btrfs_recover_relocation(struct btrfs_root *root)
4154 unset_reloc_control(rc); 4173 unset_reloc_control(rc);
4155 4174
4156 trans = btrfs_join_transaction(rc->extent_root, 1); 4175 trans = btrfs_join_transaction(rc->extent_root, 1);
4157 btrfs_commit_transaction(trans, rc->extent_root); 4176 if (IS_ERR(trans))
4158out: 4177 err = PTR_ERR(trans);
4178 else
4179 btrfs_commit_transaction(trans, rc->extent_root);
4180out_free:
4159 kfree(rc); 4181 kfree(rc);
4182out:
4160 while (!list_empty(&reloc_roots)) { 4183 while (!list_empty(&reloc_roots)) {
4161 reloc_root = list_entry(reloc_roots.next, 4184 reloc_root = list_entry(reloc_roots.next,
4162 struct btrfs_root, root_list); 4185 struct btrfs_root, root_list);