diff --git a/0028-vgsplit-fix-check-for-not-splitting-an-LV-between-tw.patch b/0028-vgsplit-fix-check-for-not-splitting-an-LV-between-tw.patch new file mode 100644 index 0000000000000000000000000000000000000000..b4007c58bd2501c7096acb33e21c29e5cbe78d56 --- /dev/null +++ b/0028-vgsplit-fix-check-for-not-splitting-an-LV-between-tw.patch @@ -0,0 +1,86 @@ +From 3fe57cc892fc984c30fb14c866a109ef17772ed4 Mon Sep 17 00:00:00 2001 +From: Peter Rajnoha +Date: Tue, 12 Aug 2025 11:32:18 +0200 +Subject: [PATCH] vgsplit: fix check for not splitting an LV between two VGs + for cachevol +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +When cachevol was used for the cache LV, the check for not splitting an +LV between two VGs was incorrect, not allowing to split the VG in cases +it should have been possible. + +For example, splitting a VG which contains the cache LV with cachevol +only on two devices (sda and sdb here) and leaving third device completely +unused (sdc here) should clearly allow us to split it into a new VG: + +❯ vgcreate vg /dev/sd{a..c} + Physical volume "/dev/sda" successfully created. + Physical volume "/dev/sdb" successfully created. + Physical volume "/dev/sdc" successfully created. + Volume group "vg" successfully created + +❯ lvcreate -l2 -n main vg /dev/sda + Logical volume "main" created. + +❯ lvcreate -l2 -n fast vg /dev/sdb + Logical volume "fast" created. + +❯ lvconvert -y --type cache --cachevol fast vg/main + Logical volume vg/main is now cached. + +❯ lvs -a -o name,devices vg + lv_name devices + [fast_cvol] /dev/sdb(0) + main main_corig(0) + [main_corig] /dev/sda(0) + +❯ lsblk -o name /dev/sd{a..c} +NAME +sda +└─vg-main_corig + └─vg-main +sdb +└─vg-fast_cvol + ├─vg-fast_cvol-cdata + │ └─vg-main + └─vg-fast_cvol-cmeta + └─vg-main +sdc + +Before this patch: + +❯ vgsplit vg vg2 /dev/sdc + Logical volume vg/main must be inactive. + +❯ vgchange -an vg + 0 logical volume(s) in volume group "vg" now active + +❯ vgsplit vg vg2 /dev/sdc + Can't split LV main between two Volume Groups + +With this patch applied: + +❯ vgsplit vg vg2 /dev/sdc + New volume group "vg2" successfully split from "vg" +--- + tools/vgsplit.c | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/tools/vgsplit.c b/tools/vgsplit.c +index 329bef3..dd1f754 100644 +--- a/tools/vgsplit.c ++++ b/tools/vgsplit.c +@@ -449,6 +449,8 @@ static int _move_cache(struct volume_group *vg_from, + + if (lv_is_cache_vol(lv)) { + fast = lv; ++ } else if (lv_is_cache_vol(seg->lv)) { ++ fast = seg->lv; + } else { + data = seg_lv(seg, 0); + meta = seg->metadata_lv; +-- +2.43.0 + diff --git a/lvm2.spec b/lvm2.spec index 8fdc8f60ca2ae6ab57d39e49db73e9534e54daaa..40b2d82b7c7e8fd902a46a7f38a2af53d44cb911 100644 --- a/lvm2.spec +++ b/lvm2.spec @@ -43,7 +43,7 @@ Name: lvm2 Version: 2.03.21 -Release: 18 +Release: 19 Epoch: 8 Summary: Tools for logical volume management License: GPLv2+ and LGPLv2.1 and BSD @@ -76,6 +76,7 @@ Patch24: 0024-config-check-for-0-from-read.patch Patch25: 0025-fix-multiple-mounts-in-lvextend.patch Patch26: 0026-fix-pv_major-and-pv_minor-report-field-type.patch Patch27: 0027-vgsplit-fix-check-for-not-splitting-an-LV-between-tw.patch +Patch28: 0028-vgsplit-fix-check-for-not-splitting-an-LV-between-tw.patch BuildRequires: gcc BuildRequires: gcc-c++ @@ -502,6 +503,9 @@ fi %changelog +* Mon Nov 10 2025 liuh - 8:2.03.21-19 +- vgsplit: fix check for not splitting an LV between two VGs for cachevol + * Sat Nov 8 2025 liuh - 8:2.03.21-18 - vgsplit: fix check for not splitting an LV between two VGs