Skip to content

Commit b5eb693

Browse files
naotakdave
authored andcommitted
btrfs: zoned: limit active zones to max_open_zones
When there is no active zone limit, we can technically write into any number of zones at the same time. However, exceeding the max open zones can degrade performance. To prevent this, set the max_active_zones to bdev_max_open_zones() if there is no active zone limit. Reviewed-by: Johannes Thumshirn <[email protected]> Signed-off-by: Naohiro Aota <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 7f055cd commit b5eb693

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

fs/btrfs/zoned.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
/* Number of superblock log zones */
4444
#define BTRFS_NR_SB_LOG_ZONES 2
4545

46+
/* Default number of max active zones when the device has no limits. */
47+
#define BTRFS_DEFAULT_MAX_ACTIVE_ZONES 128
48+
4649
/*
4750
* Minimum of active zones we need:
4851
*
@@ -417,7 +420,10 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device, bool populate_cache)
417420
if (!IS_ALIGNED(nr_sectors, zone_sectors))
418421
zone_info->nr_zones++;
419422

420-
max_active_zones = bdev_max_active_zones(bdev);
423+
max_active_zones = min_not_zero(bdev_max_active_zones(bdev),
424+
bdev_max_open_zones(bdev));
425+
if (!max_active_zones && zone_info->nr_zones > BTRFS_DEFAULT_MAX_ACTIVE_ZONES)
426+
max_active_zones = BTRFS_DEFAULT_MAX_ACTIVE_ZONES;
421427
if (max_active_zones && max_active_zones < BTRFS_MIN_ACTIVE_ZONES) {
422428
btrfs_err(fs_info,
423429
"zoned: %s: max active zones %u is too small, need at least %u active zones",

0 commit comments

Comments
 (0)