Commit 5f61b96
btrfs: fix inode lookup error handling during log replay
When replaying log trees we use read_one_inode() to get an inode, which is
just a wrapper around btrfs_iget_logging(), which in turn is a wrapper for
btrfs_iget(). But read_one_inode() always returns NULL for any error
that btrfs_iget_logging() / btrfs_iget() may return and this is a problem
because:
1) In many callers of read_one_inode() we convert the NULL into -EIO,
which is not accurate since btrfs_iget() may return -ENOMEM and -ENOENT
for example, besides -EIO and other errors. So during log replay we
may end up reporting a false -EIO, which is confusing since we may
not have had any IO error at all;
2) When replaying directory deletes, at replay_dir_deletes(), we assume
the NULL returned from read_one_inode() means that the inode doesn't
exist and then proceed as if no error had happened. This is wrong
because unless btrfs_iget() returned ERR_PTR(-ENOENT), we had an
actual error and the target inode may exist in the target subvolume
root - this may later result in the log replay code failing at a
later stage (if we are "lucky") or succeed but leaving some
inconsistency in the filesystem.
So fix this by not ignoring errors from btrfs_iget_logging() and as
a consequence remove the read_one_inode() wrapper and just use
btrfs_iget_logging() directly. Also since btrfs_iget_logging() is
supposed to be called only against subvolume roots, just like
read_one_inode() which had a comment about it, add an assertion to
btrfs_iget_logging() to check that the target root corresponds to a
subvolume root.
Fixes: 5d4f98a ("Btrfs: Mixed back reference (FORWARD ROLLING FORMAT CHANGE)")
Reviewed-by: Johannes Thumshirn <[email protected]>
Reviewed-by: Qu Wenruo <[email protected]>
Signed-off-by: Filipe Manana <[email protected]>
Signed-off-by: David Sterba <[email protected]>1 parent 54a7081 commit 5f61b96
1 file changed
Lines changed: 62 additions & 65 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
146 | 149 | | |
147 | 150 | | |
148 | 151 | | |
| |||
604 | 607 | | |
605 | 608 | | |
606 | 609 | | |
607 | | - | |
608 | | - | |
609 | | - | |
610 | | - | |
611 | | - | |
612 | | - | |
613 | | - | |
614 | | - | |
615 | | - | |
616 | | - | |
617 | | - | |
618 | | - | |
619 | | - | |
620 | | - | |
621 | | - | |
622 | 610 | | |
623 | 611 | | |
624 | 612 | | |
| |||
674 | 662 | | |
675 | 663 | | |
676 | 664 | | |
677 | | - | |
678 | | - | |
679 | | - | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
680 | 668 | | |
681 | 669 | | |
682 | 670 | | |
| |||
948 | 936 | | |
949 | 937 | | |
950 | 938 | | |
951 | | - | |
952 | | - | |
953 | | - | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
954 | 943 | | |
955 | 944 | | |
956 | 945 | | |
| |||
1169 | 1158 | | |
1170 | 1159 | | |
1171 | 1160 | | |
1172 | | - | |
1173 | | - | |
1174 | | - | |
1175 | | - | |
| 1161 | + | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
1176 | 1165 | | |
1177 | 1166 | | |
1178 | 1167 | | |
| |||
1317 | 1306 | | |
1318 | 1307 | | |
1319 | 1308 | | |
1320 | | - | |
1321 | | - | |
1322 | | - | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
1323 | 1312 | | |
1324 | 1313 | | |
1325 | 1314 | | |
| |||
1391 | 1380 | | |
1392 | 1381 | | |
1393 | 1382 | | |
1394 | | - | |
1395 | | - | |
1396 | | - | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
1397 | 1387 | | |
1398 | 1388 | | |
1399 | 1389 | | |
1400 | | - | |
1401 | | - | |
1402 | | - | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
1403 | 1394 | | |
1404 | 1395 | | |
1405 | 1396 | | |
| |||
1411 | 1402 | | |
1412 | 1403 | | |
1413 | 1404 | | |
1414 | | - | |
1415 | | - | |
1416 | 1405 | | |
1417 | | - | |
1418 | | - | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
1419 | 1412 | | |
1420 | 1413 | | |
1421 | 1414 | | |
| |||
1684 | 1677 | | |
1685 | 1678 | | |
1686 | 1679 | | |
1687 | | - | |
1688 | | - | |
1689 | | - | |
| 1680 | + | |
| 1681 | + | |
| 1682 | + | |
1690 | 1683 | | |
1691 | 1684 | | |
1692 | 1685 | | |
| |||
1722 | 1715 | | |
1723 | 1716 | | |
1724 | 1717 | | |
1725 | | - | |
1726 | | - | |
1727 | | - | |
| 1718 | + | |
| 1719 | + | |
| 1720 | + | |
1728 | 1721 | | |
1729 | 1722 | | |
1730 | 1723 | | |
| |||
1763 | 1756 | | |
1764 | 1757 | | |
1765 | 1758 | | |
1766 | | - | |
1767 | | - | |
1768 | | - | |
| 1759 | + | |
| 1760 | + | |
| 1761 | + | |
1769 | 1762 | | |
1770 | | - | |
1771 | | - | |
| 1763 | + | |
| 1764 | + | |
1772 | 1765 | | |
1773 | | - | |
| 1766 | + | |
1774 | 1767 | | |
1775 | 1768 | | |
1776 | 1769 | | |
| |||
1847 | 1840 | | |
1848 | 1841 | | |
1849 | 1842 | | |
1850 | | - | |
1851 | | - | |
1852 | | - | |
| 1843 | + | |
| 1844 | + | |
| 1845 | + | |
1853 | 1846 | | |
1854 | 1847 | | |
1855 | 1848 | | |
| |||
2149 | 2142 | | |
2150 | 2143 | | |
2151 | 2144 | | |
2152 | | - | |
2153 | | - | |
2154 | | - | |
| 2145 | + | |
| 2146 | + | |
| 2147 | + | |
| 2148 | + | |
2155 | 2149 | | |
2156 | 2150 | | |
2157 | 2151 | | |
| |||
2303 | 2297 | | |
2304 | 2298 | | |
2305 | 2299 | | |
2306 | | - | |
2307 | | - | |
2308 | | - | |
2309 | | - | |
| 2300 | + | |
| 2301 | + | |
| 2302 | + | |
| 2303 | + | |
2310 | 2304 | | |
2311 | | - | |
| 2305 | + | |
2312 | 2306 | | |
2313 | | - | |
| 2307 | + | |
| 2308 | + | |
| 2309 | + | |
| 2310 | + | |
2314 | 2311 | | |
2315 | 2312 | | |
2316 | 2313 | | |
| |||
2469 | 2466 | | |
2470 | 2467 | | |
2471 | 2468 | | |
2472 | | - | |
2473 | | - | |
2474 | | - | |
| 2469 | + | |
| 2470 | + | |
| 2471 | + | |
2475 | 2472 | | |
2476 | 2473 | | |
2477 | 2474 | | |
| |||
0 commit comments