linux/fs/ocfs2/cluster
Yufan Chen 5686459423 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>
2026-04-15 02:15:01 -07:00
..
heartbeat.c ocfs2/heartbeat: fix slot mapping rollback leaks on error paths 2026-04-15 02:15:01 -07:00
heartbeat.h ocfs2: use bitmap API in fill_node_map 2022-11-18 13:55:06 -08:00
Makefile
masklog.c ocfs2: cluster: use default_groups in kobj_type 2022-01-15 16:30:24 +02:00
masklog.h ocfs2: miscellaneous spelling fixes 2025-01-12 20:21:07 -08:00
netdebug.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
nodemanager.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
nodemanager.h treewide: remove editor modelines and cruft 2021-05-07 00:26:34 -07:00
ocfs2_heartbeat.h treewide: remove editor modelines and cruft 2021-05-07 00:26:34 -07:00
ocfs2_nodemanager.h treewide: remove editor modelines and cruft 2021-05-07 00:26:34 -07:00
quorum.c ocfs2: miscellaneous spelling fixes 2025-01-12 20:21:07 -08:00
quorum.h treewide: remove editor modelines and cruft 2021-05-07 00:26:34 -07:00
sys.c treewide: remove editor modelines and cruft 2021-05-07 00:26:34 -07:00
sys.h treewide: remove editor modelines and cruft 2021-05-07 00:26:34 -07:00
tcp_internal.h treewide: remove editor modelines and cruft 2021-05-07 00:26:34 -07:00
tcp.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
tcp.h treewide: remove editor modelines and cruft 2021-05-07 00:26:34 -07:00