aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/relocation.c
diff options
context:
space:
mode:
authorTsutomu Itoh <t-itoh@jp.fujitsu.com>2011-01-24 21:51:38 -0500
committerChris Mason <chris.mason@oracle.com>2011-01-28 16:40:37 -0500
commit3612b49598c303cfb22a4b609427f829828e2427 (patch)
treed0e9eabb176777ab80af5d78eab0555044172370 /fs/btrfs/relocation.c
parent34d19bada00f4825588b338a8ee193820f9ceeb0 (diff)
btrfs: fix return value check of btrfs_join_transaction()
The error check of btrfs_join_transaction()/btrfs_join_transaction_nolock() is added, and the mistake of the error check in several places is corrected. For more stable Btrfs, I think that we should reduce BUG_ON(). But, I think that long time is necessary for this. So, I propose this patch as a short-term solution. With this patch: - To more stable Btrfs, the part that should be corrected is clarified. - The panic isn't done by the NULL pointer reference etc. (even if BUG_ON() is increased temporarily) - The error code is returned in the place where the error can be easily returned. As a long-term plan: - BUG_ON() is reduced by using the forced-readonly framework, etc. Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/relocation.c')
-rw-r--r--fs/btrfs/relocation.c26
1 files changed, 23 insertions, 3 deletions
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 045c9c2b2d7e..ea9965430241 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -2147,6 +2147,12 @@ again:
2147 } 2147 }
2148 2148
2149 trans = btrfs_join_transaction(rc->extent_root, 1); 2149 trans = btrfs_join_transaction(rc->extent_root, 1);
2150 if (IS_ERR(trans)) {
2151 if (!err)
2152 btrfs_block_rsv_release(rc->extent_root,
2153 rc->block_rsv, num_bytes);
2154 return PTR_ERR(trans);
2155 }
2150 2156
2151 if (!err) { 2157 if (!err) {
2152 if (num_bytes != rc->merging_rsv_size) { 2158 if (num_bytes != rc->merging_rsv_size) {
@@ -3222,6 +3228,7 @@ truncate:
3222 trans = btrfs_join_transaction(root, 0); 3228 trans = btrfs_join_transaction(root, 0);
3223 if (IS_ERR(trans)) { 3229 if (IS_ERR(trans)) {
3224 btrfs_free_path(path); 3230 btrfs_free_path(path);
3231 ret = PTR_ERR(trans);
3225 goto out; 3232 goto out;
3226 } 3233 }
3227 3234
@@ -3628,6 +3635,7 @@ int prepare_to_relocate(struct reloc_control *rc)
3628 set_reloc_control(rc); 3635 set_reloc_control(rc);
3629 3636
3630 trans = btrfs_join_transaction(rc->extent_root, 1); 3637 trans = btrfs_join_transaction(rc->extent_root, 1);
3638 BUG_ON(IS_ERR(trans));
3631 btrfs_commit_transaction(trans, rc->extent_root); 3639 btrfs_commit_transaction(trans, rc->extent_root);
3632 return 0; 3640 return 0;
3633} 3641}
@@ -3804,7 +3812,10 @@ static noinline_for_stack int relocate_block_group(struct reloc_control *rc)
3804 3812
3805 /* get rid of pinned extents */ 3813 /* get rid of pinned extents */
3806 trans = btrfs_join_transaction(rc->extent_root, 1); 3814 trans = btrfs_join_transaction(rc->extent_root, 1);
3807 btrfs_commit_transaction(trans, rc->extent_root); 3815 if (IS_ERR(trans))
3816 err = PTR_ERR(trans);
3817 else
3818 btrfs_commit_transaction(trans, rc->extent_root);
3808out_free: 3819out_free:
3809 btrfs_free_block_rsv(rc->extent_root, rc->block_rsv); 3820 btrfs_free_block_rsv(rc->extent_root, rc->block_rsv);
3810 btrfs_free_path(path); 3821 btrfs_free_path(path);
@@ -4125,6 +4136,11 @@ int btrfs_recover_relocation(struct btrfs_root *root)
4125 set_reloc_control(rc); 4136 set_reloc_control(rc);
4126 4137
4127 trans = btrfs_join_transaction(rc->extent_root, 1); 4138 trans = btrfs_join_transaction(rc->extent_root, 1);
4139 if (IS_ERR(trans)) {
4140 unset_reloc_control(rc);
4141 err = PTR_ERR(trans);
4142 goto out_free;
4143 }
4128 4144
4129 rc->merge_reloc_tree = 1; 4145 rc->merge_reloc_tree = 1;
4130 4146
@@ -4154,9 +4170,13 @@ int btrfs_recover_relocation(struct btrfs_root *root)
4154 unset_reloc_control(rc); 4170 unset_reloc_control(rc);
4155 4171
4156 trans = btrfs_join_transaction(rc->extent_root, 1); 4172 trans = btrfs_join_transaction(rc->extent_root, 1);
4157 btrfs_commit_transaction(trans, rc->extent_root); 4173 if (IS_ERR(trans))
4158out: 4174 err = PTR_ERR(trans);
4175 else
4176 btrfs_commit_transaction(trans, rc->extent_root);
4177out_free:
4159 kfree(rc); 4178 kfree(rc);
4179out:
4160 while (!list_empty(&reloc_roots)) { 4180 while (!list_empty(&reloc_roots)) {
4161 reloc_root = list_entry(reloc_roots.next, 4181 reloc_root = list_entry(reloc_roots.next,
4162 struct btrfs_root, root_list); 4182 struct btrfs_root, root_list);