From: Naohiro Aota <Naohiro.Aota@wdc.com>
To: Qu Wenruo <quwenruo.btrfs@gmx.com>
Cc: "linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Subject: Re: [PATCH v2 4/8] btrfs-progs: mkfs: fix minimum size calculation for zoned mode
Date: Wed, 15 May 2024 16:25:24 +0000 [thread overview]
Message-ID: <ji7guuchxiuit4u7b654f6jdrjwfvdazpozrlx2opxvmvbss3i@l6vmxacywa7a> (raw)
In-Reply-To: <bc637e8e-de79-46d8-b13d-e80d49131b8f@gmx.com>
On Wed, May 15, 2024 at 08:24:46AM +0930, Qu Wenruo wrote:
>
>
> 在 2024/5/15 03:52, Naohiro Aota 写道:
> > Currently, we check if a device is larger than 5 zones to determine we can
> > create btrfs on the device or not. Actually, we need more zones to create
> > DUP block groups, so it fails with "ERROR: not enough free space to
> > allocate chunk". Implement proper support for non-SINGLE profile.
> >
> > Also, current code does not ensure we can create tree-log BG and data
> > relocation BG, which are essential for the real usage. Count them as
> > requirement too.
> >
> > Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
> > ---
> > mkfs/common.c | 53 +++++++++++++++++++++++++++++++++++++++++++--------
> > 1 file changed, 45 insertions(+), 8 deletions(-)
> >
> > diff --git a/mkfs/common.c b/mkfs/common.c
> > index af54089654a0..a5100b296f65 100644
> > --- a/mkfs/common.c
> > +++ b/mkfs/common.c
> > @@ -818,14 +818,51 @@ u64 btrfs_min_dev_size(u32 nodesize, bool mixed, u64 zone_size, u64 meta_profile
> > 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 (zone_size) {
> > + /* 2 zones for the primary superblock. */
> > + reserved += 2 * zone_size;
> > +
> > + /*
> > + * 1 zone each for the initial system, metadata, and data block
> > + * group
> > + */
> > + reserved += 3 * zone_size;
> > +
> > + /*
> > + * non-SINGLE profile needs:
> > + * 1 zone for system block group
> > + * 1 zone for normal metadata block group
> > + * 1 zone for tree-log block group
> > + *
> > + * SINGLE profile only need to add tree-log block group
>
> This comments looks a little confusing to me.
>
> As (for now) the non-SINGLE profiles for metadata is only DUP, thus they
> needs at least 2 zones for each bg.
RAID is also supported in an experimetanl build ;-)
> It's only explained later in the "meta_size *= 2;" line.
>
> Would the following ones be a little better?
>
> /*
> * non-SINGLE profile needs:
> * 1 extra system block group
> * 1 extra normal metadata block group
> * 1 extra tree-log block group
> *
> * SINGLE profiles needs:
> * 1 extra tree-log block group
> */
> if (meta_profiles & BTRFS_BLOCK_GROUP_DUP)
> factor = 2;
> if (meta_profiles & BTRFS_BLOCK_GROUP_PROFILE_MASK)
> meta_size = 3 * zone_size * factor;
> else
> meta_size = 1 * zone_size * factor;
>
> Otherwise looks reasonable to me.
I followed the regular case code, but this looks cleaner to me. I'll follow
your suggestion and tweak the comment as well.
> Thanks,
> Qu
> > + */
> > + if (meta_profile & BTRFS_BLOCK_GROUP_PROFILE_MASK)
> > + meta_size = 3 * zone_size;
> > + else
> > + meta_size = zone_size;
> > + /* DUP profile needs two zones for each block group. */
> > + if (meta_profile & BTRFS_BLOCK_GROUP_DUP)
> > + meta_size *= 2;
> > + reserved += meta_size;
> > +
> > + /*
> > + * non-SINGLE profile needs:
> > + * 1 zone for data block group
> > + * 1 zone for data relocation block group
> > + *
> > + * SINGLE profile only need to add data relocationblock group
> > + */
> > + if (data_profile & BTRFS_BLOCK_GROUP_PROFILE_MASK)
> > + data_size = 2 * zone_size;
> > + else
> > + data_size = zone_size;
> > + /* DUP profile needs two zones for each block group. */
> > + if (data_profile & BTRFS_BLOCK_GROUP_DUP)
> > + data_size *= 2;
> > + reserved += data_size;
> > +
> > + return reserved;
> > + }
> >
> > if (mixed)
> > return 2 * (BTRFS_MKFS_SYSTEM_GROUP_SIZE +
next prev parent reply other threads:[~2024-05-15 16:25 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-14 18:22 [PATCH v2 0/8] btrfs-progs: zoned: proper "mkfs.btrfs -b" support Naohiro Aota
2024-05-14 18:22 ` [PATCH v2 1/8] btrfs-progs: rename block_count to byte_count Naohiro Aota
2024-05-14 18:22 ` [PATCH v2 2/8] btrfs-progs: mkfs: remove duplicated device size check Naohiro Aota
2024-05-14 18:22 ` [PATCH v2 3/8] btrfs-progs: mkfs: unify zoned mode minimum size calc into btrfs_min_dev_size() Naohiro Aota
2024-05-14 18:22 ` [PATCH v2 4/8] btrfs-progs: mkfs: fix minimum size calculation for zoned mode Naohiro Aota
2024-05-14 22:54 ` Qu Wenruo
2024-05-15 16:25 ` Naohiro Aota [this message]
2024-05-14 18:22 ` [PATCH v2 5/8] btrfs-progs: mkfs: check if byte_count is zone size aligned Naohiro Aota
2024-05-14 22:56 ` Qu Wenruo
2024-05-15 15:43 ` Naohiro Aota
2024-05-14 18:22 ` [PATCH v2 6/8] btrfs-progs: support byte length for zone resetting Naohiro Aota
2024-05-14 22:59 ` Qu Wenruo
2024-05-15 16:11 ` Naohiro Aota
2024-05-15 21:47 ` Qu Wenruo
2024-05-14 18:22 ` [PATCH v2 7/8] btrfs-progs: add test " Naohiro Aota
2024-05-14 23:04 ` Qu Wenruo
2024-05-15 16:14 ` Naohiro Aota
2024-05-14 18:22 ` [PATCH v2 8/8] btrfs-progs: test: use smaller emulated zone size Naohiro Aota
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=ji7guuchxiuit4u7b654f6jdrjwfvdazpozrlx2opxvmvbss3i@l6vmxacywa7a \
--to=naohiro.aota@wdc.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=quwenruo.btrfs@gmx.com \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).