All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Thumshirn <johannes.thumshirn@wdc.com>
To: David Sterba <dsterba@suse.com>
Cc: Johannes Thumshirn <johannes.thumshirn@wdc.com>,
	linux-btrfs@vger.kernel.org
Subject: [PATCH] btrfs-progs: zoned: add upper and lower zone size boundarys
Date: Thu, 10 Feb 2022 05:49:00 -0800	[thread overview]
Message-ID: <20220210134900.184638-1-johannes.thumshirn@wdc.com> (raw)

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


             reply	other threads:[~2022-02-10 13:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-10 13:49 Johannes Thumshirn [this message]
2022-05-27 15:02 ` [PATCH] btrfs-progs: zoned: add upper and lower zone size boundarys David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220210134900.184638-1-johannes.thumshirn@wdc.com \
    --to=johannes.thumshirn@wdc.com \
    --cc=dsterba@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.