btrfs: zoned: fix btrfs_can_activate_zone() to support DUP profile
authorNaohiro Aota <naohiro.aota@wdc.com>
Mon, 13 Mar 2023 07:29:49 +0000 (16:29 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 30 Mar 2023 10:49:22 +0000 (12:49 +0200)
commit00331677c084db45d38333f4e76d7303712b21ee
tree26059c45204f8e6f49ea85bef15e1c4ee2d92aef
parent3bc7324e4911351e39c54a62e6ca46321cb10faf
btrfs: zoned: fix btrfs_can_activate_zone() to support DUP profile

commit 9e1cdf0c354e46e428c0e0cab008abbe81b6013d upstream.

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: 265f7237dd25 ("btrfs: zoned: allow DUP on meta-data block groups")
CC: stable@vger.kernel.org # 6.1+
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/zoned.c