Commit fc92f798 authored by Josef Bacik's avatar Josef Bacik Committed by David Sterba

btrfs: hold a ref on the root in create_subvol

We're creating the new root here, but we should hold the ref until after
we've initialized the inode for it.
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 8727002f
...@@ -672,10 +672,16 @@ static noinline int create_subvol(struct inode *dir, ...@@ -672,10 +672,16 @@ static noinline int create_subvol(struct inode *dir,
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
goto fail; goto fail;
} }
if (!btrfs_grab_fs_root(new_root)) {
ret = -ENOENT;
btrfs_abort_transaction(trans, ret);
goto fail;
}
btrfs_record_root_in_trans(trans, new_root); btrfs_record_root_in_trans(trans, new_root);
ret = btrfs_create_subvol_root(trans, new_root, root, new_dirid); ret = btrfs_create_subvol_root(trans, new_root, root, new_dirid);
btrfs_put_fs_root(new_root);
if (ret) { if (ret) {
/* We potentially lose an unused inode item here */ /* We potentially lose an unused inode item here */
btrfs_abort_transaction(trans, ret); btrfs_abort_transaction(trans, ret);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment