btrfs: do not init a reloc root if we aren't relocating
authorJosef Bacik <josef@toxicpanda.com>
Wed, 4 Mar 2020 16:18:24 +0000 (11:18 -0500)
committerDavid Sterba <dsterba@suse.com>
Mon, 23 Mar 2020 16:01:57 +0000 (17:01 +0100)
commit2abc726ab4b83db774e315c660ab8da21477092f
tree026a25254b297d0b984a33940c6475b1d1e7447c
parent6217b0fadd4473a16fabc6aecd7527a9f71af534
btrfs: do not init a reloc root if we aren't relocating

We previously were checking if the root had a dead root before accessing
root->reloc_root in order to avoid a use-after-free type bug.  However
this scenario happens after we've unset the reloc control, so we would
have been saved if we'd simply checked for fs_info->reloc_control.  At
this point during relocation we no longer need to be creating new reloc
roots, so simply move this check above the reloc_root checks to avoid
any future races and confusion.

Reviewed-by: Qu Wenruo <wqu@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>
fs/btrfs/relocation.c