Skip to content

btrfs-progs: Fixes inline ram_bytes related bugs

Qu Wenruo linux-btrfs 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest6 patches 7 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6btrfs-progs: restore: Fix wrong compressed item size for decompress()cmds-restore.c+2 -10 replies
2/6btrfs-progs: Get rid of the confusing btrfs_file_extent_inline_len()check/main.c check/mode-lowmem.c cmds-restore.c +3 more+6 -290 replies
3/6btrfs-progs: check/original: Detect and repair wrong inline ram_bytescheck/main.c check/mode-original.h+43 -24 replies
4/6btrfs-progs: check/lowmem: Prepare check_file_extent() to handle repaircheck/mode-lowmem.c+23 -220 replies
5/6btrfs-progs: check/lowmem: Repair wrong inlien ram_bytes for uncompressed extentcheck/mode-lowmem.c+72 -10 replies
6/6btrfs-progs: fsck-tests: Add test case for corrupted inline ram_bytestests/fsck-tests/035-inline-bad-ram-bytes/offset_by_one.img tests/fsck-tests/035-inline-bad-ram-bytes/test.sh+11 -00 replies

Reviews trailers per patch

1 of 6 patches has a Reviewed-by or Acked-by.

PatchSu YueSteve Leung
SeriesT-b
1/6
2/6
3/6R-b
4/6
5/6
6/6

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/6] btrfs-progs: Fixes inline ram_bytes related bugs

The patchset can be fetched from github (*):
https://github.com/adam900710/btrfs-progs/tree/inline_ram_bytes

It's based on David's devel branch, whose HEAD is:
commit 0d1c5812e28e286648781c7b35b542311cc01aa4 (david/devel)

Author: Matthias Benkard <[email protected]>
Date:   Wed Apr 25 16:34:54 2018 +0200

btrfs-progs: mkfs: traverse_directory: Reset error code on continue

Reported-by Steve Leung <[email protected]>, his old btrfs (at least offending inodes are from 2014) has inline uncompressed extent, while its ram_bytes mismatch with item size.

Latest kernel tree check catches this bug, while we failed to detect by dump-tree.

It turns out that btrfs-progs is doing something evil to avoid reading ram_bytes from inline uncompressed extent.

So this patchset will address all such ram_bytes related problems.

The 1st patch is a not-so-relative fix for restore, which is using ram_bytes for decompress. Although thanks to the compression header, we won't read out-of-boundary, but fixing it is never a bad thing.

The 2nd patch will get rid of the evil btrfs_file_extent_inline_len() which hides raw ram_bytes from us, and fooling us for a long long time.

The 3rd~5th patches introduce check/repair function for both original and lowmem mode (although lowmem mode can detect it even before this patch).

The last one is the test case for it as usual.

*: Or should I just migrate to gitlab after M$ acquired github?

Qu Wenruo (6):
btrfs-progs: restore: Fix wrong compressed item size for decompress()
btrfs-progs: Get rid of the confusing btrfs_file_extent_inline_len()
btrfs-progs: check/original: Detect and repair wrong inline ram_bytes
btrfs-progs: check/lowmem: Prepare check_file_extent() to handle
repair
btrfs-progs: check/lowmem: Repair wrong inlien ram_bytes for
uncompressed extent
btrfs-progs: fsck-tests: Add test case for corrupted inline ram_bytes

 check/main.c                                  |  46 ++++++-
 check/mode-lowmem.c                           | 120 ++++++++++++++----
 check/mode-original.h                         |   1 +
 cmds-restore.c                                |   5 +-
 ctree.h                                       |  22 ----
 file.c                                        |   3 +-
 print-tree.c                                  |   4 +-
 .../offset_by_one.img                         | Bin 0 -> 3072 bytes
 .../035-inline-bad-ram-bytes/test.sh          |  11 ++
 9 files changed, 157 insertions(+), 55 deletions(-)
 create mode 100644 tests/fsck-tests/035-inline-bad-ram-bytes/offset_by_one.img
 create mode 100755 tests/fsck-tests/035-inline-bad-ram-bytes/test.sh
Signature · 1 line
2.17.1