]> git.hungrycats.org Git - linux/commitdiff
btrfs: grab a ref on the root in relink_extent_backref
authorJosef Bacik <josef@toxicpanda.com>
Wed, 20 Nov 2019 16:07:31 +0000 (08:07 -0800)
committerJosef Bacik <josef@toxicpanda.com>
Fri, 6 Dec 2019 16:34:48 +0000 (08:34 -0800)
We're doing an arbitrary lookup on an fs_root, we need to hold a ref on
that root.

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

index 88f3d6eace7a31f31c31de0397a54a9d7bd28fde..3dc9bc9530e2aeeb1507487ee4f9988abc550c02 100644 (file)
@@ -2711,6 +2711,9 @@ static noinline int relink_extent_backref(struct btrfs_path *path,
                return PTR_ERR(root);
        }
 
+       if (!btrfs_grab_fs_root(root))
+               return 0;
+
        if (btrfs_root_readonly(root)) {
                srcu_read_unlock(&fs_info->subvol_srcu, index);
                return 0;
@@ -2722,6 +2725,7 @@ static noinline int relink_extent_backref(struct btrfs_path *path,
        key.offset = 0;
 
        inode = btrfs_iget(fs_info->sb, &key, root);
+       btrfs_put_fs_root(root);
        if (IS_ERR(inode)) {
                srcu_read_unlock(&fs_info->subvol_srcu, index);
                return 0;