Commit 76deacf0 authored by Josef Bacik's avatar Josef Bacik Committed by David Sterba
Browse files

btrfs: hold a ref on the root in create_reloc_inode



We're creating a reloc inode in the data reloc tree, we need to hold a
ref on the root while we're doing 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 3d7babdc
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -4351,10 +4351,14 @@ struct inode *create_reloc_inode(struct btrfs_fs_info *fs_info,
	root = read_fs_root(fs_info, BTRFS_DATA_RELOC_TREE_OBJECTID);
	if (IS_ERR(root))
		return ERR_CAST(root);
	if (!btrfs_grab_fs_root(root))
		return ERR_PTR(-ENOENT);

	trans = btrfs_start_transaction(root, 6);
	if (IS_ERR(trans))
	if (IS_ERR(trans)) {
		btrfs_put_fs_root(root);
		return ERR_CAST(trans);
	}

	err = btrfs_find_free_objectid(root, &objectid);
	if (err)
@@ -4372,6 +4376,7 @@ struct inode *create_reloc_inode(struct btrfs_fs_info *fs_info,

	err = btrfs_orphan_add(trans, BTRFS_I(inode));
out:
	btrfs_put_fs_root(root);
	btrfs_end_transaction(trans);
	btrfs_btree_balance_dirty(fs_info);
	if (err) {