btrfs: release path before calling to btrfs_load_block_group_zone_info
authorJohannes Thumshirn <johannes.thumshirn@wdc.com>
Thu, 4 Feb 2021 10:21:44 +0000 (19:21 +0900)
committerDavid Sterba <dsterba@suse.com>
Tue, 9 Feb 2021 01:32:20 +0000 (02:32 +0100)
commit4afd2fe835a0ff87fb88cba7a7daa881d8e14233
tree70b3a60c496d009afbaf29d7da0d73ea9b6b02b5
parentd6639b35da2d742f9cbcdf8f49f87f2bde9fd479
btrfs: release path before calling to btrfs_load_block_group_zone_info

Since we have no write pointer in conventional zones, we cannot
determine the allocation offset from it. Instead, we set the allocation
offset after the highest addressed extent. This is done by reading the
extent tree in btrfs_load_block_group_zone_info().

However, this function is called from btrfs_read_block_groups(), so the
read lock for the tree node could be recursively taken.

To avoid this unsafe locking scenario, release the path before reading
the extent tree to get the allocation offset.

Reviewed-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/block-group.c