From: Josef Bacik Date: Wed, 20 Nov 2019 19:53:54 +0000 (-0800) Subject: btrfs: hold a ref on the root in find_data_references X-Git-Url: http://git.hungrycats.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1c33f77260e8b7ad2d97dca42859b5cf68449e3e;p=linux 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 --- diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index c3cf582f943f..3b419a4e4829 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -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; }