Re: [PATCH] btrfs-progs: properly format btrfs_header in btrfs_create_root()
From: David Sterba <hidden>
Date: 2021-09-23 19:23:01
On Fri, Sep 24, 2021 at 12:29:11AM +0900, Naohiro Aota wrote:
Enabling quota on zoned btrfs hits the following ASSERT().
$ mkfs.btrfs -f -d single -m single -R quota /dev/nullb0
btrfs-progs v5.11
See http://btrfs.wiki.kernel.org for more information.
Zoned: /dev/nullb0: host-managed device detected, setting zoned feature
Resetting device zones /dev/nullb0 (1600 zones) ...
bad tree block 25395200, bytenr mismatch, want=25395200, have=0
kernel-shared/disk-io.c:549: write_tree_block: BUG_ON `1` triggered, value 1
./mkfs.btrfs(+0x26aaa)[0x564d1a7ccaaa]
./mkfs.btrfs(write_tree_block+0xb8)[0x564d1a7cee29]
./mkfs.btrfs(__commit_transaction+0x91)[0x564d1a7e3740]
./mkfs.btrfs(btrfs_commit_transaction+0x135)[0x564d1a7e39aa]
./mkfs.btrfs(main+0x1fe9)[0x564d1a7b442a]
/lib64/libc.so.6(__libc_start_main+0xcd)[0x7f36377d37fd]
./mkfs.btrfs(_start+0x2a)[0x564d1a7b1fda]
zsh: IOT instruction sudo ./mkfs.btrfs -f -d single -m single -R quota /dev/nullb0
The issue occur because btrfs_create_root() is not formatting the root node
properly. This is fine on regular btrfs, because it's fortunately reusing
an once freed buffer. As the previous tree node allocation kindly formatted
the header, it will see the proper bytenr and pass the checks.
However, we never reuse an once freed buffer on zoned btrfs. As a result,
we have zero-filled bytenr, FSID, and chunk-tree UUID, hitting the ASSERTs
in check_tree_block().
Reported-by: Johannes Thumshirn <redacted>
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>Added to devel, thanks.