Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b37b39cd authored by Josef Bacik's avatar Josef Bacik Committed by Chris Mason
Browse files

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: default avatarJosef Bacik <jbacik@fusionio.com>
Signed-off-by: default avatarChris Mason <chris.mason@fusionio.com>
parent 50f1319c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -7696,7 +7696,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
	 * don't have it in the radix (like when we recover after a power fail
	 * or unmount) so we don't leak memory.
	 */
	if (root_dropped == false)
	if (!for_reloc && root_dropped == false)
		btrfs_add_dead_root(root);
	if (err)
		btrfs_std_error(root->fs_info, err);
+6 −1
Original line number Diff line number Diff line
@@ -2314,8 +2314,13 @@ int merge_reloc_roots(struct reloc_control *rc)
			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);
		}