Skip to content

Commit 9e3aa80

Browse files
josefbacikkdave
authored andcommitted
btrfs: free data reloc tree on failed mount
While testing a weird problem with -o degraded, I noticed I was getting leaked root errors BTRFS warning (device loop0): writable mount is not allowed due to too many missing devices BTRFS error (device loop0): open_ctree failed BTRFS error (device loop0): leaked root -9-0 refcount 1 This is the DATA_RELOC root, which gets read before the other fs roots, but is included in the fs roots radix tree. Handle this by adding a btrfs_drop_and_free_fs_root() on the data reloc root if it exists. This is ok to do here if we fail further up because we will only drop the ref if we delete the root from the radix tree, and all other cleanup won't be duplicated. CC: stable@vger.kernel.org # 5.8+ Reviewed-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: Josef Bacik <josef@toxicpanda.com> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent ea57788 commit 9e3aa80

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

fs/btrfs/disk-io.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3441,6 +3441,8 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device
34413441
btrfs_put_block_group_cache(fs_info);
34423442

34433443
fail_tree_roots:
3444+
if (fs_info->data_reloc_root)
3445+
btrfs_drop_and_free_fs_root(fs_info, fs_info->data_reloc_root);
34443446
free_root_pointers(fs_info, true);
34453447
invalidate_inode_pages2(fs_info->btree_inode->i_mapping);
34463448

0 commit comments

Comments
 (0)