Skip to content

Regression in "mkfs.btrfs --compress zlib:9 --shrink", creates broken files since v7.0 (Input/output error on certain files) #1135

Description

@mid-kid

To reproduce, start with an empty directory. This was tested on gentoo.

Prepare a 20MiB file:

# mkdir -p root
# dd if=/dev/urandom of=root/file.bin count=20MiB

Install an older version of mkfs.btrfs:

# emerge -1g '<sys-fs/btrfs-progs-7'
[...snip...]
# emerge --info sys-fs/btrfs-progs
[...snip...]
sys-fs/btrfs-progs-6.19.1::gentoo was built with the following:
USE="convert man zstd -experimental -reiserfs -static -static-libs -udev -verify-sig" ABI_X86="(64)"
CFLAGS="-O2 -pipe -march=x86-64 -mtune=generic -g -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing"
CXXFLAGS="-O2 -pipe -march=x86-64 -mtune=generic -g -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs -g -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing"
# mkfs.btrfs --version
mkfs.btrfs, part of btrfs-progs v6.19.1
-EXPERIMENTAL -INJECT -STATIC +LZO +ZSTD -UDEV +FSVERITY +ZONED CRYPTO=builtin

Create a disk image using this version:

# mkfs.btrfs -r root --compress zlib:9 --shrink good.img

Install a newer version of mkfs.btrfs:

# emerge -1g sys-fs/btrfs-progs
[...snip...]
# emerge --info sys-fs/btrfs-progs
[...snip...]
sys-fs/btrfs-progs-7.0::gentoo was built with the following:
USE="convert man zstd -experimental -reiserfs -static -static-libs -udev -verify-sig" ABI_X86="(64)"
CFLAGS="-O2 -pipe -march=x86-64 -mtune=generic -g -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing"
CXXFLAGS="-O2 -pipe -march=x86-64 -mtune=generic -g -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs -g -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing"
# mkfs.btrfs --version
mkfs.btrfs, part of btrfs-progs v7.0
-EXPERIMENTAL -INJECT -STATIC +LZO +ZSTD -UDEV +FSVERITY +ZONED CRYPTO=builtin

Create a disk image using this version:

# mkfs.btrfs -r root --compress zlib:9 --shrink bad.img

Mount both disk images and compare:

# mkdir good bad
# mount good.img good
# mount bad.img bad
# LANG=C sha256sum good/file.bin bad/file.bin
42cef11a58e793db3810978bd559d1284ae5d4b0f0ff677196c919dac3d44c2f  good/file.bin
sha256sum: bad/file.bin: Input/output error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions