Commit 4c78e9f5 authored by Josef Bacik's avatar Josef Bacik Committed by David Sterba

btrfs: hold a ref on the root in open_ctree

We lookup the fs_root and put it in our fs_info directly, we should hold
a ref on this root for the lifetime of the fs_info.
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 0d4b0463
...@@ -1537,6 +1537,7 @@ void btrfs_free_fs_info(struct btrfs_fs_info *fs_info) ...@@ -1537,6 +1537,7 @@ void btrfs_free_fs_info(struct btrfs_fs_info *fs_info)
kfree(fs_info->free_space_root); kfree(fs_info->free_space_root);
kfree(fs_info->super_copy); kfree(fs_info->super_copy);
kfree(fs_info->super_for_commit); kfree(fs_info->super_for_commit);
btrfs_put_fs_root(fs_info->fs_root);
kvfree(fs_info); kvfree(fs_info);
} }
...@@ -3206,6 +3207,13 @@ int __cold open_ctree(struct super_block *sb, ...@@ -3206,6 +3207,13 @@ int __cold open_ctree(struct super_block *sb,
goto fail_qgroup; goto fail_qgroup;
} }
if (!btrfs_grab_fs_root(fs_info->fs_root)) {
fs_info->fs_root = NULL;
err = -ENOENT;
btrfs_warn(fs_info, "failed to grab a ref on the fs tree");
goto fail_qgroup;
}
if (sb_rdonly(sb)) if (sb_rdonly(sb))
return 0; return 0;
......
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