* [PATCH] btrfs-progs: zoned: add upper and lower zone size boundarys
@ 2022-02-10 13:49 Johannes Thumshirn
2022-05-27 15:02 ` David Sterba
0 siblings, 1 reply; 2+ messages in thread
From: Johannes Thumshirn @ 2022-02-10 13:49 UTC (permalink / raw)
To: David Sterba; +Cc: Johannes Thumshirn, linux-btrfs
As we're not supporting arbitrarily big or small zone sizes in the kernel,
reject devices that don't fit in progs as well.
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
---
kernel-shared/zoned.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/kernel-shared/zoned.c b/kernel-shared/zoned.c
index 2a11a1d723aa..2665861f23c4 100644
--- a/kernel-shared/zoned.c
+++ b/kernel-shared/zoned.c
@@ -47,6 +47,9 @@
#define BTRFS_SB_LOG_FIRST_SHIFT const_ilog2(BTRFS_SB_LOG_FIRST_OFFSET)
#define BTRFS_SB_LOG_SECOND_SHIFT const_ilog2(BTRFS_SB_LOG_SECOND_OFFSET)
+#define BTRFS_MAX_ZONE_SIZE (8ULL * SZ_1G)
+#define BTRFS_MIN_ZONE_SIZE SZ_64M
+
#define EMULATED_ZONE_SIZE SZ_256M
static int btrfs_get_dev_zone_info(struct btrfs_device *device);
@@ -307,6 +310,17 @@ static int report_zones(int fd, const char *file,
/* Allocate the zone information array */
zinfo->zone_size = zone_bytes;
zinfo->nr_zones = device_size / zone_bytes;
+
+ if (zinfo->zone_size > BTRFS_MAX_ZONE_SIZE) {
+ error("zoned: zone size %llu larger than supported maximum %llu",
+ zinfo->zone_size, BTRFS_MAX_ZONE_SIZE);
+ exit(1);
+ } else if (zinfo->zone_size < BTRFS_MIN_ZONE_SIZE) {
+ error("zoned: zone size %llu smaller than supported minimum %u",
+ zinfo->zone_size, BTRFS_MIN_ZONE_SIZE);
+ exit(1);
+ }
+
if (device_size & (zone_bytes - 1))
zinfo->nr_zones++;
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] btrfs-progs: zoned: add upper and lower zone size boundarys
2022-02-10 13:49 [PATCH] btrfs-progs: zoned: add upper and lower zone size boundarys Johannes Thumshirn
@ 2022-05-27 15:02 ` David Sterba
0 siblings, 0 replies; 2+ messages in thread
From: David Sterba @ 2022-05-27 15:02 UTC (permalink / raw)
To: Johannes Thumshirn; +Cc: David Sterba, linux-btrfs
On Thu, Feb 10, 2022 at 05:49:00AM -0800, Johannes Thumshirn wrote:
> As we're not supporting arbitrarily big or small zone sizes in the kernel,
> reject devices that don't fit in progs as well.
>
> Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
I've updated the lower limit to 4M so it matches the recent update in
kernel and added patch to devel, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-05-27 15:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-10 13:49 [PATCH] btrfs-progs: zoned: add upper and lower zone size boundarys Johannes Thumshirn
2022-05-27 15:02 ` 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.