From 6ea6e688ebe7018b22072457f2f921310bb15155 Mon Sep 17 00:00:00 2001 From: liuh Date: Sat, 8 Nov 2025 15:51:04 +0800 Subject: [PATCH] vgsplit: fix check for not splitting an LV between two VGs --- ...k-for-not-splitting-an-LV-between-tw.patch | 55 +++++++++++++++++++ lvm2.spec | 6 +- 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 0027-vgsplit-fix-check-for-not-splitting-an-LV-between-tw.patch diff --git a/0027-vgsplit-fix-check-for-not-splitting-an-LV-between-tw.patch b/0027-vgsplit-fix-check-for-not-splitting-an-LV-between-tw.patch new file mode 100644 index 0000000..360e752 --- /dev/null +++ b/0027-vgsplit-fix-check-for-not-splitting-an-LV-between-tw.patch @@ -0,0 +1,55 @@ +From 185455659347722a5eab26f1cc9f189076847e45 Mon Sep 17 00:00:00 2001 +From: Peter Rajnoha +Date: Fri, 25 Jul 2025 10:45:07 +0200 +Subject: [PATCH] vgsplit: fix check for not splitting an LV between two VGs +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Fix check for not splitting an LV between two VGs in case +where the LVs contains an internal layer. + +For example, integrity layer for RAIDs and splitting a PV that +is not part of the RAID LV at all (sdc here): + +❯ vgcreate vg /dev/sda /dev/sdb /dev/sdc + Volume group "vg" successfully created + +❯ lvcreate -l1 -m1 --type raid1 --raidintegrity y vg /dev/sda /dev/sdb + Logical volume "lvol0" created. + +Before this patch: + +❯ vgsplit vg vg2 /dev/sdc + Logical volume vg/lvol0_rimage_0 (part of lvol0) 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 lvol0_rimage_0 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, 1 insertion(+), 1 deletion(-) + +diff --git a/tools/vgsplit.c b/tools/vgsplit.c +index c7f4b8a..329bef3 100644 +--- a/tools/vgsplit.c ++++ b/tools/vgsplit.c +@@ -169,7 +169,7 @@ static int _move_lvs(struct volume_group *vg_from, struct volume_group *vg_to) + + } + +- if (vg_with == vg_from) ++ if (!vg_with || vg_with == vg_from) + continue; + + /* Move this LV */ +-- +2.43.0 + diff --git a/lvm2.spec b/lvm2.spec index 1e675c1..8fdc8f6 100644 --- a/lvm2.spec +++ b/lvm2.spec @@ -43,7 +43,7 @@ Name: lvm2 Version: 2.03.21 -Release: 17 +Release: 18 Epoch: 8 Summary: Tools for logical volume management License: GPLv2+ and LGPLv2.1 and BSD @@ -75,6 +75,7 @@ Patch23: 0023-fix-function-undeclared-in-libdm-common.c-and-dev-cache.c.patch 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 BuildRequires: gcc BuildRequires: gcc-c++ @@ -501,6 +502,9 @@ fi %changelog +* Sat Nov 8 2025 liuh - 8:2.03.21-18 +- vgsplit: fix check for not splitting an LV between two VGs + * Mon Oct 27 2025 weishuaihao - 8:2.03.21-17 - fix pv_major and pv_minor report field type -- Gitee