summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/relocation.c
diff options
context:
space:
mode:
authorJosef Bacik2013-07-23 22:57:15 +0200
committerChris Mason2013-09-01 14:04:24 +0200
commitb37b39cd6b8af7a7c39fc7340d71f3db492af9e2 (patch)
tree9c76260f5ce3d17d48e4669ac40d7fa8149151fc /fs/btrfs/relocation.c
parentBtrfs: reset ret in record_one_backref (diff)
downloadkernel-qcow2-linux-b37b39cd6b8af7a7c39fc7340d71f3db492af9e2.tar.gz
kernel-qcow2-linux-b37b39cd6b8af7a7c39fc7340d71f3db492af9e2.tar.xz
kernel-qcow2-linux-b37b39cd6b8af7a7c39fc7340d71f3db492af9e2.zip
Btrfs: cleanup reloc roots properly on error
I was hitting the BUG_ON() at the end of merge_reloc_roots() because we were aborting the transaction at some point previously and then getting an error when we tried to drop the reloc root. I fixed btrfs_drop_snapshot to re-add us to the dead roots list if we failed, but this isn't the right thing to do for reloc roots since it uses root->root_list for it's own stuff in order to know what needs to be cleaned up. So fix btrfs_drop_snapshot to only do the re-add if we aren't dropping for reloc, and handle errors from merge_reloc_root() by dropping the reloc root we are processing since it won't be on the list of roots to cleanup. With this patch my reproducer no longer panics. Thanks, Signed-off-by: Josef Bacik <jbacik@fusionio.com> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'fs/btrfs/relocation.c')
-rw-r--r--fs/btrfs/relocation.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 295a6115c326..5a23d875ab40 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -2314,8 +2314,13 @@ again:
BUG_ON(root->reloc_root != reloc_root);
ret = merge_reloc_root(rc, root);
- if (ret)
+ if (ret) {
+ __update_reloc_root(reloc_root, 1);
+ free_extent_buffer(reloc_root->node);
+ free_extent_buffer(reloc_root->commit_root);
+ kfree(reloc_root);
goto out;
+ }
} else {
list_del_init(&reloc_root->root_list);
}