linux/drivers/md/persistent-data
Mikulas Patocka 09a65adc7d dm-thin: fix metadata refcount underflow
There's a bug in dm-thin in the function rebalance_children. If the
internal btree node has one entry, the code tries to copy all btree
entries from the node's child to the node itself and then decrement the
child's reference count.

If the child node is shared (it has reference count > 1), we won't free
it, so there would be two pointers to each of the grandchildren nodes.
But the reference counts of the grandchildren is not increased, thus the
reference count doesn't match the number of pointers that point to the
grandchildren. This results in "device mapper: space map common: unable
to decrement block" errors.

Fix this bug by incrementing reference counts on the grandchildren if the
btree node is shared.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Fixes: 3241b1d3e0 ("dm: add persistent data library")
Cc: stable@vger.kernel.org
2026-04-20 19:56:44 +02:00
..
dm-array.c dm array: fix cursor index when skipping across block boundaries 2024-12-13 08:39:18 -05:00
dm-array.h dm: change "unsigned" to "unsigned int" 2023-02-14 14:23:06 -05:00
dm-bitset.c dm: add missing empty lines 2023-02-14 14:23:06 -05:00
dm-bitset.h
dm-block-manager.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
dm-block-manager.h dm: Constify struct dm_block_validator 2024-07-19 12:08:15 +02:00
dm-btree-internal.h dm: Constify struct dm_block_validator 2024-07-19 12:08:15 +02:00
dm-btree-remove.c dm-thin: fix metadata refcount underflow 2026-04-20 19:56:44 +02:00
dm-btree-spine.c dm: Constify struct dm_block_validator 2024-07-19 12:08:15 +02:00
dm-btree.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
dm-btree.h dm: add missing blank line after declarations/fix those 2023-02-14 14:23:07 -05:00
dm-persistent-data-internal.h dm: change "unsigned" to "unsigned int" 2023-02-14 14:23:06 -05:00
dm-space-map-common.c dm: Fix typo in error message 2024-11-20 11:38:04 +01:00
dm-space-map-common.h dm: favour __packed versus "__attribute__ ((packed))" 2023-02-14 14:23:07 -05:00
dm-space-map-disk.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
dm-space-map-disk.h
dm-space-map-metadata.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
dm-space-map-metadata.h
dm-space-map.h dm thin metadata: Fix ABBA deadlock by resetting dm_bufio_client 2023-06-16 18:24:13 -04:00
dm-transaction-manager.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
dm-transaction-manager.h dm: Constify struct dm_block_validator 2024-07-19 12:08:15 +02:00
Kconfig lib/crc: remove CONFIG_LIBCRC32C 2025-04-04 11:31:42 -07:00
Makefile