Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 297870
b: refs/heads/master
c: ffd7b33
h: refs/heads/master
v: v3
  • Loading branch information
Jeff Mahoney authored and David Sterba committed Mar 22, 2012
1 parent ebbd46a commit a6ef5cc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 355808c296c6923db6705f43639969a80b16d15d
refs/heads/master: ffd7b33944f4573a063af7a55f8a5199c8185665
22 changes: 16 additions & 6 deletions trunk/fs/btrfs/relocation.c
Original file line number Diff line number Diff line change
Expand Up @@ -1221,14 +1221,15 @@ static int clone_backref_node(struct btrfs_trans_handle *trans,
/*
* helper to add 'address of tree root -> reloc tree' mapping
*/
static int __add_reloc_root(struct btrfs_root *root)
static int __must_check __add_reloc_root(struct btrfs_root *root)
{
struct rb_node *rb_node;
struct mapping_node *node;
struct reloc_control *rc = root->fs_info->reloc_ctl;

node = kmalloc(sizeof(*node), GFP_NOFS);
BUG_ON(!node);
if (!node)
return -ENOMEM;

node->bytenr = root->node->start;
node->data = root;
Expand All @@ -1237,7 +1238,12 @@ static int __add_reloc_root(struct btrfs_root *root)
rb_node = tree_insert(&rc->reloc_root_tree.rb_root,
node->bytenr, &node->rb_node);
spin_unlock(&rc->reloc_root_tree.lock);
BUG_ON(rb_node);
if (rb_node) {
kfree(node);
btrfs_panic(root->fs_info, -EEXIST, "Duplicate root found "
"for start=%llu while inserting into relocation "
"tree\n");
}

list_add_tail(&root->root_list, &rc->reloc_roots);
return 0;
Expand Down Expand Up @@ -1353,6 +1359,7 @@ int btrfs_init_reloc_root(struct btrfs_trans_handle *trans,
struct btrfs_root *reloc_root;
struct reloc_control *rc = root->fs_info->reloc_ctl;
int clear_rsv = 0;
int ret;

if (root->reloc_root) {
reloc_root = root->reloc_root;
Expand All @@ -1372,7 +1379,8 @@ int btrfs_init_reloc_root(struct btrfs_trans_handle *trans,
if (clear_rsv)
trans->block_rsv = NULL;

__add_reloc_root(reloc_root);
ret = __add_reloc_root(reloc_root);
BUG_ON(ret < 0);
root->reloc_root = reloc_root;
return 0;
}
Expand Down Expand Up @@ -4226,7 +4234,8 @@ int btrfs_recover_relocation(struct btrfs_root *root)
reloc_root->root_key.offset);
BUG_ON(IS_ERR(fs_root));

__add_reloc_root(reloc_root);
err = __add_reloc_root(reloc_root);
BUG_ON(err < 0);
fs_root->reloc_root = reloc_root;
}

Expand Down Expand Up @@ -4428,7 +4437,8 @@ void btrfs_reloc_post_snapshot(struct btrfs_trans_handle *trans,
reloc_root = create_reloc_root(trans, root->reloc_root,
new_root->root_key.objectid);

__add_reloc_root(reloc_root);
ret = __add_reloc_root(reloc_root);
BUG_ON(ret < 0);
new_root->reloc_root = reloc_root;

if (rc->create_reloc_tree) {
Expand Down

0 comments on commit a6ef5cc

Please sign in to comment.