From 557b2850cef7fa49e2cbacd36e77f679181f09ae Mon Sep 17 00:00:00 2001 From: Heinz Mauelshagen Date: Wed, 17 Jul 2024 17:08:20 +0200 Subject: [PATCH] lv_manip: avoid unreleased memory pool(s) message on RAID extend In case of different PV sizes in a VG, the lvm2 allocator falls short to define extended segments resiliently asked for 100%FREE RaidLV extension and a RAID distinct allocation check fails. Fix is to release a memory pool on the resulting error path. Until the lvm2 allocator gets enhanced (WIP) to do such complex (and other) allocations proper, a workaround is to extend a RaidLV to any free space on its already allocated PVs by defining those PVs on the lvextend command line then iteratively run further such lvextend commands to extend it to its final intended size. Mind, this may be a non-trivial extension interation. --- lib/metadata/lv_manip.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c index 07becd16f..35263b802 100644 --- a/lib/metadata/lv_manip.c +++ b/lib/metadata/lv_manip.c @@ -4415,6 +4415,7 @@ static int _lv_extend_layered_lv(struct alloc_handle *ah, log_error("Failed to remove LV"); else if (!vg_write(vg) || !vg_commit(vg)) log_error("Failed to commit VG %s", vg->name); + dm_pool_free(vg->vgmem, lvl); return_0; } @@ -4571,7 +4572,7 @@ int lv_extend(struct logical_volume *lv, alloc != ALLOC_ANYWHERE && !(r = _lv_raid_redundant_allocation(lv, allocatable_pvs))) { log_error("Insufficient suitable allocatable extents for logical volume %s", display_lvname(lv)); - if (!lv_remove(lv) || !vg_write(lv->vg) || !vg_commit(lv->vg)) + if (!old_extents && (!lv_remove(lv) || !vg_write(lv->vg) || !vg_commit(lv->vg))) return_0; goto out; }