Skip to content

Commit

Permalink
btrfs: zoned: move non-changing condition check out of the loop
Browse files Browse the repository at this point in the history
btrfs_zone_activate() checks if block_group->alloc_offset ==
block_group->zone_capacity every time it iterates the loop. But, it is
not depending on the index. Move out the check and do it only once.

Fixes: f9a912a ("btrfs: zoned: make zone activation multi stripe capable")
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>
  • Loading branch information
Naohiro Aota authored and David Sterba committed May 5, 2022
1 parent 9f73f1a commit 5495771
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions fs/btrfs/zoned.c
Original file line number Diff line number Diff line change
Expand Up @@ -1835,19 +1835,19 @@ bool btrfs_zone_activate(struct btrfs_block_group *block_group)
goto out_unlock;
}

/* No space left */
if (block_group->alloc_offset == block_group->zone_capacity) {
ret = false;
goto out_unlock;
}

for (i = 0; i < map->num_stripes; i++) {
device = map->stripes[i].dev;
physical = map->stripes[i].physical;

if (device->zone_info->max_active_zones == 0)
continue;

/* No space left */
if (block_group->alloc_offset == block_group->zone_capacity) {
ret = false;
goto out_unlock;
}

if (!btrfs_dev_set_active_zone(device, physical)) {
/* Cannot activate the zone */
ret = false;
Expand Down

0 comments on commit 5495771

Please sign in to comment.