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>
         */
        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;
 
        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,