Commit 442b1ac5 authored by Josef Bacik's avatar Josef Bacik Committed by David Sterba
Browse files

btrfs: hold a ref on the root in record_reloc_root_in_trans



We are recording this root in the transaction, so we need to hold a ref
on it until we do that.

Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent ab9737bd
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -2648,15 +2648,19 @@ static int record_reloc_root_in_trans(struct btrfs_trans_handle *trans,
{
	struct btrfs_fs_info *fs_info = reloc_root->fs_info;
	struct btrfs_root *root;
	int ret;

	if (reloc_root->last_trans == trans->transid)
		return 0;

	root = read_fs_root(fs_info, reloc_root->root_key.offset);
	BUG_ON(IS_ERR(root));
	BUG_ON(!btrfs_grab_fs_root(root));
	BUG_ON(root->reloc_root != reloc_root);
	ret = btrfs_record_root_in_trans(trans, root);
	btrfs_put_fs_root(root);

	return btrfs_record_root_in_trans(trans, root);
	return ret;
}

static noinline_for_stack