mbox series

[0/3] btrfs-progs: check: detect and repair ram_bytes mismatch for non-compressed data extents

Message ID cover.1714640642.git.wqu@suse.com (mailing list archive)
Headers show
Series btrfs-progs: check: detect and repair ram_bytes mismatch for non-compressed data extents | expand

Message

Qu Wenruo May 2, 2024, 9:07 a.m. UTC
There are at least one kernel bug that makes on-disk
btrfs_file_extent_item::ram_bytes incorrect for non-compressed non-hole
data extents.

Thankfully kernel just doesn't care ram_bytes for non-compressed extents
at all, so it doesn't lead to any data corruption or whatever, and this
is really just a minor problem.

But for the sake of consistency and to follow the on-disk format, we
should still detect and repair such problems.

This patchset would implement detection and repair for both lowmem and
original mode, and a new hand crafted test case for it.

The reason why the test case is still handle crafted is, we do not have
the btrfs-corrupt-block support for corrupting ram_bytes to a specific
value yet.

I'd prefer to do the binary image migration to script in a dedicated
patchset in the future.

Qu Wenruo (3):
  btrfs-progs: check/lowmem: detect and repair mismatched ram_bytes
  btrfs-progs: check/original: detect and repair ram_bytes mismatch
  btrfs-progs: tests/fsck: add test case for ram_bytes detection and
    repair

 check/main.c                                  | 126 +++++++++++++++++-
 check/mode-lowmem.c                           |  69 ++++++++++
 check/mode-lowmem.h                           |   1 +
 check/mode-original.h                         |   8 ++
 .../default.img.xz                            | Bin 0 -> 2076 bytes
 5 files changed, 200 insertions(+), 4 deletions(-)
 create mode 100644 tests/fsck-tests/062-noncompressed-ram-bytes-mismatch/default.img.xz

--
2.45.0

Comments

David Sterba May 3, 2024, 1:29 p.m. UTC | #1
On Thu, May 02, 2024 at 06:37:52PM +0930, Qu Wenruo wrote:
> There are at least one kernel bug that makes on-disk
> btrfs_file_extent_item::ram_bytes incorrect for non-compressed non-hole
> data extents.
> 
> Thankfully kernel just doesn't care ram_bytes for non-compressed extents
> at all, so it doesn't lead to any data corruption or whatever, and this
> is really just a minor problem.
> 
> But for the sake of consistency and to follow the on-disk format, we
> should still detect and repair such problems.
> 
> This patchset would implement detection and repair for both lowmem and
> original mode, and a new hand crafted test case for it.
> 
> The reason why the test case is still handle crafted is, we do not have
> the btrfs-corrupt-block support for corrupting ram_bytes to a specific
> value yet.
> 
> I'd prefer to do the binary image migration to script in a dedicated
> patchset in the future.

The crafted binary images are ok for now, I've verified it by restoring,
did tree dump and check.

There's an issue tracking the other images audit,
https://github.com/kdave/btrfs-progs/issues/772, I did only a quick pass
but a tool that will do the restore/check and maybe some other steps
will be added to the repository.

Patches added to devel, thanks.