Commit e85a0ad
btrfs: ensure releasing squota reserve on head refs
A reservation goes through a 3 step lifetime:
- generated during delalloc
- released/counted by ordered_extent allocation
- freed by running delayed ref
That third step depends on must_insert_reserved on the head ref, so the
head ref with that field set owns the reservation. Once you prepare to
run the head ref, must_insert_reserved is unset, which means that
running the ref must free the reservation, whether or not it succeeds,
or else the reservation is leaked. That results in either a risk of
spurious ENOSPC if the fs stays writeable or a warning on unmount if it
is readonly.
The existing squota code was aware of these invariants, but missed a few
cases. Improve it by adding a helper function to use in the cleanup
paths and call it from the existing early returns in running delayed
refs. This also simplifies btrfs_record_squota_delta and struct
btrfs_quota_delta.
This fixes (or at least improves the reliability of) generic/475 with
"mkfs -O squota". On my machine, that test failed ~4/10 times without
this patch and passed 100/100 times with it.
Signed-off-by: Boris Burkov <boris@bur.io>
Signed-off-by: David Sterba <dsterba@suse.com>1 parent a868055 commit e85a0ad
3 files changed
Lines changed: 46 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1547 | 1547 | | |
1548 | 1548 | | |
1549 | 1549 | | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
| 1553 | + | |
| 1554 | + | |
| 1555 | + | |
| 1556 | + | |
| 1557 | + | |
| 1558 | + | |
| 1559 | + | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
1550 | 1567 | | |
1551 | 1568 | | |
1552 | 1569 | | |
| |||
1569 | 1586 | | |
1570 | 1587 | | |
1571 | 1588 | | |
1572 | | - | |
1573 | 1589 | | |
1574 | 1590 | | |
1575 | 1591 | | |
| |||
1586 | 1602 | | |
1587 | 1603 | | |
1588 | 1604 | | |
| 1605 | + | |
1589 | 1606 | | |
1590 | 1607 | | |
1591 | | - | |
1592 | | - | |
1593 | | - | |
1594 | 1608 | | |
1595 | 1609 | | |
1596 | 1610 | | |
| |||
1742 | 1756 | | |
1743 | 1757 | | |
1744 | 1758 | | |
1745 | | - | |
1746 | 1759 | | |
1747 | 1760 | | |
1748 | 1761 | | |
| |||
1774 | 1787 | | |
1775 | 1788 | | |
1776 | 1789 | | |
1777 | | - | |
| 1790 | + | |
1778 | 1791 | | |
| 1792 | + | |
| 1793 | + | |
1779 | 1794 | | |
1780 | 1795 | | |
1781 | 1796 | | |
| |||
1871 | 1886 | | |
1872 | 1887 | | |
1873 | 1888 | | |
| 1889 | + | |
| 1890 | + | |
1874 | 1891 | | |
1875 | 1892 | | |
1876 | 1893 | | |
| |||
1885 | 1902 | | |
1886 | 1903 | | |
1887 | 1904 | | |
1888 | | - | |
| 1905 | + | |
1889 | 1906 | | |
1890 | | - | |
1891 | | - | |
1892 | | - | |
1893 | | - | |
| 1907 | + | |
| 1908 | + | |
| 1909 | + | |
1894 | 1910 | | |
1895 | | - | |
| 1911 | + | |
1896 | 1912 | | |
1897 | 1913 | | |
1898 | 1914 | | |
| |||
2033 | 2049 | | |
2034 | 2050 | | |
2035 | 2051 | | |
| 2052 | + | |
| 2053 | + | |
| 2054 | + | |
| 2055 | + | |
| 2056 | + | |
| 2057 | + | |
2036 | 2058 | | |
2037 | 2059 | | |
2038 | 2060 | | |
| |||
3292 | 3314 | | |
3293 | 3315 | | |
3294 | 3316 | | |
3295 | | - | |
3296 | 3317 | | |
3297 | 3318 | | |
3298 | 3319 | | |
| |||
4937 | 4958 | | |
4938 | 4959 | | |
4939 | 4960 | | |
4940 | | - | |
4941 | 4961 | | |
4942 | 4962 | | |
4943 | 4963 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4661 | 4661 | | |
4662 | 4662 | | |
4663 | 4663 | | |
| 4664 | + | |
| 4665 | + | |
| 4666 | + | |
| 4667 | + | |
| 4668 | + | |
| 4669 | + | |
| 4670 | + | |
| 4671 | + | |
| 4672 | + | |
| 4673 | + | |
| 4674 | + | |
4664 | 4675 | | |
4665 | 4676 | | |
4666 | 4677 | | |
| |||
4705 | 4716 | | |
4706 | 4717 | | |
4707 | 4718 | | |
4708 | | - | |
4709 | | - | |
4710 | | - | |
4711 | 4719 | | |
4712 | 4720 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
274 | 274 | | |
275 | 275 | | |
276 | 276 | | |
277 | | - | |
278 | | - | |
279 | 277 | | |
280 | 278 | | |
281 | 279 | | |
| |||
422 | 420 | | |
423 | 421 | | |
424 | 422 | | |
| 423 | + | |
425 | 424 | | |
426 | 425 | | |
427 | 426 | | |
| |||
0 commit comments