Commit cffc5a2
btrfs: tree-checker: validate dref root and objectid
Not yet upstreamed.
[CORRUPTION]
There is a bug report that btrfs flips RO due to a corruption in the
extent tree, the involved dumps looks like this:
item 188 key (402811572224 168 4096) itemoff 14598 itemsize 79
extent refs 3 gen 3678544 flags 1
ref#0: extent data backref root 13835058055282163977 objectid 281473384125923 offset 81432576 count 1
ref#1: shared data backref parent 1947073626112 count 1
ref#2: shared data backref parent 1156030103552 count 1
BTRFS critical (device vdc1: state EA): unable to find ref byte nr 402811572224 parent 0 root 265 owner 28703026 offset 81432576 slot 189
BTRFS error (device vdc1: state EA): failed to run delayed ref for logical 402811572224 num_bytes 4096 type 178 action 2 ref_mod 1: -2
[CAUSE]
The corrupted entry is ref#0 of item 188.
The root number 13835058055282163977 is beyond the upper limit for root
items (the current limit is 1 << 48), and the objectid also looks
suspicious.
Only the offset and count is correct.
[ENHANCEMENT]
Although it's still unknown why we have such many bytes corrupted
randomly, we can still enhance the tree-checker for data backrefs by:
- Validate the root value
For now there should only be 3 types of roots can have data backref:
* subvolume trees
* data reloc trees
* root tree
Only for v1 space cache
- validate the objectid value
The objectid should be a valid inode number.
Hopefully we can catch such problem in the future with the new checkers.
Reported-by: Kai Krakow <hurikhan77@gmail.com>
Link: https://lore.kernel.org/linux-btrfs/CAMthOuPjg5RDT-G_LXeBBUUtzt3cq=JywF+D1_h+JYxe=WKp-Q@mail.gmail.com/#t
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>1 parent f8ae3d1 commit cffc5a2
1 file changed
+47
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1265 | 1265 | | |
1266 | 1266 | | |
1267 | 1267 | | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
1268 | 1281 | | |
1269 | 1282 | | |
1270 | 1283 | | |
| |||
1417 | 1430 | | |
1418 | 1431 | | |
1419 | 1432 | | |
| 1433 | + | |
| 1434 | + | |
1420 | 1435 | | |
1421 | 1436 | | |
1422 | 1437 | | |
| |||
1460 | 1475 | | |
1461 | 1476 | | |
1462 | 1477 | | |
| 1478 | + | |
| 1479 | + | |
1463 | 1480 | | |
1464 | 1481 | | |
1465 | 1482 | | |
1466 | 1483 | | |
1467 | 1484 | | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
1468 | 1498 | | |
1469 | 1499 | | |
1470 | 1500 | | |
| |||
1600 | 1630 | | |
1601 | 1631 | | |
1602 | 1632 | | |
| 1633 | + | |
| 1634 | + | |
1603 | 1635 | | |
1604 | 1636 | | |
1605 | 1637 | | |
1606 | 1638 | | |
1607 | 1639 | | |
1608 | 1640 | | |
1609 | 1641 | | |
| 1642 | + | |
| 1643 | + | |
1610 | 1644 | | |
| 1645 | + | |
| 1646 | + | |
| 1647 | + | |
| 1648 | + | |
| 1649 | + | |
| 1650 | + | |
| 1651 | + | |
| 1652 | + | |
| 1653 | + | |
| 1654 | + | |
| 1655 | + | |
| 1656 | + | |
| 1657 | + | |
1611 | 1658 | | |
1612 | 1659 | | |
1613 | 1660 | | |
| |||
0 commit comments