* [PATCH] btrfs: zoned: fix btrfs_can_activate_zone() to support DUP profile
@ 2023-03-13 7:29 Naohiro Aota
2023-03-13 8:45 ` Johannes Thumshirn
2023-03-14 17:49 ` David Sterba
0 siblings, 2 replies; 3+ messages in thread
From: Naohiro Aota @ 2023-03-13 7:29 UTC (permalink / raw)
To: linux-btrfs; +Cc: Naohiro Aota
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 buy
properly handle the case with the profile flags.
Fixes: 265f7237dd25 ("btrfs: zoned: allow DUP on meta-data block groups")
CC: stable@vger.kernel.org # 6.1+
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
---
fs/btrfs/zoned.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
index f3fcc3e09550..f7397680cde9 100644
--- a/fs/btrfs/zoned.c
+++ b/fs/btrfs/zoned.c
@@ -2099,11 +2099,21 @@ bool btrfs_can_activate_zone(struct btrfs_fs_devices *fs_devices, u64 flags)
if (!device->bdev)
continue;
- if (!zinfo->max_active_zones ||
- atomic_read(&zinfo->active_zones_left)) {
+ if (!zinfo->max_active_zones) {
ret = true;
break;
}
+
+ switch (flags & BTRFS_BLOCK_GROUP_PROFILE_MASK) {
+ case 0: /* single */
+ ret = atomic_read(&zinfo->active_zones_left) >= 1;
+ break;
+ case BTRFS_BLOCK_GROUP_DUP:
+ ret = atomic_read(&zinfo->active_zones_left) >= 2;
+ break;
+ }
+ if (ret)
+ break;
}
mutex_unlock(&fs_info->chunk_mutex);
--
2.39.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: zoned: fix btrfs_can_activate_zone() to support DUP profile
2023-03-13 7:29 [PATCH] btrfs: zoned: fix btrfs_can_activate_zone() to support DUP profile Naohiro Aota
@ 2023-03-13 8:45 ` Johannes Thumshirn
2023-03-14 17:49 ` David Sterba
1 sibling, 0 replies; 3+ messages in thread
From: Johannes Thumshirn @ 2023-03-13 8:45 UTC (permalink / raw)
To: Naohiro Aota, linux-btrfs
Looks good,
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] btrfs: zoned: fix btrfs_can_activate_zone() to support DUP profile
2023-03-13 7:29 [PATCH] btrfs: zoned: fix btrfs_can_activate_zone() to support DUP profile Naohiro Aota
2023-03-13 8:45 ` Johannes Thumshirn
@ 2023-03-14 17:49 ` David Sterba
1 sibling, 0 replies; 3+ messages in thread
From: David Sterba @ 2023-03-14 17:49 UTC (permalink / raw)
To: Naohiro Aota; +Cc: linux-btrfs
On Mon, Mar 13, 2023 at 04:29:49PM +0900, Naohiro Aota wrote:
> 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 buy
> properly handle the case with the profile flags.
>
> Fixes: 265f7237dd25 ("btrfs: zoned: allow DUP on meta-data block groups")
> CC: stable@vger.kernel.org # 6.1+
> Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Added to misc-next, thanks.
> ---
> fs/btrfs/zoned.c | 14 ++++++++++++--
> 1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
> index f3fcc3e09550..f7397680cde9 100644
> --- a/fs/btrfs/zoned.c
> +++ b/fs/btrfs/zoned.c
> @@ -2099,11 +2099,21 @@ bool btrfs_can_activate_zone(struct btrfs_fs_devices *fs_devices, u64 flags)
> if (!device->bdev)
> continue;
>
> - if (!zinfo->max_active_zones ||
> - atomic_read(&zinfo->active_zones_left)) {
> + if (!zinfo->max_active_zones) {
> ret = true;
> break;
> }
> +
> + switch (flags & BTRFS_BLOCK_GROUP_PROFILE_MASK) {
> + case 0: /* single */
> + ret = atomic_read(&zinfo->active_zones_left) >= 1;
With ( ) around the expression it's more obvious that it's not a simple
assignment:
ret = (atomic_read(&zinfo->active_zones_left) >= 1);
Updated in the commit.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-03-14 17:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-13 7:29 [PATCH] btrfs: zoned: fix btrfs_can_activate_zone() to support DUP profile Naohiro Aota
2023-03-13 8:45 ` Johannes Thumshirn
2023-03-14 17:49 ` David Sterba
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.