* [PATCH v2] btrfs: zoned: introduce a minimal zone size and reject mount
@ 2022-05-13 15:52 Johannes Thumshirn
2022-05-13 17:37 ` David Sterba
2022-05-13 18:42 ` Nikolay Borisov
0 siblings, 2 replies; 4+ messages in thread
From: Johannes Thumshirn @ 2022-05-13 15:52 UTC (permalink / raw)
To: David Sterba; +Cc: Johannes Thumshirn, linux-btrfs
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>
---
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)
#define SUPER_INFO_SECTORS ((u64)BTRFS_SUPER_INFO_SIZE >> SECTOR_SHIFT)
@@ -402,6 +404,13 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device, bool populate_cache)
zone_info->zone_size, BTRFS_MAX_ZONE_SIZE);
ret = -EINVAL;
goto out;
+ } else if (zone_info->zone_size < BTRFS_MIN_ZONE_SIZE) {
+ btrfs_err_in_rcu(fs_info,
+ "zoned: %s: zone size %llu smaller than supported minimum %u",
+ rcu_str_deref(device->name),
+ zone_info->zone_size, BTRFS_MIN_ZONE_SIZE);
+ ret = -EINVAL;
+ goto out;
}
nr_sectors = bdev_nr_sectors(bdev);
--
2.35.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] btrfs: zoned: introduce a minimal zone size and reject mount
2022-05-13 15:52 [PATCH v2] btrfs: zoned: introduce a minimal zone size and reject mount Johannes Thumshirn
@ 2022-05-13 17:37 ` David Sterba
2022-05-13 18:42 ` Nikolay Borisov
1 sibling, 0 replies; 4+ messages in thread
From: David Sterba @ 2022-05-13 17:37 UTC (permalink / raw)
To: Johannes Thumshirn; +Cc: David Sterba, linux-btrfs
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.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] btrfs: zoned: introduce a minimal zone size and reject mount
2022-05-13 15:52 [PATCH v2] btrfs: zoned: introduce a minimal zone size and reject mount Johannes Thumshirn
2022-05-13 17:37 ` David Sterba
@ 2022-05-13 18:42 ` Nikolay Borisov
2022-05-13 18:46 ` Nikolay Borisov
1 sibling, 1 reply; 4+ messages in thread
From: Nikolay Borisov @ 2022-05-13 18:42 UTC (permalink / raw)
To: Johannes Thumshirn, David Sterba; +Cc: linux-btrfs
On 13.05.22 г. 18:52 ч., 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>
> ---
> 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)
nit: we already have SZ_4M
>
> #define SUPER_INFO_SECTORS ((u64)BTRFS_SUPER_INFO_SIZE >> SECTOR_SHIFT)
>
> @@ -402,6 +404,13 @@ int btrfs_get_dev_zone_info(struct btrfs_device *device, bool populate_cache)
> zone_info->zone_size, BTRFS_MAX_ZONE_SIZE);
> ret = -EINVAL;
> goto out;
> + } else if (zone_info->zone_size < BTRFS_MIN_ZONE_SIZE) {
> + btrfs_err_in_rcu(fs_info,
> + "zoned: %s: zone size %llu smaller than supported minimum %u",
> + rcu_str_deref(device->name),
> + zone_info->zone_size, BTRFS_MIN_ZONE_SIZE);
> + ret = -EINVAL;
> + goto out;
> }
>
> nr_sectors = bdev_nr_sectors(bdev);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] btrfs: zoned: introduce a minimal zone size and reject mount
2022-05-13 18:42 ` Nikolay Borisov
@ 2022-05-13 18:46 ` Nikolay Borisov
0 siblings, 0 replies; 4+ messages in thread
From: Nikolay Borisov @ 2022-05-13 18:46 UTC (permalink / raw)
To: Johannes Thumshirn, David Sterba; +Cc: linux-btrfs
On 13.05.22 г. 21:42 ч., Nikolay Borisov wrote:
>
>
> On 13.05.22 г. 18:52 ч., 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>
>> ---
>> 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)
>
> nit: we already have SZ_4M
... and David has already seen it so this is noop :)
>
>> #define SUPER_INFO_SECTORS ((u64)BTRFS_SUPER_INFO_SIZE >>
>> SECTOR_SHIFT)
>> @@ -402,6 +404,13 @@ int btrfs_get_dev_zone_info(struct btrfs_device
>> *device, bool populate_cache)
>> zone_info->zone_size, BTRFS_MAX_ZONE_SIZE);
>> ret = -EINVAL;
>> goto out;
>> + } else if (zone_info->zone_size < BTRFS_MIN_ZONE_SIZE) {
>> + btrfs_err_in_rcu(fs_info,
>> + "zoned: %s: zone size %llu smaller than supported minimum %u",
>> + rcu_str_deref(device->name),
>> + zone_info->zone_size, BTRFS_MIN_ZONE_SIZE);
>> + ret = -EINVAL;
>> + goto out;
>> }
>> nr_sectors = bdev_nr_sectors(bdev);
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-05-13 18:46 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-13 15:52 [PATCH v2] btrfs: zoned: introduce a minimal zone size and reject mount Johannes Thumshirn
2022-05-13 17:37 ` David Sterba
2022-05-13 18:42 ` Nikolay Borisov
2022-05-13 18:46 ` Nikolay Borisov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox