]> git.hungrycats.org Git - linux/commitdiff
btrfs: hold a ref on the root in prepare_to_merge
authorJosef Bacik <josef@toxicpanda.com>
Wed, 20 Nov 2019 19:45:06 +0000 (11:45 -0800)
committerJosef Bacik <josef@toxicpanda.com>
Fri, 6 Dec 2019 16:34:48 +0000 (08:34 -0800)
We look up the reloc roots corresponding root, we need to hold a ref on
that root.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
fs/btrfs/relocation.c

index 473bbbd58d31be80077f22bf385bf94417b3a275..19d69ce41f061faf84b24187f6920d42e3ea7651 100644 (file)
@@ -2433,6 +2433,8 @@ again:
                list_del_init(&reloc_root->root_list);
 
                root = read_fs_root(fs_info, reloc_root->root_key.offset);
+               if (!btrfs_grab_fs_root(root))
+                       BUG();
                BUG_ON(IS_ERR(root));
                BUG_ON(root->reloc_root != reloc_root);
 
@@ -2445,6 +2447,7 @@ again:
                btrfs_update_reloc_root(trans, root);
 
                list_add(&reloc_root->root_list, &reloc_roots);
+               btrfs_put_fs_root(root);
        }
 
        list_splice(&reloc_roots, &rc->reloc_roots);