Commit 5686459
ocfs2/heartbeat: fix slot mapping rollback leaks on error paths
o2hb_map_slot_data() allocates hr_tmp_block, hr_slots, hr_slot_data, and
pages in stages. If a later allocation fails, the current code returns
without unwinding the earlier allocations.
o2hb_region_dev_store() also leaves slot mapping resources behind when
setup aborts, and it keeps hr_aborted_start/hr_node_deleted set across
retries. That leaves stale state behind after a failed start.
Factor the slot cleanup into o2hb_unmap_slot_data(), use it from both
o2hb_map_slot_data() and o2hb_region_release(), and call it from the
dev_store() rollback after stopping a started heartbeat thread. While
freeing pages, clear each hr_slot_data entry as it is released, and reset
the start state before each new setup attempt.
This closes the slot mapping leak on allocation/setup failure paths and
keeps failed setup attempts retryable.
Link: https://lkml.kernel.org/r/20260330153428.19586-1-yufan.chen@linux.dev
Signed-off-by: Yufan Chen <ericterminal@gmail.com>
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Cc: Mark Fasheh <mark@fasheh.com>
Cc: Joel Becker <jlbec@evilplan.org>
Cc: Junxiao Bi <junxiao.bi@oracle.com>
Cc: Changwei Ge <gechangwei@live.cn>
Cc: Jun Piao <piaojun@huawei.com>
Cc: Heming Zhao <heming.zhao@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>1 parent e3a84be commit 5686459
1 file changed
Lines changed: 56 additions & 27 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1488 | 1488 | | |
1489 | 1489 | | |
1490 | 1490 | | |
1491 | | - | |
1492 | | - | |
1493 | | - | |
1494 | | - | |
| 1491 | + | |
1495 | 1492 | | |
1496 | 1493 | | |
1497 | 1494 | | |
1498 | | - | |
1499 | | - | |
1500 | | - | |
1501 | | - | |
1502 | | - | |
1503 | 1495 | | |
1504 | 1496 | | |
1505 | 1497 | | |
1506 | 1498 | | |
1507 | | - | |
| 1499 | + | |
1508 | 1500 | | |
| 1501 | + | |
| 1502 | + | |
1509 | 1503 | | |
1510 | 1504 | | |
| 1505 | + | |
1511 | 1506 | | |
1512 | 1507 | | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
| 1511 | + | |
| 1512 | + | |
| 1513 | + | |
| 1514 | + | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
1513 | 1527 | | |
1514 | 1528 | | |
1515 | 1529 | | |
1516 | | - | |
1517 | | - | |
1518 | 1530 | | |
1519 | 1531 | | |
1520 | 1532 | | |
| |||
1667 | 1679 | | |
1668 | 1680 | | |
1669 | 1681 | | |
| 1682 | + | |
1670 | 1683 | | |
1671 | 1684 | | |
1672 | 1685 | | |
1673 | 1686 | | |
1674 | 1687 | | |
1675 | 1688 | | |
1676 | 1689 | | |
1677 | | - | |
1678 | | - | |
| 1690 | + | |
| 1691 | + | |
1679 | 1692 | | |
1680 | 1693 | | |
1681 | | - | |
1682 | | - | |
| 1694 | + | |
| 1695 | + | |
1683 | 1696 | | |
1684 | | - | |
| 1697 | + | |
1685 | 1698 | | |
1686 | 1699 | | |
1687 | 1700 | | |
| |||
1695 | 1708 | | |
1696 | 1709 | | |
1697 | 1710 | | |
1698 | | - | |
| 1711 | + | |
1699 | 1712 | | |
1700 | | - | |
| 1713 | + | |
1701 | 1714 | | |
1702 | 1715 | | |
1703 | | - | |
| 1716 | + | |
1704 | 1717 | | |
1705 | 1718 | | |
1706 | 1719 | | |
| |||
1720 | 1733 | | |
1721 | 1734 | | |
1722 | 1735 | | |
| 1736 | + | |
| 1737 | + | |
| 1738 | + | |
| 1739 | + | |
1723 | 1740 | | |
1724 | 1741 | | |
1725 | 1742 | | |
| |||
1809 | 1826 | | |
1810 | 1827 | | |
1811 | 1828 | | |
1812 | | - | |
| 1829 | + | |
1813 | 1830 | | |
1814 | 1831 | | |
| 1832 | + | |
| 1833 | + | |
1815 | 1834 | | |
1816 | 1835 | | |
1817 | 1836 | | |
| |||
1823 | 1842 | | |
1824 | 1843 | | |
1825 | 1844 | | |
1826 | | - | |
| 1845 | + | |
1827 | 1846 | | |
1828 | 1847 | | |
1829 | 1848 | | |
1830 | 1849 | | |
1831 | 1850 | | |
1832 | | - | |
| 1851 | + | |
1833 | 1852 | | |
1834 | 1853 | | |
1835 | 1854 | | |
| |||
1860 | 1879 | | |
1861 | 1880 | | |
1862 | 1881 | | |
1863 | | - | |
| 1882 | + | |
1864 | 1883 | | |
1865 | 1884 | | |
1866 | 1885 | | |
| |||
1877 | 1896 | | |
1878 | 1897 | | |
1879 | 1898 | | |
1880 | | - | |
| 1899 | + | |
1881 | 1900 | | |
1882 | 1901 | | |
1883 | 1902 | | |
1884 | 1903 | | |
1885 | | - | |
| 1904 | + | |
1886 | 1905 | | |
1887 | 1906 | | |
1888 | 1907 | | |
| |||
1901 | 1920 | | |
1902 | 1921 | | |
1903 | 1922 | | |
1904 | | - | |
| 1923 | + | |
1905 | 1924 | | |
| 1925 | + | |
| 1926 | + | |
| 1927 | + | |
| 1928 | + | |
| 1929 | + | |
| 1930 | + | |
| 1931 | + | |
| 1932 | + | |
| 1933 | + | |
| 1934 | + | |
1906 | 1935 | | |
1907 | 1936 | | |
1908 | 1937 | | |
| |||
0 commit comments