Bug 2095504

Summary: vgimportdevices: fix incorrect deviceidtype usage
Product: Red Hat Enterprise Linux 8 Reporter: David Teigland <teigland>
Component: lvm2Assignee: David Teigland <teigland>
lvm2 sub component: Devices, Filtering and Stacking QA Contact: cluster-qe <cluster-qe>
Status: CLOSED ERRATA Docs Contact:
Severity: unspecified    
Priority: unspecified CC: agk, cmarthal, heinzm, jbrassow, mcsontos, msnitzer, prajnoha, zkabelac
Version: 8.0Keywords: Triaged
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: lvm2-2.03.14-4.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-11-08 10:55:29 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description David Teigland 2022-06-09 19:29:34 UTC
Description of problem:
    
    When a VG has PVs with different device id types,
    it would try to use the idtype of the previous PV
    in the loop.  This would produce an unncessary warning,
    or could lead to using the devname idtype when a better
    idtype is available.

Testing:
create a VG from two PVs where each PV has a different device id type, e.g. loop_file and devname.
run vgimportdevices VG
the command will attempt to use the id type of the first dev for the second dev also, which will produce a warning or error, or may cause the first id type to be used for the second also.

fix in main branch:
https://sourceware.org/git/?p=lvm2.git;a=commit;h=151ce8b27672134438d0bc457f49123db96a176c

Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 2 Corey Marthaler 2022-06-14 22:53:22 UTC
I believe these are the errors still in rhel8.7:

kernel-4.18.0-400.el8    BUILT: Fri Jun 10 13:11:32 CDT 2022
lvm2-2.03.14-3.el8    BUILT: Tue Jan  4 14:54:16 CST 2022
lvm2-libs-2.03.14-3.el8    BUILT: Tue Jan  4 14:54:16 CST 2022


[root@hayes-01 ~]# cat /etc/lvm/devices/system.devices 
# LVM uses devices listed in this file.
# Created by LVM command lvmdevices pid 5914 at Tue Jun 14 17:48:03 2022
VERSION=1.1.57
[root@hayes-01 ~]# vgimportdevices df
  WARNING: ignoring deviceidtype loop_file which is not available for device.
  WARNING: ignoring deviceidtype loop_file which is not available for device.
  WARNING: ignoring deviceidtype loop_file which is not available for device.
  Added 4 devices to devices file.
[root@hayes-01 ~]#  cat /etc/lvm/devices/system.devices 
# LVM uses devices listed in this file.
# Created by LVM command vgimportdevices pid 5950 at Tue Jun 14 17:49:08 2022
VERSION=1.1.58
IDTYPE=loop_file IDNAME=/tmp/loopback.2420871.9685 DEVNAME=/dev/loop0 PVID=gHXiPpQH8RwBBOUNDXpkqBmWqVyYem0q
IDTYPE=mpath_uuid IDNAME=part1-mpath-36d094660575ece002291bade2acdbd28 DEVNAME=/dev/mapper/mpatha1 PVID=ysKIlI1r7ElNDVOgd0BrBsgexwEnhMc3
IDTYPE=crypt_uuid IDNAME=CRYPT-LUKS2-32a836d4b71845e7a241d7fad67887a2-multi_luks DEVNAME=/dev/mapper/multi_luks PVID=mkFaDWLrBdpxwuSQeRYNSzBDizUNjdVP
IDTYPE=sys_wwid IDNAME=naa.6d094660575ece002291bb4a313e4759 DEVNAME=/dev/sdf1 PVID=2xXLFSsoMaNdTjmxTBnaama0O49y70lL PART=1






This is presumably fixed in Rhel9.1:

kernel-5.14.0-108.el9    BUILT: Thu Jun  9 08:48:18 AM CDT 2022
lvm2-2.03.16-1.el9    BUILT: Wed May 18 12:08:33 PM CDT 2022
lvm2-libs-2.03.16-1.el9    BUILT: Wed May 18 12:08:33 PM CDT 2022


