Commit 4f3fb9e
committed
btrfs-progs: enhance detection on unknown inode keys
There is a bug report that a bitflip corrupted one tree block, causing
a corruption that can not be repaired by btrfs-check.
The corruption looks like this:
item 10 key (730455 INODE_ITEM 0) itemoff 15456 itemsize 160
generation 7280 transid 9794 size 13829 nbytes 16384
block group 0 mode 100600 links 1 uid 1000 gid 1000 rdev 0
sequence 11 flags 0x0(none)
atime 1765397443.29231914 (2025-12-11 06:40:43)
ctime 1764798591.882909548 (2025-12-04 08:19:51)
mtime 1764798591.882909548 (2025-12-04 08:19:51)
otime 1764712848.413821734 (2025-12-03 08:30:48)
item 11 key (730455 UNKNOWN.8 1924) itemoff 15406 itemsize 50
Note item 11, it has a unknown key, but the itemsize indicates it's an
INODE_REF with 40 name_len (which matches the DIR_ITEM).
bin(BTRFS_INODE_REF_KEY) = 0b1100
bin(8) = 0b1000
So it's indeed a bitflip.
At least we should report such unknown inode key types as errors.
The lowmem mode is already doing such report, although not treating them as
an error.
The original mode just ignores them completely.
So this patch enhance btrfs check to:
- Report such unknown item and treat them as error for the original mode
- Treat such unknown item as error for the lowmem mode
Reported-by: mikkel+btrfs@mikkel.cc
Link: https://lore.kernel.org/linux-btrfs/5d5e344e-96be-4436-9a58-d60ba14fdb4f@gmx.com/T/#me22cef92653e660e88a4c005b10f5201a8fd83ac
Signed-off-by: Qu Wenruo <wqu@suse.com>1 parent 79c154a commit 4f3fb9e
3 files changed
+11
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
90 | 91 | | |
91 | 92 | | |
92 | 93 | | |
| |||
1895 | 1896 | | |
1896 | 1897 | | |
1897 | 1898 | | |
| 1899 | + | |
| 1900 | + | |
| 1901 | + | |
| 1902 | + | |
1898 | 1903 | | |
1899 | 1904 | | |
1900 | 1905 | | |
| |||
4027 | 4032 | | |
4028 | 4033 | | |
4029 | 4034 | | |
| 4035 | + | |
| 4036 | + | |
4030 | 4037 | | |
4031 | 4038 | | |
4032 | 4039 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2808 | 2808 | | |
2809 | 2809 | | |
2810 | 2810 | | |
2811 | | - | |
2812 | | - | |
| 2811 | + | |
| 2812 | + | |
| 2813 | + | |
2813 | 2814 | | |
2814 | 2815 | | |
2815 | 2816 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| |||
0 commit comments