Skip to content

Commit

Permalink
btrfs: hold a ref for the root in btrfs_find_orphan_roots
Browse files Browse the repository at this point in the history
We lookup roots for every orphan item we have, we need to hold a ref on
the root while we're doing this work.

Signed-off-by: Josef Bacik <[email protected]>
Reviewed-by: David Sterba <[email protected]>
Signed-off-by: David Sterba <[email protected]>
  • Loading branch information
josefbacik authored and kdave committed Mar 23, 2020
1 parent 9f58320 commit 0b2dee5
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions fs/btrfs/root-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ int btrfs_find_orphan_roots(struct btrfs_fs_info *fs_info)

root = btrfs_get_fs_root(fs_info, &root_key, false);
err = PTR_ERR_OR_ZERO(root);
if (!err && !btrfs_grab_fs_root(root))
err = -ENOENT;
if (err && err != -ENOENT) {
break;
} else if (err == -ENOENT) {
Expand Down Expand Up @@ -287,6 +289,7 @@ int btrfs_find_orphan_roots(struct btrfs_fs_info *fs_info)
set_bit(BTRFS_ROOT_DEAD_TREE, &root->state);
btrfs_add_dead_root(root);
}
btrfs_put_fs_root(root);
}

btrfs_free_path(path);
Expand Down

0 comments on commit 0b2dee5

Please sign in to comment.