From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Josef Bacik <josef@toxicpanda.com>,
linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH 2/9] btrfs-progs: use blocks_nr to determine the super used bytes
Date: Mon, 23 Aug 2021 16:43:21 +0800 [thread overview]
Message-ID: <2c871503-2787-e0ec-0a55-8fb9c44e32cd@gmx.com> (raw)
In-Reply-To: <1d73b314e14e03f4fe7a70475822f534fd5914e4.1629486429.git.josef@toxicpanda.com>
On 2021/8/21 上午3:11, Josef Bacik wrote:
> We were setting the superblock's used bytes to a static number. However
> the number of blocks we have to write has the correct used size, so just
> add up the total number of blocks we're allocating as we determine their
> offsets. This value will be used later which is why I'm calculating it
> this way instead of doing the math to set the bytes_super specifically.
>
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Getting rid of an hardcoded immediate number is always a good thing.
Thanks,
Qu
> ---
> mkfs/common.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/mkfs/common.c b/mkfs/common.c
> index e9ff529a..8902d39e 100644
> --- a/mkfs/common.c
> +++ b/mkfs/common.c
> @@ -162,6 +162,7 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg)
> u64 ref_root;
> u32 array_size;
> u32 item_size;
> + u64 total_used = 0;
> int skinny_metadata = !!(cfg->features &
> BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA);
> u64 num_bytes;
> @@ -207,6 +208,7 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg)
> if (blk == MKFS_SUPER_BLOCK)
> continue;
> cfg->blocks[blk] = system_group_offset + cfg->nodesize * i;
> + total_used += cfg->nodesize;
> }
>
> btrfs_set_super_bytenr(&super, cfg->blocks[MKFS_SUPER_BLOCK]);
> @@ -216,7 +218,7 @@ int make_btrfs(int fd, struct btrfs_mkfs_config *cfg)
> btrfs_set_super_root(&super, cfg->blocks[MKFS_ROOT_TREE]);
> btrfs_set_super_chunk_root(&super, cfg->blocks[MKFS_CHUNK_TREE]);
> btrfs_set_super_total_bytes(&super, num_bytes);
> - btrfs_set_super_bytes_used(&super, 6 * cfg->nodesize);
> + btrfs_set_super_bytes_used(&super, total_used);
> btrfs_set_super_sectorsize(&super, cfg->sectorsize);
> super.__unused_leafsize = cpu_to_le32(cfg->nodesize);
> btrfs_set_super_nodesize(&super, cfg->nodesize);
>
next prev parent reply other threads:[~2021-08-23 8:43 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-20 19:11 [PATCH 0/9] btrfs-progs: mkfs fixes and enhancements for extent tree v2 Josef Bacik
2021-08-20 19:11 ` [PATCH 1/9] btrfs-progs: use an associative array for init mkfs blocks Josef Bacik
2021-08-23 8:42 ` Qu Wenruo
2021-08-23 16:10 ` David Sterba
2021-10-09 6:34 ` Wang Yugui
2021-10-11 10:19 ` David Sterba
2021-08-20 19:11 ` [PATCH 2/9] btrfs-progs: use blocks_nr to determine the super used bytes Josef Bacik
2021-08-23 8:43 ` Qu Wenruo [this message]
2021-08-20 19:11 ` [PATCH 3/9] btrfs-progs: allocate blocks from the start of the temp system chunk Josef Bacik
2021-08-23 8:45 ` Qu Wenruo
2021-08-20 19:11 ` [PATCH 4/9] btrfs-progs: set nritems based on root items written Josef Bacik
2021-08-23 8:46 ` Qu Wenruo
2021-08-20 19:11 ` [PATCH 5/9] btrfs-progs: add helper for writing empty tree nodes Josef Bacik
2021-08-23 8:49 ` Qu Wenruo
2021-08-20 19:11 ` [PATCH 6/9] btrfs-progs: add the block group item in make_btrfs() Josef Bacik
2021-08-23 9:00 ` Qu Wenruo
2021-08-23 20:04 ` Josef Bacik
2021-08-23 23:37 ` Qu Wenruo
2021-08-23 23:47 ` Josef Bacik
2021-08-24 0:01 ` Qu Wenruo
2021-08-20 19:11 ` [PATCH 7/9] btrfs-progs: add add_block_group_free_space helper Josef Bacik
2021-08-20 19:11 ` [PATCH 8/9] btrfs-progs: generate free space tree at make_btrfs() time Josef Bacik
2021-08-20 19:11 ` [PATCH 9/9] btrfs-progs: add the incompat flag for extent tree v2 Josef Bacik
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=2c871503-2787-e0ec-0a55-8fb9c44e32cd@gmx.com \
--to=quwenruo.btrfs@gmx.com \
--cc=josef@toxicpanda.com \
--cc=kernel-team@fb.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;
as well as URLs for NNTP newsgroup(s).