Skip to content

Commit 9e1cdf0

Browse files
naotakdave
authored andcommitted
btrfs: zoned: fix btrfs_can_activate_zone() to support DUP profile
btrfs_can_activate_zone() returns true if at least one device has one zone available for activation. This is OK for the single profile, but not OK for DUP profile. We need two zones to create a DUP block group. Fix it by properly handling the case with the profile flags. Fixes: 265f723 ("btrfs: zoned: allow DUP on meta-data block groups") CC: [email protected] # 6.1+ Reviewed-by: Johannes Thumshirn <[email protected]> Signed-off-by: Naohiro Aota <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 10a8857 commit 9e1cdf0

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

fs/btrfs/zoned.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2086,11 +2086,21 @@ bool btrfs_can_activate_zone(struct btrfs_fs_devices *fs_devices, u64 flags)
20862086
if (!device->bdev)
20872087
continue;
20882088

2089-
if (!zinfo->max_active_zones ||
2090-
atomic_read(&zinfo->active_zones_left)) {
2089+
if (!zinfo->max_active_zones) {
20912090
ret = true;
20922091
break;
20932092
}
2093+
2094+
switch (flags & BTRFS_BLOCK_GROUP_PROFILE_MASK) {
2095+
case 0: /* single */
2096+
ret = (atomic_read(&zinfo->active_zones_left) >= 1);
2097+
break;
2098+
case BTRFS_BLOCK_GROUP_DUP:
2099+
ret = (atomic_read(&zinfo->active_zones_left) >= 2);
2100+
break;
2101+
}
2102+
if (ret)
2103+
break;
20942104
}
20952105
mutex_unlock(&fs_info->chunk_mutex);
20962106

0 commit comments

Comments
 (0)