Re: [PATCH v2 2/3] btrfs-progs: mkfs: recow all tree blocks properly

David Sterba
2021-10-11T14:34:46Z

On Mon, Oct 11, 2021 at 08:06:49PM +0800, Qu Wenruo wrote:
> [BUG]
> Since btrfs-progs v5.14, mkfs.btrfs no longer cleans up the temporary
> SINGLE metadata chunks if "-R free-space-tree" is specified:
>
> $ mkfs.btrfs -f -R free-space-tree -m dup -d dup /dev/test/test
> $ btrfs ins dump-tree -t chunk /dev/test/test | grep "type METADATA"
> length 8388608 owner 2 stripe_len 65536 type METADATA
> length 268435456 owner 2 stripe_len 65536 type METADATA|DUP
>
> [CAUSE]
> Since commit 4b6cf2a3eb78 ("btrfs-progs: mkfs: generate free space tree
> at make_btrfs() time"), free space tree is created when the temporary
> btrfs image is created.
>
> This behavior itself has no problem at all.
>
> The problem happens when "-m DUP -d DUP" (or other profiles) is
> specified.
>
> This makes btrfs to create extra chunks, enlarging free space tree so
> that it can be as high as level 1.
>
> During mkfs, we rely on recow_roots() to re-CoW all tree blocks to the

Please spell it as COW (not CoW or cow) when it means copy-on-write.