btrfs: zoned: move btrfs_free_excluded_extents out of btrfs_calc_zone_unusable
authorNaohiro Aota <naohiro.aota@wdc.com>
Thu, 19 Aug 2021 12:19:09 +0000 (21:19 +0900)
committerDavid Sterba <dsterba@suse.com>
Tue, 26 Oct 2021 17:07:58 +0000 (19:07 +0200)
btrfs_free_excluded_extents() is not neccessary for
btrfs_calc_zone_unusable() and it makes btrfs_calc_zone_unusable()
difficult to reuse. Move it out and call btrfs_free_excluded_extents()
in proper context.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/block-group.c
fs/btrfs/zoned.c

index 64c4685bd7706464f08a898ec77571d558697386..4f43825ac75453c629353154b4f6f64227cdf487 100644 (file)
@@ -2035,6 +2035,8 @@ static int read_one_block_group(struct btrfs_fs_info *info,
         */
        if (btrfs_is_zoned(info)) {
                btrfs_calc_zone_unusable(cache);
+               /* Should not have any excluded extents. Just in case, though. */
+               btrfs_free_excluded_extents(cache);
        } else if (cache->length == cache->used) {
                cache->last_byte_to_unpin = (u64)-1;
                cache->cached = BTRFS_CACHE_FINISHED;
index 10ea5c12c4baec36628123397b767880ff570534..dd545af225e86e3ccf71b9ada40187de725303be 100644 (file)
@@ -1273,9 +1273,6 @@ void btrfs_calc_zone_unusable(struct btrfs_block_group *cache)
        cache->cached = BTRFS_CACHE_FINISHED;
        cache->free_space_ctl->free_space = free;
        cache->zone_unusable = unusable;
-
-       /* Should not have any excluded extents. Just in case, though */
-       btrfs_free_excluded_extents(cache);
 }
 
 void btrfs_redirty_list_add(struct btrfs_transaction *trans,