Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 361002
b: refs/heads/master
c: aca1bba
h: refs/heads/master
v: v3
  • Loading branch information
Liu Bo authored and Josef Bacik committed Mar 4, 2013
1 parent bff1e02 commit b3afbd7
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 13 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: 8f71f3e0e4fb5a2445fb93d3057a33aefc4aa30d
refs/heads/master: aca1bba6f9bc550a33312b28e98b3de5ddb3bb15
47 changes: 35 additions & 12 deletions trunk/fs/btrfs/relocation.c
Original file line number Diff line number Diff line change
Expand Up @@ -2239,14 +2239,29 @@ int prepare_to_merge(struct reloc_control *rc, int err)
return err;
}

static noinline_for_stack
void free_reloc_roots(struct list_head *list)
{
struct btrfs_root *reloc_root;

while (!list_empty(list)) {
reloc_root = list_entry(list->next, struct btrfs_root,
root_list);
__update_reloc_root(reloc_root, 1);
free_extent_buffer(reloc_root->node);
free_extent_buffer(reloc_root->commit_root);
kfree(reloc_root);
}
}

static noinline_for_stack
int merge_reloc_roots(struct reloc_control *rc)
{
struct btrfs_root *root;
struct btrfs_root *reloc_root;
LIST_HEAD(reloc_roots);
int found = 0;
int ret;
int ret = 0;
again:
root = rc->extent_root;

Expand All @@ -2272,20 +2287,33 @@ int merge_reloc_roots(struct reloc_control *rc)
BUG_ON(root->reloc_root != reloc_root);

ret = merge_reloc_root(rc, root);
BUG_ON(ret);
if (ret)
goto out;
} else {
list_del_init(&reloc_root->root_list);
}
ret = btrfs_drop_snapshot(reloc_root, rc->block_rsv, 0, 1);
BUG_ON(ret < 0);
if (ret < 0) {
if (list_empty(&reloc_root->root_list))
list_add_tail(&reloc_root->root_list,
&reloc_roots);
goto out;
}
}

if (found) {
found = 0;
goto again;
}
out:
if (ret) {
btrfs_std_error(root->fs_info, ret);
if (!list_empty(&reloc_roots))
free_reloc_roots(&reloc_roots);
}

BUG_ON(!RB_EMPTY_ROOT(&rc->reloc_root_tree.rb_root));
return 0;
return ret;
}

static void free_block_list(struct rb_root *blocks)
Expand Down Expand Up @@ -4266,14 +4294,9 @@ int btrfs_recover_relocation(struct btrfs_root *root)
out_free:
kfree(rc);
out:
while (!list_empty(&reloc_roots)) {
reloc_root = list_entry(reloc_roots.next,
struct btrfs_root, root_list);
list_del(&reloc_root->root_list);
free_extent_buffer(reloc_root->node);
free_extent_buffer(reloc_root->commit_root);
kfree(reloc_root);
}
if (!list_empty(&reloc_roots))
free_reloc_roots(&reloc_roots);

btrfs_free_path(path);

if (err == 0) {
Expand Down

0 comments on commit b3afbd7

Please sign in to comment.