diff options
author | Josef Bacik <josef@toxicpanda.com> | 2020-01-24 09:32:42 -0500 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2020-03-23 17:01:30 +0100 |
commit | 3d7babdcf2cc87367e694f9b67460dde22c48319 (patch) | |
tree | 8dd0d344e51fc369cb5639a6b2acddd497da1e7e | |
parent | 442b1ac5244ea2dc09d8aa688b41e0a0c4634b0a (diff) |
btrfs: hold a ref on the root in find_data_references
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>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r-- | fs/btrfs/relocation.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index 0336a48d7d96..976917ca412a 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -3751,7 +3751,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; @@ -3864,6 +3868,8 @@ next: } out: + btrfs_put_fs_root(root); +out_free: btrfs_free_path(path); return err; } |