diff options
author | Josef Bacik <josef@toxicpanda.com> | 2020-01-24 09:32:46 -0500 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2020-02-10 14:40:32 +0100 |
commit | 63fdd9ee72727bfaa2464c579cf46762e109ad99 (patch) | |
tree | 811cf45b3c6619849fc6c98d800c4960b8aee158 | |
parent | a774641bd8fca715af2f1b3bf678aa10f6f8d531 (diff) | |
download | btrfs-next-63fdd9ee72727bfaa2464c579cf46762e109ad99.tar.gz |
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: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r-- | fs/btrfs/root-tree.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/btrfs/root-tree.c b/fs/btrfs/root-tree.c index 1ea4a35a0830fe..a32632f439870b 100644 --- a/fs/btrfs/root-tree.c +++ b/fs/btrfs/root-tree.c @@ -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) { @@ -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); |