Skip to content

Commit ceb4f60

Browse files
naotakdave
authored andcommitted
btrfs: zoned: activate block group properly on unlimited active zone device
btrfs_zone_activate() checks if it activated all the underlying zones in the loop. However, that check never hit on an unlimited activate zone device (max_active_zones == 0). Fortunately, it still works without ENOSPC because btrfs_zone_activate() returns true in the end, even if block_group->zone_is_active == 0. But, it is confusing to have non zone_is_active block group still usable for allocation. Also, we are wasting CPU time to iterate the loop every time btrfs_zone_activate() is called for the blog groups. Since error case in the loop is handled by out_unlock, we can just set zone_is_active and do the list stuff after the loop. 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 5495771 commit ceb4f60

1 file changed

Lines changed: 8 additions & 14 deletions

File tree

fs/btrfs/zoned.c

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1853,24 +1853,18 @@ bool btrfs_zone_activate(struct btrfs_block_group *block_group)
18531853
ret = false;
18541854
goto out_unlock;
18551855
}
1856-
1857-
/* Successfully activated all the zones */
1858-
if (i == map->num_stripes - 1)
1859-
block_group->zone_is_active = 1;
1860-
1861-
18621856
}
1857+
1858+
/* Successfully activated all the zones */
1859+
block_group->zone_is_active = 1;
18631860
spin_unlock(&block_group->lock);
18641861

1865-
if (block_group->zone_is_active) {
1866-
/* For the active block group list */
1867-
btrfs_get_block_group(block_group);
1862+
/* For the active block group list */
1863+
btrfs_get_block_group(block_group);
18681864

1869-
spin_lock(&fs_info->zone_active_bgs_lock);
1870-
list_add_tail(&block_group->active_bg_list,
1871-
&fs_info->zone_active_bgs);
1872-
spin_unlock(&fs_info->zone_active_bgs_lock);
1873-
}
1865+
spin_lock(&fs_info->zone_active_bgs_lock);
1866+
list_add_tail(&block_group->active_bg_list, &fs_info->zone_active_bgs);
1867+
spin_unlock(&fs_info->zone_active_bgs_lock);
18741868

18751869
return true;
18761870

0 commit comments

Comments
 (0)