diff options
author | Jeff Mahoney <jeffm@suse.com> | 2011-10-03 23:23:15 -0400 |
---|---|---|
committer | David Sterba <dsterba@suse.cz> | 2012-03-21 20:45:34 -0400 |
commit | ffd7b33944f4573a063af7a55f8a5199c8185665 (patch) | |
tree | bb7b3b2293bedc58b0d09f146ef68d0614432072 /fs/btrfs | |
parent | 355808c296c6923db6705f43639969a80b16d15d (diff) |
btrfs: __add_reloc_root error push-up
This patch pushes kmalloc errors up to the caller and BUGs in the caller.
The BUG_ON for duplicate reloc tree root insertion is replaced with a
panic explaining the issue.
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/relocation.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index e5996ff8aaa4..974b0dfeffa3 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c | |||
@@ -1221,14 +1221,15 @@ fail: | |||
1221 | /* | 1221 | /* |
1222 | * helper to add 'address of tree root -> reloc tree' mapping | 1222 | * helper to add 'address of tree root -> reloc tree' mapping |
1223 | */ | 1223 | */ |
1224 | static int __add_reloc_root(struct btrfs_root *root) | 1224 | static int __must_check __add_reloc_root(struct btrfs_root *root) |
1225 | { | 1225 | { |
1226 | struct rb_node *rb_node; | 1226 | struct rb_node *rb_node; |
1227 | struct mapping_node *node; | 1227 | struct mapping_node *node; |
1228 | struct reloc_control *rc = root->fs_info->reloc_ctl; | 1228 | struct reloc_control *rc = root->fs_info->reloc_ctl; |
1229 | 1229 | ||
1230 | node = kmalloc(sizeof(*node), GFP_NOFS); | 1230 | node = kmalloc(sizeof(*node), GFP_NOFS); |
1231 | BUG_ON(!node); | 1231 | if (!node) |
1232 | return -ENOMEM; | ||
1232 | 1233 | ||
1233 | node->bytenr = root->node->start; | 1234 | node->bytenr = root->node->start; |
1234 | node->data = root; | 1235 | node->data = root; |
@@ -1237,7 +1238,12 @@ static int __add_reloc_root(struct btrfs_root *root) | |||
1237 | rb_node = tree_insert(&rc->reloc_root_tree.rb_root, | 1238 | rb_node = tree_insert(&rc->reloc_root_tree.rb_root, |
1238 | node->bytenr, &node->rb_node); | 1239 | node->bytenr, &node->rb_node); |
1239 | spin_unlock(&rc->reloc_root_tree.lock); | 1240 | spin_unlock(&rc->reloc_root_tree.lock); |
1240 | BUG_ON(rb_node); | 1241 | if (rb_node) { |
1242 | kfree(node); | ||
1243 | btrfs_panic(root->fs_info, -EEXIST, "Duplicate root found " | ||
1244 | "for start=%llu while inserting into relocation " | ||
1245 | "tree\n"); | ||
1246 | } | ||
1241 | 1247 | ||
1242 | list_add_tail(&root->root_list, &rc->reloc_roots); | 1248 | list_add_tail(&root->root_list, &rc->reloc_roots); |
1243 | return 0; | 1249 | return 0; |
@@ -1353,6 +1359,7 @@ int btrfs_init_reloc_root(struct btrfs_trans_handle *trans, | |||
1353 | struct btrfs_root *reloc_root; | 1359 | struct btrfs_root *reloc_root; |
1354 | struct reloc_control *rc = root->fs_info->reloc_ctl; | 1360 | struct reloc_control *rc = root->fs_info->reloc_ctl; |
1355 | int clear_rsv = 0; | 1361 | int clear_rsv = 0; |
1362 | int ret; | ||
1356 | 1363 | ||
1357 | if (root->reloc_root) { | 1364 | if (root->reloc_root) { |
1358 | reloc_root = root->reloc_root; | 1365 | reloc_root = root->reloc_root; |
@@ -1372,7 +1379,8 @@ int btrfs_init_reloc_root(struct btrfs_trans_handle *trans, | |||
1372 | if (clear_rsv) | 1379 | if (clear_rsv) |
1373 | trans->block_rsv = NULL; | 1380 | trans->block_rsv = NULL; |
1374 | 1381 | ||
1375 | __add_reloc_root(reloc_root); | 1382 | ret = __add_reloc_root(reloc_root); |
1383 | BUG_ON(ret < 0); | ||
1376 | root->reloc_root = reloc_root; | 1384 | root->reloc_root = reloc_root; |
1377 | return 0; | 1385 | return 0; |
1378 | } | 1386 | } |
@@ -4226,7 +4234,8 @@ int btrfs_recover_relocation(struct btrfs_root *root) | |||
4226 | reloc_root->root_key.offset); | 4234 | reloc_root->root_key.offset); |
4227 | BUG_ON(IS_ERR(fs_root)); | 4235 | BUG_ON(IS_ERR(fs_root)); |
4228 | 4236 | ||
4229 | __add_reloc_root(reloc_root); | 4237 | err = __add_reloc_root(reloc_root); |
4238 | BUG_ON(err < 0); | ||
4230 | fs_root->reloc_root = reloc_root; | 4239 | fs_root->reloc_root = reloc_root; |
4231 | } | 4240 | } |
4232 | 4241 | ||
@@ -4428,7 +4437,8 @@ void btrfs_reloc_post_snapshot(struct btrfs_trans_handle *trans, | |||
4428 | reloc_root = create_reloc_root(trans, root->reloc_root, | 4437 | reloc_root = create_reloc_root(trans, root->reloc_root, |
4429 | new_root->root_key.objectid); | 4438 | new_root->root_key.objectid); |
4430 | 4439 | ||
4431 | __add_reloc_root(reloc_root); | 4440 | ret = __add_reloc_root(reloc_root); |
4441 | BUG_ON(ret < 0); | ||
4432 | new_root->reloc_root = reloc_root; | 4442 | new_root->reloc_root = reloc_root; |
4433 | 4443 | ||
4434 | if (rc->create_reloc_tree) { | 4444 | if (rc->create_reloc_tree) { |