@@ -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++;
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(+)