[root@hayes-02 ~]# cat /etc/lvm/devices/system.devices 
# LVM uses devices listed in this file.
# Created by LVM command lvmdevices pid 26595 at Tue Jun 14 17:47:58 2022
VERSION=1.1.163
[root@hayes-02 ~]# vgimportdevices df
  Added 4 devices to devices file.
[root@hayes-02 ~]#  cat /etc/lvm/devices/system.devices 
# LVM uses devices listed in this file.
# Created by LVM command vgimportdevices pid 26609 at Tue Jun 14 17:49:06 2022
VERSION=1.1.164
IDTYPE=loop_file IDNAME=/tmp/loopback.2420860.517 DEVNAME=/dev/loop1 PVID=ESCNqDNGdyebxKspNoTvGsCeEXjeemO6
IDTYPE=mpath_uuid IDNAME=part1-mpath-36d094660650d1e0022bd29f91ebe756c DEVNAME=/dev/mapper/mpatha1 PVID=hn8mrpIpMbL1FYFVWhQ0V3Al9Th07uiP
IDTYPE=crypt_uuid IDNAME=CRYPT-LUKS2-da00a612b2ce406fad66cbfa5c1776d8-multi_luks DEVNAME=/dev/mapper/multi_luks PVID=SEuwIbMrrmmZ0XQyXqfLqg2WhgKUpksM
IDTYPE=sys_wwid IDNAME=naa.6d094660650d1e0022bd2a001f1ae16e DEVNAME=/dev/sdf1 PVID=dftsl4WpDL640fc60CHevmc49uueoHWn PART=1






Full Scenario Output:
SCENARIO - multi_idtype_vgimportdevices:  Test vgimportdevices of a VG containing PVs with a variety of different deviceidtypes: loop, mpath, crypt, PV (bug 2095504) 
50+0 records in
50+0 records out
52428800 bytes (52 MB, 50 MiB) copied, 0.0257285 s, 2.0 GB/s
adding entry to the devices file for /dev/loop0
creating PV on hayes-01 using device /dev/loop0
pvcreate --yes -ff   /dev/loop0
  Physical volume "/dev/loop0" successfully created.
multipath /dev/sde
adding entry to the devices file for /dev/mapper/mpatha1
creating PV on hayes-01 using device /dev/mapper/mpatha1
pvcreate --yes -ff   /dev/mapper/mpatha1
  Physical volume "/dev/mapper/mpatha1" successfully created.
cryptsetup luksFormat /dev/sdd1
WARNING: Device /dev/sdd1 already contains a 'crypto_LUKS' superblock signature.
cryptsetup luksOpen /dev/sdd1 multi_luks
adding entry to the devices file for /dev/mapper/multi_luks
creating PV on hayes-01 using device /dev/mapper/multi_luks
pvcreate --yes -ff   /dev/mapper/multi_luks
  Wiping atari signature on /dev/mapper/multi_luks.
  Physical volume "/dev/mapper/multi_luks" successfully created.
adding entry to the devices file for /dev/sdf1
creating PV on hayes-01 using device /dev/sdf1
pvcreate --yes -ff   /dev/sdf1
  Physical volume "/dev/sdf1" successfully created.
creating VG on hayes-01 using PV(s) /dev/loop0 /dev/mapper/mpatha1 /dev/mapper/multi_luks /dev/sdf1
vgcreate    df /dev/loop0 /dev/mapper/mpatha1 /dev/mapper/multi_luks /dev/sdf1
  Volume group "df" successfully created
removing entry from the devices file for /dev/loop0
removing entry from the devices file for /dev/mapper/mpatha1
removing entry from the devices file for /dev/mapper/multi_luks
removing entry from the devices file for /dev/sdf1
  No matching physical volumes found
vgs df
  Volume group "df" not found
  Cannot process volume group df
vgs properly did NOT find VG df
Verify that all removed devices file entries can be recreated using vgimportdevices
vgimportdevices df
  WARNING: ignoring deviceidtype loop_file which is not available for device.
  WARNING: ignoring deviceidtype loop_file which is not available for device.
  WARNING: ignoring deviceidtype loop_file which is not available for device.
  Added 4 devices to devices file.
