From: Josef Bacik Date: Fri, 24 Jan 2020 14:32:40 +0000 (-0500) Subject: btrfs: hold a ref on the root in merge_reloc_roots X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=ab9737bd759741a56641d627e6a2025be18c91f9;p=openwrt%2Fstaging%2Fblogic.git btrfs: hold a ref on the root in merge_reloc_roots We look up the corresponding root for the reloc root, we need to hold a ref while we're messing with it. Signed-off-by: Josef Bacik Reviewed-by: David Sterba Signed-off-by: David Sterba --- diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index b85850823a1b..679dd3958ff2 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -2592,9 +2592,11 @@ again: root = read_fs_root(fs_info, reloc_root->root_key.offset); BUG_ON(IS_ERR(root)); + BUG_ON(!btrfs_grab_fs_root(root)); BUG_ON(root->reloc_root != reloc_root); ret = merge_reloc_root(rc, root); + btrfs_put_fs_root(root); if (ret) { if (list_empty(&reloc_root->root_list)) list_add_tail(&reloc_root->root_list,