From: Anand Jain <anand.jain@oracle.com>
To: Qu Wenruo <wqu@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 1/2] btrfs-progs: mkfs: fix a crash when enabling extent-tree-v2
Date: Sat, 8 Oct 2022 19:51:15 +0800 [thread overview]
Message-ID: <9b8ff079-2c97-8293-a253-913110d64e4c@oracle.com> (raw)
In-Reply-To: <265f9914e5f66686647a716a7a038de81bb09aec.1665143843.git.wqu@suse.com>
On 10/7/22 20:03, Qu Wenruo wrote:
> [BUG]
> When enabling extent-tree-v2 feature at mkfs time (need to enable
> experimental features), mkfs.btrfs will crash:
>
> # ./mkfs.btrfs -f -O extent-tree-v2 ~/test.img
> btrfs-progs v5.19.1
> See http://btrfs.wiki.kernel.org for more information.
>
> ERROR: superblock magic doesn't match
> NOTE: several default settings have changed in version 5.15, please make sure
> this does not affect your deployments:
> - DUP for metadata (-m dup)
> - enabled no-holes (-O no-holes)
> - enabled free-space-tree (-R free-space-tree)
>
> Segmentation fault (core dumped)
>
> [CAUSE]
> The block group tree looks like this after make_btrfs() call:
>
> (gdb) call btrfs_print_tree(root->fs_info->block_group_root->node, 0)
> leaf 1163264 items 1 free space 16234 generation 1 owner BLOCK_GROUP_TREE
> leaf 1163264 flags 0x0() backref revision 1
> checksum stored f137c1ac
> checksum calced f137c1ac
> fs uuid 450d4b15-4954-4574-9801-8c6d248aaec6
> chunk uuid 4c4cc54d-f240-4aa4-b88b-bd487db43444
> item 0 key (1048576 BLOCK_GROUP_ITEM 4194304) itemoff 16259 itemsize 24
> block group used 131072 chunk_objectid 256 flags SYSTEM|single
> ^^^
>
> This looks completely sane, but notice that chunk_objectid 256.
> That 256 value is the expected one for regular non-extent-tree-v2 btrfs,
> but for extent-tree-v2, chunk_objectid is reused as the global id of
> extent tree where the block group belongs to.
>
> With the old 256 value as chunk_objectid, btrfs will not find an extent
> tree root for the block group, and return NULL for btrfs_extent_root()
> call, and trigger segfault.
>
> This is a regression caused by commit 1430b41427b5 ("btrfs-progs:
> separate block group tree from extent tree v2"), which doesn't take
> extent-tree-v2 on-disk format into consideration.
>
> [FIX]
> For the initial btrfs created by make_btrfs(), all block group items
> will be in extent-tree global id 0, thus we can reset chunk_objectid to
> 0, if and only if extent-tree-v2 is enabled.
>
> Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Tested-by: Anand Jain <anand.jain@oracle.com>
next prev parent reply other threads:[~2022-10-08 11:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-07 12:02 [PATCH 0/2] btrfs-progs: mkfs: extent-tree-v2 related fixes Qu Wenruo
2022-10-07 12:03 ` [PATCH 1/2] btrfs-progs: mkfs: fix a crash when enabling extent-tree-v2 Qu Wenruo
2022-10-08 11:51 ` Anand Jain [this message]
2022-10-07 12:03 ` [PATCH 2/2] btrfs-progs: mkfs: fix a stack over-flow when features string are too long Qu Wenruo
2022-10-08 11:52 ` Anand Jain
2022-10-10 14:34 ` [PATCH 0/2] btrfs-progs: mkfs: extent-tree-v2 related fixes 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=9b8ff079-2c97-8293-a253-913110d64e4c@oracle.com \
--to=anand.jain@oracle.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=wqu@suse.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