IDTYPE=loop_file IDNAME=/tmp/loopback.2420470.1984 DEVNAME=/dev/loop0 PVID=ZZG8GPteIOrN0H3xigmkGlYolrNA10nH
IDTYPE=mpath_uuid IDNAME=part1-mpath-36d094660575ece002291bade2acdbd28 DEVNAME=/dev/mapper/mpatha1 PVID=XcXJYN51i9i0iuKiLSjuulJu4CMW9Yvm
IDTYPE=crypt_uuid IDNAME=CRYPT-LUKS2-b15af1c10c4b49848b7bdafc83078c65-multi_luks DEVNAME=/dev/mapper/multi_luks PVID=HRFBKmvT9MONcFhxWEQR2k4nxW64Wpxk
IDTYPE=sys_wwid IDNAME=naa.6d094660575ece002291bb4a313e4759 DEVNAME=/dev/sdf1 PVID=Fz2BkPi3WUJlPNIL7y6gYTMULY0FqI33 PART=1
removing vg df from hayes-01
  Volume group "df" successfully removed
Clean up all four different device id types PVs
removing pv /dev/loop0 on hayes-01
  Labels on physical volume "/dev/loop0" successfully wiped.
removing entry from the devices file for /dev/loop0
removing pv /dev/mapper/mpatha1 on hayes-01
  Labels on physical volume "/dev/mapper/mpatha1" successfully wiped.
removing entry from the devices file for /dev/mapper/mpatha1
removing pv /dev/mapper/multi_luks on hayes-01
  Labels on physical volume "/dev/mapper/multi_luks" successfully wiped.
removing entry from the devices file for /dev/mapper/multi_luks
removing pv /dev/sdf1 on hayes-01
  Labels on physical volume "/dev/sdf1" successfully wiped.
removing entry from the devices file for /dev/sdf1
successfully reset wwids

Comment 3 Corey Marthaler 2022-06-21 21:57:51 UTC
Marking Verified:Tested with the initial 8.7 build. These warnings are no longer present.

kernel-4.18.0-400.el8    BUILT: Fri Jun 10 13:11:32 CDT 2022
lvm2-2.03.14-4.el8    BUILT: Wed Jun 15 17:14:34 CDT 2022
lvm2-libs-2.03.14-4.el8    BUILT: Wed Jun 15 17:14:34 CDT 2022



SCENARIO - multi_idtype_vgimportdevices:  Test vgimportdevices of a VG containing PVs with a variety of different deviceidtypes: loop, mpath, crypt, PV (bug 2095504) 
50+0 records in
50+0 records out
52428800 bytes (52 MB, 50 MiB) copied, 0.0252299 s, 2.1 GB/s
adding entry to the devices file for /dev/loop0
creating PV on hayes-02 using device /dev/loop0
pvcreate --yes -ff   /dev/loop0
  Physical volume "/dev/loop0" successfully created.
multipath /dev/sdf
adding entry to the devices file for /dev/mapper/mpatha1
creating PV on hayes-02 using device /dev/mapper/mpatha1
pvcreate --yes -ff   /dev/mapper/mpatha1
  Physical volume "/dev/mapper/mpatha1" successfully created.
cryptsetup luksFormat /dev/sdg1
WARNING: Device /dev/sdg1 already contains a 'crypto_LUKS' superblock signature.
cryptsetup luksOpen /dev/sdg1 multi_luks
adding entry to the devices file for /dev/mapper/multi_luks
creating PV on hayes-02 using device /dev/mapper/multi_luks
pvcreate --yes -ff   /dev/mapper/multi_luks
  Physical volume "/dev/mapper/multi_luks" successfully created.
adding entry to the devices file for /dev/sdh1
creating PV on hayes-02 using device /dev/sdh1
pvcreate --yes -ff   /dev/sdh1
  Physical volume "/dev/sdh1" successfully created.
