Re: [PATCH v2] btrfs: zoned: introduce a minimal zone size and reject mount

David Sterba
2022-05-13T17:41:46Z

On Fri, May 13, 2022 at 08:52:52AM -0700, Johannes Thumshirn wrote:
> Zoned devices are expected to have zone sizes in the range of 1-2GB for
> ZNS SSDs and SMR HDDs have zone sizes of 256MB, so there is no need to
> allow arbitrarily small zone sizes on btrfs.
>
> But for testing purposes with emulated devices it is sometimes desirable
> to create devices with as small as 4MB zone size to uncover errors.
>
> So use 4MB as the smallest possible zone size and reject mounts of devices
> with a smaller zone size.
>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>

Thanks, added to misc-next.

> ---
> fs/btrfs/zoned.c | 15 ++++++++++++---
> 1 file changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/fs/btrfs/zoned.c b/fs/btrfs/zoned.c
> index 1b1b310c3c51..d9579d4ec0f2 100644
> --- a/fs/btrfs/zoned.c
> +++ b/fs/btrfs/zoned.c
> @@ -51,11 +51,13 @@
> #define BTRFS_MIN_ACTIVE_ZONES (BTRFS_SUPER_MIRROR_MAX + 5)
>
> /*
> - * Maximum supported zone size. Currently, SMR disks have a zone size of
> - * 256MiB, and we are expecting ZNS drives to be in the 1-4GiB range. We do not
> - * expect the zone size to become larger than 8GiB in the near future.
> + * Minimum / maximum supported zone size. Currently, SMR disks have a zone
> + * size of 256MiB, and we are expecting ZNS drives to be in the 1-4GiB range.
> + * We do not expect the zone size to become larger than 8GiB or smaller than
> + * 4MiB in the near future.
> */
> #define BTRFS_MAX_ZONE_SIZE SZ_8G
> +#define BTRFS_MIN_ZONE_SIZE (4 * SZ_1M)

I've checked if the SZ_4M constant exists, it does so I'll use it.