diff mbox series

[v2,1/2] btrfs-progs: print out the correct minimum size for zoned file systems

Message ID d4a3973e50ab59cc063327252121edd1260024a8.1688658745.git.josef@toxicpanda.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: some zoned mkfs fixups | expand

Commit Message

Josef Bacik July 6, 2023, 3:53 p.m. UTC
While trying to get the ZNS testing running I ran into a problem with
making a small file system for one of the tests, but the error output
didn't make sense because it said the minimum size was 114294784 bytes,
and I was trying to make a file system of size 419430400 bytes.  The
problem here is that we were spitting out min_dev_size, which isn't the
minimum size for the ZNS configuration.  Add a helper for calculating
the minimum zoned fs size, and use that for the error output.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 mkfs/main.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

Comments

Christoph Hellwig July 7, 2023, 11:36 a.m. UTC | #1
Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

diff --git a/mkfs/main.c b/mkfs/main.c
index 972ed111..8d94dac8 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -79,6 +79,17 @@  struct prepare_device_progress {
 	int ret;
 };
 
+/*
+ * 2 zones for the primary superblock
+ * 1 zone for the system block group
+ * 1 zone for a metadata block group
+ * 1 zone for a data block group
+ */
+static u64 min_zoned_fs_size(const char *filename)
+{
+	return 5 * zone_size(file);
+}
+
 static int create_metadata_block_groups(struct btrfs_root *root, bool mixed,
 				struct mkfs_allocation *allocation)
 {
@@ -1436,17 +1447,11 @@  int BOX_MAIN(mkfs)(int argc, char **argv)
 			min_dev_size);
 		goto error;
 	}
-	/*
-	 * 2 zones for the primary superblock
-	 * 1 zone for the system block group
-	 * 1 zone for a metadata block group
-	 * 1 zone for a data block group
-	 */
-	if (opt_zoned && block_count && block_count < 5 * zone_size(file)) {
+	if (opt_zoned && block_count && block_count < min_zoned_fs_size(file)) {
 		error("size %llu is too small to make a usable filesystem",
 			block_count);
 		error("minimum size for a zoned btrfs filesystem is %llu",
-			min_dev_size);
+			min_zoned_fs_size(file));
 		goto error;
 	}