On Fri, Jan 24, 2020 at 09:32:44AM -0500, Josef Bacik wrote:
> We look up the fs root in various places in here when recovering from a
> crashed relcoation. Make sure we hold a ref on the root whenever we
> look them up.
>
> Signed-off-by: Josef Bacik <josef@xxxxxxxxxxxxxx>
> ---
> fs/btrfs/relocation.c | 21 ++++++++++++++++++---
> 1 file changed, 18 insertions(+), 3 deletions(-)
>
> diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
> index 9531739b5a8c..81f383df8f63 100644
> --- a/fs/btrfs/relocation.c
> +++ b/fs/btrfs/relocation.c
> @@ -4593,6 +4593,10 @@ int btrfs_recover_relocation(struct btrfs_root *root)
> if (btrfs_root_refs(&reloc_root->root_item) > 0) {
> fs_root = read_fs_root(fs_info,
> reloc_root->root_key.offset);
> + if (!btrfs_grab_fs_root(fs_root)) {
> + err = -ENOENT;
> + goto out;
> + }
> if (IS_ERR(fs_root)) {
Also in the wrong order.
> ret = PTR_ERR(fs_root);
> if (ret != -ENOENT) {