Commit 0b2dee5c authored by Josef Bacik's avatar Josef Bacik Committed by David Sterba

btrfs: hold a ref for the root in btrfs_find_orphan_roots

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: default avatarJosef Bacik <josef@toxicpanda.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 9f583209
...@@ -257,6 +257,8 @@ int btrfs_find_orphan_roots(struct btrfs_fs_info *fs_info) ...@@ -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); root = btrfs_get_fs_root(fs_info, &root_key, false);
err = PTR_ERR_OR_ZERO(root); err = PTR_ERR_OR_ZERO(root);
if (!err && !btrfs_grab_fs_root(root))
err = -ENOENT;
if (err && err != -ENOENT) { if (err && err != -ENOENT) {
break; break;
} else if (err == -ENOENT) { } else if (err == -ENOENT) {
...@@ -287,6 +289,7 @@ int btrfs_find_orphan_roots(struct btrfs_fs_info *fs_info) ...@@ -287,6 +289,7 @@ int btrfs_find_orphan_roots(struct btrfs_fs_info *fs_info)
set_bit(BTRFS_ROOT_DEAD_TREE, &root->state); set_bit(BTRFS_ROOT_DEAD_TREE, &root->state);
btrfs_add_dead_root(root); btrfs_add_dead_root(root);
} }
btrfs_put_fs_root(root);
} }
btrfs_free_path(path); btrfs_free_path(path);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment