Skip to content

Commit 5495771

Browse files
naotakdave
authored andcommitted
btrfs: zoned: move non-changing condition check out of the loop
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>
1 parent 9f73f1a commit 5495771

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

fs/btrfs/zoned.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1835,19 +1835,19 @@ bool btrfs_zone_activate(struct btrfs_block_group *block_group)
18351835
goto out_unlock;
18361836
}
18371837

1838+
/* No space left */
1839+
if (block_group->alloc_offset == block_group->zone_capacity) {
1840+
ret = false;
1841+
goto out_unlock;
1842+
}
1843+
18381844
for (i = 0; i < map->num_stripes; i++) {
18391845
device = map->stripes[i].dev;
18401846
physical = map->stripes[i].physical;
18411847

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

1845-
/* No space left */
1846-
if (block_group->alloc_offset == block_group->zone_capacity) {
1847-
ret = false;
1848-
goto out_unlock;
1849-
}
1850-
18511851
if (!btrfs_dev_set_active_zone(device, physical)) {
18521852
/* Cannot activate the zone */
18531853
ret = false;

0 commit comments

Comments
 (0)