creating VG on hayes-02 using PV(s) /dev/loop0 /dev/mapper/mpatha1 /dev/mapper/multi_luks /dev/sdh1
vgcreate    df /dev/loop0 /dev/mapper/mpatha1 /dev/mapper/multi_luks /dev/sdh1
  Volume group "df" successfully created
removing entry from the devices file for /dev/loop0
removing entry from the devices file for /dev/mapper/mpatha1
removing entry from the devices file for /dev/mapper/multi_luks
removing entry from the devices file for /dev/sdh1
  No matching physical volumes found
vgs df
  Volume group "df" not found
  Cannot process volume group df
vgs properly did NOT find VG df
Verify that all removed devices file entries can be recreated using vgimportdevices w/o idtype warnings
vgimportdevices df
  Added 4 devices to devices file.


IDTYPE=loop_file IDNAME=/tmp/loopback.2755419.5452 DEVNAME=/dev/loop0 PVID=CZsyShWz40mbQPzRdzNl5d2ohyVcxPle
IDTYPE=mpath_uuid IDNAME=part1-mpath-36d094660650d1e0022bd2a001f1ae16e DEVNAME=/dev/mapper/mpatha1 PVID=cJN5u7JoNfgM1RuNvKXe1R0tZ7L9znl8
IDTYPE=crypt_uuid IDNAME=CRYPT-LUKS2-f5a0770a83f649a9ba3874d10538165a-multi_luks DEVNAME=/dev/mapper/multi_luks PVID=iNBL26DwuFsg96Al9BYvuOcad4vU8wcf
IDTYPE=sys_wwid IDNAME=naa.6d094660650d1e0022bd2a0c1fd6d4e8 DEVNAME=/dev/sdh1 PVID=0dgPh0C0ZCV3VjlZNZhlXCo1iobBtu5H PART=1
removing vg df from hayes-02
  Volume group "df" successfully removed
Clean up all four different device id types PVs
removing pv /dev/loop0 on hayes-02
  Labels on physical volume "/dev/loop0" successfully wiped.
removing entry from the devices file for /dev/loop0
removing pv /dev/mapper/mpatha1 on hayes-02
  Labels on physical volume "/dev/mapper/mpatha1" successfully wiped.
removing entry from the devices file for /dev/mapper/mpatha1
removing pv /dev/mapper/multi_luks on hayes-02
  Labels on physical volume "/dev/mapper/multi_luks" successfully wiped.
removing entry from the devices file for /dev/mapper/multi_luks
removing pv /dev/sdh1 on hayes-02
  Labels on physical volume "/dev/sdh1" successfully wiped.
removing entry from the devices file for /dev/sdh1
successfully reset wwids
Using gpt label
Disk size: 1907199 MB
Num partitions: 1
Adding new primary partition: (40, 3905945559) = 1907199 MB
Committing changes

Comment 7 Corey Marthaler 2022-07-28 16:07:43 UTC
Fix verified in the latest kernel/lvm2 rpms as well.


kernel-4.18.0-411.el8    BUILT: Wed Jul 20 18:42:42 CDT 2022
lvm2-2.03.14-5.el8    BUILT: Thu Jul 14 09:23:13 CDT 2022
lvm2-libs-2.03.14-5.el8    BUILT: Thu Jul 14 09:23:13 CDT 2022



SCENARIO - multi_idtype_vgimportdevices:  Test vgimportdevices of a VG containing PVs with a variety of different deviceidtypes: loop, mpath, crypt, PV (bug 2095504) 
50+0 records in
50+0 records out
52428800 bytes (52 MB, 50 MiB) copied, 0.0251466 s, 2.1 GB/s
adding entry to the devices file for /dev/loop0
creating PV on hayes-02 using device /dev/loop0
pvcreate --yes -ff   /dev/loop0
  Physical volume "/dev/loop0" successfully created.
