From: Naohiro Aota <naohiro.aota@wdc.com>
To: linux-btrfs@vger.kernel.org
Cc: Naohiro Aota <naohiro.aota@wdc.com>
Subject: [PATCH 3/7] btrfs-progs: mkfs: unify zoned mode minimum size calc into btrfs_min_dev_size()
Date: Mon, 13 May 2024 18:51:29 -0600 [thread overview]
Message-ID: <20240514005133.44786-4-naohiro.aota@wdc.com> (raw)
In-Reply-To: <20240514005133.44786-1-naohiro.aota@wdc.com>
We are going to implement a better minimum size calculation for the zoned
mode. Move the current logic to btrfs_min_dev_size() and unify the size
checking path.
Also, convert "int mixed" to "bool mixed" while at it.
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
---
mkfs/common.c | 11 ++++++++++-
mkfs/common.h | 2 +-
mkfs/main.c | 22 +++++-----------------
3 files changed, 16 insertions(+), 19 deletions(-)
diff --git a/mkfs/common.c b/mkfs/common.c
index 3c48a6c120e7..af54089654a0 100644
--- a/mkfs/common.c
+++ b/mkfs/common.c
@@ -811,13 +811,22 @@ static u64 btrfs_min_global_blk_rsv_size(u32 nodesize)
return (u64)nodesize << 10;
}
-u64 btrfs_min_dev_size(u32 nodesize, int mixed, u64 meta_profile,
+u64 btrfs_min_dev_size(u32 nodesize, bool mixed, u64 zone_size, u64 meta_profile,
u64 data_profile)
{
u64 reserved = 0;
u64 meta_size;
u64 data_size;
+ /*
+ * 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 (zone_size)
+ return 5 * zone_size;
+
if (mixed)
return 2 * (BTRFS_MKFS_SYSTEM_GROUP_SIZE +
btrfs_min_global_blk_rsv_size(nodesize));
diff --git a/mkfs/common.h b/mkfs/common.h
index d9183c997bb2..de0ff57beee8 100644
--- a/mkfs/common.h
+++ b/mkfs/common.h
@@ -105,7 +105,7 @@ struct btrfs_mkfs_config {
int make_btrfs(int fd, struct btrfs_mkfs_config *cfg);
int btrfs_make_root_dir(struct btrfs_trans_handle *trans,
struct btrfs_root *root, u64 objectid);
-u64 btrfs_min_dev_size(u32 nodesize, int mixed, u64 meta_profile,
+u64 btrfs_min_dev_size(u32 nodesize, bool mixed, u64 zone_size, u64 meta_profile,
u64 data_profile);
int test_minimum_size(const char *file, u64 min_dev_size);
int is_vol_small(const char *file);
diff --git a/mkfs/main.c b/mkfs/main.c
index f6f67abf3b0e..a437ecc40c7f 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -1588,8 +1588,9 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
goto error;
}
- min_dev_size = btrfs_min_dev_size(nodesize, mixed, metadata_profile,
- data_profile);
+ min_dev_size = btrfs_min_dev_size(nodesize, mixed,
+ opt_zoned ? zone_size(file) : 0,
+ metadata_profile, data_profile);
/*
* Enlarge the destination file or create a new one, using the size
* calculated from source dir.
@@ -1650,21 +1651,8 @@ int BOX_MAIN(mkfs)(int argc, char **argv)
if (byte_count && byte_count < min_dev_size) {
error("size %llu is too small to make a usable filesystem",
byte_count);
- error("minimum size for btrfs filesystem is %llu",
- 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 && byte_count && byte_count < 5 * zone_size(file)) {
- error("size %llu is too small to make a usable filesystem",
- byte_count);
- error("minimum size for a zoned btrfs filesystem is %llu",
- min_dev_size);
+ error("minimum size for a %sbtrfs filesystem is %llu",
+ opt_zoned ? "zoned mode " : "", min_dev_size);
goto error;
}
--
2.45.0
next prev parent reply other threads:[~2024-05-14 0:52 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-14 0:51 [PATCH 0/7] btrfs-progs: zoned: proper "mkfs.btrfs -b" support Naohiro Aota
2024-05-14 0:51 ` [PATCH 1/7] btrfs-progs: rename block_count to byte_count Naohiro Aota
2024-05-14 0:51 ` [PATCH 2/7] btrfs-progs: mkfs: remove duplicated device size check Naohiro Aota
2024-05-14 0:51 ` Naohiro Aota [this message]
2024-05-14 0:51 ` [PATCH 4/7] btrfs-progs: mkfs: fix minimum size calculation for zoned Naohiro Aota
2024-05-14 0:51 ` [PATCH 5/7] btrfs-progs: mkfs: check if byte_count is zone size aligned Naohiro Aota
2024-05-14 0:51 ` [PATCH 6/7] btrfs-progs: support byte length for zone resetting Naohiro Aota
2024-05-14 0:51 ` [PATCH 7/7] btrfs-progs: add test " Naohiro Aota
2024-05-14 15:39 ` [PATCH 0/7] btrfs-progs: zoned: proper "mkfs.btrfs -b" support David Sterba
2024-05-14 17:14 ` Naohiro Aota
2024-05-14 17:21 ` 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=20240514005133.44786-4-naohiro.aota@wdc.com \
--to=naohiro.aota@wdc.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox