]> git.hungrycats.org Git - linux/commitdiff
btrfs: hold a ref on the root in merge_reloc_roots
authorJosef Bacik <josef@toxicpanda.com>
Wed, 20 Nov 2019 19:46:11 +0000 (11:46 -0800)
committerJosef Bacik <josef@toxicpanda.com>
Fri, 6 Dec 2019 16:34:48 +0000 (08:34 -0800)
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 <josef@toxicpanda.com>
fs/btrfs/relocation.c

index 19d69ce41f061faf84b24187f6920d42e3ea7651..dfd3d9053301b8e9153a7a98fb3ee7b73aafc16b 100644 (file)
@@ -2505,10 +2505,13 @@ again:
                if (btrfs_root_refs(&reloc_root->root_item) > 0) {
                        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);
 
                        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,