WARNING: This scenario will end up repartitioning your device for use w/ mpath!
multipath /dev/sdm
create: mpathb (36d094660650d1e0022bd2a2c21ba1de2) undef DELL,PERC H330 Adp
size=447G features='0' hwhandler='0' wp=undef
`-+- policy='service-time 0' prio=1 status=undef
  `- 0:2:12:0 sdm 8:192 undef ready running

adding entry to the devices file for /dev/mapper/mpathb1
creating PV on hayes-02 using device /dev/mapper/mpathb1
pvcreate --yes -ff   /dev/mapper/mpathb1
  Physical volume "/dev/mapper/mpathb1" successfully created.
cryptsetup luksFormat /dev/sdf1
cryptsetup luksOpen /dev/sdf1 multi_luks
adding entry to the devices file for /dev/mapper/multi_luks
creating PV on hayes-02 using device /dev/mapper/multi_luks
pvcreate --yes -ff   /dev/mapper/multi_luks
  Physical volume "/dev/mapper/multi_luks" successfully created.
adding entry to the devices file for /dev/sdc1
creating PV on hayes-02 using device /dev/sdc1
pvcreate --yes -ff   /dev/sdc1
  Physical volume "/dev/sdc1" successfully created.
creating VG on hayes-02 using PV(s) /dev/loop0 /dev/mapper/mpathb1 /dev/mapper/multi_luks /dev/sdc1
vgcreate    df /dev/loop0 /dev/mapper/mpathb1 /dev/mapper/multi_luks /dev/sdc1
  Volume group "df" successfully created
removing entry from the devices file for /dev/loop0
removing entry from the devices file for /dev/mapper/mpathb1
removing entry from the devices file for /dev/mapper/multi_luks
removing entry from the devices file for /dev/sdc1
  No matching physical volumes found
vgs df
  Volume group "df" not found
  Cannot process volume group df
vgs properly did NOT find VG df
Verify that all removed devices file entries can be recreated using vgimportdevices w/o idtype warnings
vgimportdevices df
  Added 4 devices to devices file.


IDTYPE=loop_file IDNAME=/tmp/loopback.518893.4108 DEVNAME=/dev/loop0 PVID=xin28xcOEddVJ88jtia1JaKa41OPVNcN
IDTYPE=mpath_uuid IDNAME=part1-mpath-36d094660650d1e0022bd2a2c21ba1de2 DEVNAME=/dev/mapper/mpathb1 PVID=IwqDlfpghspmgYhlPUZQXKlu4ppASBnX
IDTYPE=crypt_uuid IDNAME=CRYPT-LUKS2-d565d19a099c4cda8ac046754bda37fa-multi_luks DEVNAME=/dev/mapper/multi_luks PVID=IXVL84G1MwZSxWO8znIn0HSHK5TpG2qe
IDTYPE=sys_wwid IDNAME=naa.6d094660650d1e0022bd29ee1e0945a8 DEVNAME=/dev/sdc1 PVID=xMWJj8vqKAkOVrd32H4QzNJqBDKTfRYZ PART=1
removing vg df from hayes-02
  Volume group "df" successfully removed
Clean up all four different device id types PVs
removing pv /dev/loop0 on hayes-02
  Labels on physical volume "/dev/loop0" successfully wiped.
removing entry from the devices file for /dev/loop0
removing pv /dev/mapper/mpathb1 on hayes-02
  Labels on physical volume "/dev/mapper/mpathb1" successfully wiped.
removing entry from the devices file for /dev/mapper/mpathb1
removing pv /dev/mapper/multi_luks on hayes-02
  Labels on physical volume "/dev/mapper/multi_luks" successfully wiped.
removing entry from the devices file for /dev/mapper/multi_luks
removing pv /dev/sdc1 on hayes-02
  Labels on physical volume "/dev/sdc1" successfully wiped.
removing entry from the devices file for /dev/sdc1
multipath -f mpathb
multipath -W
successfully reset wwids
Using gpt label
Disk size: 457343 MB
Num partitions: 1
Adding new primary partition: (40, 936640471) = 457343 MB
Committing changes

Comment 9 errata-xmlrpc 2022-11-08 10:55:29 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (lvm2 bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:7792