We're looking up a random root, we need to hold a ref on it while we're
using it.
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
if (IS_ERR(root)) {
srcu_read_unlock(&fs_info->subvol_srcu, index);
ret = PTR_ERR(root);
- goto out;
+ goto out_free;
+ }
+
+ if (!btrfs_grab_fs_root(root)) {
+ srcu_read_unlock(&fs_info->subvol_srcu, index);
+ ret = -ENOENT;
+ goto out_free;
}
if (btrfs_is_testing(fs_info)) {
ret = add_all_parents(root, path, parents, ref, level, time_seq,
extent_item_pos, total_refs, ignore_offset);
out:
+ btrfs_put_fs_root(root);
+out_free:
path->lowest_level = 0;
btrfs_release_path(path);
return ret;