You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
btrfs-progs: check/lowmem: fix a false alert when counting the refs
[BUG]
For a btrfs which is under metadata balance and interrupted (powerloss
etc), we can have the following extent backref item for a data extent:
item 22 key (13631488 EXTENT_ITEM 524288) itemoff 3161 itemsize 108
refs 180 gen 9 flags DATA
(178 0xdfb591fbbf5f519) extent data backref root FS_TREE objectid 258 offset 0 count 77
(178 0xdfb591fa80d95ea) extent data backref root FS_TREE objectid 257 offset 0 count 1
(184 0x151e000) shared data backref parent 22142976 count 51
(184 0x512000) shared data backref parent 5316608 count 51
Then lowmem mode will cause the following false alert:
[3/8] checking extents
ERROR: extent[13631488, 524288] referencer count mismatch (root: 5, owner: 258, offset: 0) wanted: 77, have: 128
ERROR: errors found in extent allocation tree or chunk allocation
[CAUSE]
When shared and keyed backref items are found, we must follow the
following rules to avoid incorrect refs count:
- If the leaf belongs to the shared backref parent
Then any found EXTENT_DATA inside the leaf will be contributed to the
shared backref values.
- Otherwise any found EXTENT_DATA can contributed to the keyed backref
In above case, if our leaf is 5316608 or 22142976, then we should not
contribute the number of found EXTENT_DATA to the keyed backref.
Unfortunately the original fix d53d42f ("btrfs-progs: lowmem: fix
false alerts of referencer count mismatch for blocks relocated") is not
following the above strict rule, but relying on the flag of the leaf.
However that RELOC flag is not a correct indicator, e.g in above case
the leaf at 5316608 is not yet being relocated, thus no RELOC flag.
[FIX]
Instead of check the unreliable RELOC flag, follow the correct rule when
checking the leaf.
Before we start checking the content of a leaf for EXTENT_DATA items,
make sure the leaf's bytenr is not in any shared backref item.
If so skip to the next leaf.
Fixes: d53d42f ("btrfs-progs: lowmem: fix false alerts of referencer count mismatch for blocks relocated")
Signed-off-by: Qu Wenruo <[email protected]>
0 commit comments