]> git.hungrycats.org Git - linux/commitdiff
btrfs: hold a ref on the root in find_data_references
authorJosef Bacik <josef@toxicpanda.com>
Wed, 20 Nov 2019 19:53:54 +0000 (11:53 -0800)
committerJosef Bacik <josef@toxicpanda.com>
Fri, 6 Dec 2019 16:34:48 +0000 (08:34 -0800)
We're looking up the data references for the bytenr in a root, we need
to hold a ref on that root while we're doing that.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
fs/btrfs/relocation.c

index c3cf582f943f3e69d5af80c84cdcd379289a6c1f..3b419a4e48290b9d041afda50499822b39507f27 100644 (file)
@@ -3669,7 +3669,11 @@ static int find_data_references(struct reloc_control *rc,
        root = read_fs_root(fs_info, ref_root);
        if (IS_ERR(root)) {
                err = PTR_ERR(root);
-               goto out;
+               goto out_free;
+       }
+       if (!btrfs_grab_fs_root(root)) {
+               err = -ENOENT;
+               goto out_free;
        }
 
        key.objectid = ref_objectid;
@@ -3782,6 +3786,8 @@ next:
 
        }
 out:
+       btrfs_put_fs_root(root);
+out_free:
        btrfs_free_path(path);
        return err;
 }