diff options
author | Josef Bacik <josef@toxicpanda.com> | 2020-01-24 09:32:54 -0500 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2020-03-23 17:01:32 +0100 |
commit | 4c78e9f59632b5e635e51db9b68111288b38ff22 (patch) | |
tree | 3a60556c8ce681569acd91d146de3021f5427df4 /fs/btrfs | |
parent | 0d4b0463011de06288d8ca80a873a97a7d99a948 (diff) | |
download | linux-4c78e9f59632b5e635e51db9b68111288b38ff22.tar.bz2 |
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: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r-- | fs/btrfs/disk-io.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index ce36a4b9c8a3..76b888728540 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c @@ -1537,6 +1537,7 @@ void btrfs_free_fs_info(struct btrfs_fs_info *fs_info) kfree(fs_info->free_space_root); kfree(fs_info->super_copy); kfree(fs_info->super_for_commit); + btrfs_put_fs_root(fs_info->fs_root); kvfree(fs_info); } @@ -3206,6 +3207,13 @@ int __cold open_ctree(struct super_block *sb, 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)) return 0; |