mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-09 12:58:41 +03:00
If extending a VG and including a PV with 0 MDAs that was already a part of a VG, the vgextend allowed that PV to be added and we ended up *with one PV in two VGs*! The vgextend code used the 'pv_by_path' fn that returned a PV for a given path. However, when the PV did not have any metadata areas, the fn just returned a PV without any reference to existing VG. Consequently, any checks for the existing VG failed. [0] raw/~ # pvcreate --metadatacopies 0 /dev/sda Physical volume "/dev/sda" successfully created [0] raw/~ # pvcreate --metadatacopies 1 /dev/sdb Physical volume "/dev/sdb" successfully created [0] raw/~ # vgcreate vg1 /dev/sda /dev/sdb Volume group "vg1" successfully created [0] raw/~ # pvcreate --metadatacopies 1 /dev/sdc Physical volume "/dev/sdc" successfully created [0] raw/~ # vgcreate vg2 /dev/sdc Volume group "vg2" successfully created Before this patch (incorrect): [0] raw/~ # vgextend vg2 /dev/sda Volume group "vg2" successfully extended With this patch (correct): [0] raw/~ # vgextend vg2 /dev/sda Physical volume '/dev/sda' is already in volume group 'vg1' Unable to add physical volume '/dev/sda' to volume group 'vg2'.