]> git.baikalelectronics.ru Git - kernel.git/commit
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)
commite4e50e1b59a55b6ac1e8f3a1bff3ec054d4e0ad4
tree026a25254b297d0b984a33940c6475b1d1e7447c
parentd5752f3fc398784d3f4d5a9b91ef235f6e74f417
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