diff options
author | Josef Bacik <josef@toxicpanda.com> | 2020-01-24 09:32:28 -0500 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2020-03-23 17:01:27 +0100 |
commit | 9326f76f4bc4f4fc624d2f5263386ac879957867 (patch) | |
tree | 52b28b74c0d35bf39638d5f8ad042d7a2c1404d5 | |
parent | af01d2e53f3343e9f22495e79f07b107374b05a1 (diff) | |
download | linux-9326f76f4bc4f4fc624d2f5263386ac879957867.tar.bz2 |
btrfs: hold a ref on the root in resolve_indirect_ref
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>
-rw-r--r-- | fs/btrfs/backref.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c index e5d85311d5d5..193747b6e1f9 100644 --- a/fs/btrfs/backref.c +++ b/fs/btrfs/backref.c @@ -524,7 +524,13 @@ static int resolve_indirect_ref(struct btrfs_fs_info *fs_info, 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)) { @@ -577,6 +583,8 @@ static int resolve_indirect_ref(struct btrfs_fs_info *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; |