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