Bug 2039977

Summary: lvmdevices --check|update do not seem to work currently
Product: Red Hat Enterprise Linux 8 Reporter: Corey Marthaler <cmarthal>
Component: lvm2Assignee: David Teigland <teigland>
lvm2 sub component: Devices, Filtering and Stacking QA Contact: cluster-qe <cluster-qe>
Status: CLOSED ERRATA Docs Contact:
Severity: medium    
Priority: high CC: agk, heinzm, jbrassow, mcsontos, mgandhi, msnitzer, prajnoha, teigland, zkabelac
Version: 8.6Keywords: Triaged
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: lvm2-2.03.14-4.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 2040482 (view as bug list) Environment:
Last Closed: 2022-11-08 10:55:24 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:
Bug Depends On:    
Bug Blocks: 2040482    

Description Corey Marthaler 2022-01-12 20:15:07 UTC
Description of problem:
I wrote a scenario to corrupt each of the attributes of a devicesfile entry and it didn't appear that the check or update options do anything with the corruption. 


kernel-4.18.0-357.el8    BUILT: Wed Dec 22 15:55:27 CST 2021
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



LVMDEVICES(8)                                                                          System Manager's Manual                                                                          LVMDEVICES(8)
       Check the devices file and report incorrect values.

       lvmdevices --check
           [ COMMON_OPTIONS ]

       Update the devices file to fix incorrect values.

       lvmdevices --update
           [ COMMON_OPTIONS ]


SCENARIO - altered_devicesfile_check_and_repair:  Test the discovery and repair of an altered|corrupted devicesfile entry 

+++ Corrupting IDTYPE +++
Copying out blanked system.devices file to begin with
/tmp/system495.devices -> hayes-01:/etc/lvm/devices/system.devices
lvmdevices --adddev /dev/sdd1
Altered entry:
IDTYPE=corrupted IDNAME=naa.6d094660575ece002291ba5c230d16c6 DEVNAME=/dev/sdd1 PVID=XstIe4l7LLT9ipevUzziOErCADLg29Uz PART=1 
Copying out altered system.devices file to hayes-01
/tmp/system576.devices -> hayes-01:/etc/lvm/devices/system.devices
lvmdevices --check
  Devices file unknown naa.6d094660575ece002291ba5c230d16c6 PVID XstIe4l7LLT9ipevUzziOErCADLg29Uz last seen on /dev/sdd1 not found.
lvmdevices SHOULD have found the corruption for /dev/sdd1 entry
lvmdevices --update
  Devices file unknown naa.6d094660575ece002291ba5c230d16c6 PVID XstIe4l7LLT9ipevUzziOErCADLg29Uz last seen on /dev/sdd1 not found.
  No update for devices file is needed.
lvmdevices SHOULD have updated the corruption for /dev/sdd1 entry

+++ Corrupting IDNAME +++
Copying out blanked system.devices file to begin with
/tmp/system1539.devices -> hayes-01:/etc/lvm/devices/system.devices
lvmdevices --adddev /dev/sdd1
Altered entry:
IDTYPE=sys_wwid IDNAME=corrupted DEVNAME=/dev/sdd1 PVID=XstIe4l7LLT9ipevUzziOErCADLg29Uz PART=1 
Copying out altered system.devices file to hayes-01
/tmp/system890.devices -> hayes-01:/etc/lvm/devices/system.devices
lvmdevices --check
  Devices file sys_wwid corrupted PVID XstIe4l7LLT9ipevUzziOErCADLg29Uz last seen on /dev/sdd1 not found.
lvmdevices SHOULD have found the corruption for /dev/sdd1 entry
lvmdevices --update
  Devices file sys_wwid corrupted PVID XstIe4l7LLT9ipevUzziOErCADLg29Uz last seen on /dev/sdd1 not found.
  No update for devices file is needed.
lvmdevices SHOULD have updated the corruption for /dev/sdd1 entry

+++ Corrupting PVID +++
Copying out blanked system.devices file to begin with
/tmp/system1407.devices -> hayes-01:/etc/lvm/devices/system.devices
lvmdevices --adddev /dev/sdd1
Altered entry:
IDTYPE=sys_wwid IDNAME=naa.6d094660575ece002291ba5c230d16c6 DEVNAME=/dev/sdd1 PVID=corrupted PART=1 
Copying out altered system.devices file to hayes-01
/tmp/system1364.devices -> hayes-01:/etc/lvm/devices/system.devices
lvmdevices --check
  Device /dev/sdd1 has PVID XstIe4l7LLT9ipevUzziOErCADLg29Uz (devices file corrupted)
lvmdevices SHOULD have found the corruption for /dev/sdd1 entry
lvmdevices --update
  Device /dev/sdd1 has PVID XstIe4l7LLT9ipevUzziOErCADLg29Uz (devices file corrupted)
  Updated devices file to version 1.1.1256
lvmdevices SHOULD have updated the corruption for /dev/sdd1 entry

+++ Corrupting PART +++
Copying out blanked system.devices file to begin with
/tmp/system819.devices -> hayes-01:/etc/lvm/devices/system.devices
lvmdevices --adddev /dev/sdd1
Altered entry:
IDTYPE=sys_wwid IDNAME=naa.6d094660575ece002291ba5c230d16c6 DEVNAME=/dev/sdd1 PVID=XstIe4l7LLT9ipevUzziOErCADLg29Uz PART=corrupted 
Copying out altered system.devices file to hayes-01
/tmp/system1450.devices -> hayes-01:/etc/lvm/devices/system.devices
lvmdevices --check
  Devices file /dev/sdd is excluded by filter: device is partitioned.
lvmdevices SHOULD have found the corruption for /dev/sdd1 entry
lvmdevices --update
  No update for devices file is needed.
  Devices file /dev/sdd is excluded by filter: device is partitioned.
lvmdevices SHOULD have updated the corruption for /dev/sdd1 entry


Version-Release number of selected component (if applicable):
kernel-4.18.0-357.el8    BUILT: Wed Dec 22 15:55:27 CST 2021
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

Comment 1 David Teigland 2022-01-12 23:07:03 UTC
The purpose of lvmdevices check|update is only vaguely described in the man page, so the main thing to do is to precisely define what is actually checked and fixed.  It's primarily the unstable DEVNAME field, but there might be one or two other things.

Comment 2 David Teigland 2022-01-14 21:55:37 UTC
in stable branch: https://sourceware.org/git/?p=lvm2.git;a=commit;h=bb477d63e336a10e5959962a9f26a028ea9e55eb

This improves the lvmdevices check output to have an error exit if the devices file needs an update.

Comment 6 Corey Marthaler 2022-07-15 20:06:13 UTC
Marking verified in the latest rpms.

kernel-4.18.0-398.g366e.el8.kpq1    BUILT: Tue Jun  7 04:56:38 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 - altered_pvid_check_and_repair:  Test the discovery and repair of an altered pvid in devicesfile entry (bug 2039977|2040482) 
Copying out blanked system.devices file to begin with
/tmp/system247.devices -> hayes-01:/etc/lvm/devices/system.devices
adding entry to the devices file for /dev/sdi1
path:/dev/sdi1
Altered entry:
IDTYPE=sys_wwid IDNAME=naa.6d094660575ece002291be7e6227ca72 DEVNAME=/dev/sdi1 PVID=c0rrup7HQrZNds PART=1 
Copying out altered system.devices file to hayes-01
/tmp/system1938.devices -> hayes-01:/etc/lvm/devices/system.devices
lvmdevices --check
  Device /dev/sdi1 has no PVID (devices file c0rrup7HQrZNds)
  Updates needed for devices file.

lvmdevices --update
  Updated devices file to version 1.1.1415

1.1.1414 == 1.1.1415
lvmdevices --deldev /dev/sdi1



SCENARIO - altered_pvid_w_pv_label_present_check_and_repair:  Test for the alteration of the devicesfiles pvid when a pv label exists (2039977|2040482) 
Copying out blanked system.devices file to begin with
/tmp/system1619.devices -> hayes-01:/etc/lvm/devices/system.devices
adding entry to the devices file for /dev/sdi1
creating PV on hayes-01 using device /dev/sdi1
pvcreate --yes -ff   /dev/sdi1
  Physical volume "/dev/sdi1" successfully created.

Altered entry:
IDTYPE=sys_wwid IDNAME=naa.6d094660575ece002291be7e6227ca72 DEVNAME=/dev/sdi1 PVID=c0rrup7HQrZNds PART=1 
Copying out altered system.devices file to hayes-01
/tmp/system1148.devices -> hayes-01:/etc/lvm/devices/system.devices
path:/dev/sdi1
lvmdevices --check
  Device /dev/sdi1 has PVID wFc9PteWP7HzZSiKHIOuBVI7Z0nkXbhm (devices file c0rrup7HQrZNds)
  Updates needed for devices file.

lvmdevices --update
  Updated devices file to version 1.1.1419

1.1.1418 == 1.1.1419
removing pv /dev/sdi1 on hayes-01
  Labels on physical volume "/dev/sdi1" successfully wiped.
removing entry from the devices file for /dev/sdi1



SCENARIO - altered_devname_w_pv_label_present_check_and_repair:  Test for the alteration of the devicesfiles devname when a pv label exists (2039977|2040482) 
Copying out blanked system.devices file to begin with
/tmp/system1307.devices -> hayes-01:/etc/lvm/devices/system.devices
adding entry to the devices file for /dev/sdi1
creating PV on hayes-01 using device /dev/sdi1
pvcreate --yes -ff   /dev/sdi1
  Physical volume "/dev/sdi1" successfully created.

Altered entry:
IDTYPE=sys_wwid IDNAME=naa.6d094660575ece002291be7e6227ca72 DEVNAME=/dev/sdi PVID=JoJ8ooCPAoU3200DtSoIIL2t2GPjQ2bO PART=1 
Copying out altered system.devices file to hayes-01
/tmp/system206.devices -> hayes-01:/etc/lvm/devices/system.devices
path:/dev/sdi1
lvmdevices --check
  Device /dev/sdi1 has updated name (devices file /dev/sdi)
  Updates needed for devices file.

lvmdevices --update
  Updated devices file to version 1.1.1424

1.1.1423 == 1.1.1424
removing pv /dev/sdi1 on hayes-01
  Labels on physical volume "/dev/sdi1" successfully wiped.
removing entry from the devices file for /dev/sdi1



SCENARIO - altered_devname_check_and_repair:  Test the discovery and repair of an altered devname in devicesfile entry (bug 2039977|2040482) 
Copying out blanked system.devices file to begin with
/tmp/system1390.devices -> hayes-01:/etc/lvm/devices/system.devices
adding entry to the devices file for /dev/sdi1
path:/dev/sdi1
Altered entry:
IDTYPE=sys_wwid IDNAME=naa.6d094660575ece002291be7e6227ca72 DEVNAME=/dev/sdz1 PVID=. PART=1 
Copying out altered system.devices file to hayes-01
/tmp/system445.devices -> hayes-01:/etc/lvm/devices/system.devices
lvmdevices --check
  Device /dev/sdi1 has updated name (devices file /dev/sdz1)
  Updates needed for devices file.

lvmdevices --update
  Updated devices file to version 1.1.1428

1.1.1427 == 1.1.1428
lvmdevices --deldev /dev/sdi1

Comment 9 Corey Marthaler 2022-07-27 18:31:02 UTC
Verified with the latest kernel/lvm2 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 - altered_pvid_check_and_repair:  Test the discovery and repair of an altered pvid in devicesfile entry (bug 2039977|2040482) 
Copying out blanked system.devices file to begin with
/tmp/system1710.devices -> hayes-01:/etc/lvm/devices/system.devices
adding entry to the devices file for /dev/sde1
path:/dev/sde1
Altered entry:
IDTYPE=sys_wwid IDNAME=naa.6d094660575ece002291bade2acdbd28 DEVNAME=/dev/sde1 PVID=c0rrup7HQrZNds PART=1 
Copying out altered system.devices file to hayes-01
/tmp/system1627.devices -> hayes-01:/etc/lvm/devices/system.devices
lvmdevices --check
  Device /dev/sde1 has no PVID (devices file c0rrup7HQrZNds)
  Updates needed for devices file.

lvmdevices --update
  Updated devices file to version 1.1.27

1.1.26 == 1.1.27
lvmdevices --deldev /dev/sde1


SCENARIO - altered_devname_w_pv_label_present_check_and_repair:  Test for the alteration of the devicesfiles devname when a pv label exists (2039977|2040482) 
Copying out blanked system.devices file to begin with
/tmp/system1817.devices -> hayes-01:/etc/lvm/devices/system.devices
adding entry to the devices file for /dev/sde1
creating PV on hayes-01 using device /dev/sde1
pvcreate --yes -ff   /dev/sde1
  Physical volume "/dev/sde1" successfully created.

Altered entry:
IDTYPE=sys_wwid IDNAME=naa.6d094660575ece002291bade2acdbd28 DEVNAME=/dev/sde PVID=3260ikGymBnreYReSr3cr18vIcKi4poe PART=1 
Copying out altered system.devices file to hayes-01
/tmp/system1739.devices -> hayes-01:/etc/lvm/devices/system.devices
path:/dev/sde1
lvmdevices --check
  Device /dev/sde1 has updated name (devices file /dev/sde)
  Updates needed for devices file.

lvmdevices --update
  Updated devices file to version 1.1.31

1.1.30 == 1.1.31
removing pv /dev/sde1 on hayes-01
  Labels on physical volume "/dev/sde1" successfully wiped.
removing entry from the devices file for /dev/sde1


SCENARIO - altered_devname_check_and_repair:  Test the discovery and repair of an altered devname in devicesfile entry (bug 2039977|2040482) 
Copying out blanked system.devices file to begin with
/tmp/system515.devices -> hayes-01:/etc/lvm/devices/system.devices
adding entry to the devices file for /dev/sde1
path:/dev/sde1
Altered entry:
IDTYPE=sys_wwid IDNAME=naa.6d094660575ece002291bade2acdbd28 DEVNAME=/dev/sdz1 PVID=. PART=1 
Copying out altered system.devices file to hayes-01
/tmp/system110.devices -> hayes-01:/etc/lvm/devices/system.devices
lvmdevices --check
  Device /dev/sde1 has updated name (devices file /dev/sdz1)
  Updates needed for devices file.

lvmdevices --update
  Updated devices file to version 1.1.35

1.1.34 == 1.1.35
lvmdevices --deldev /dev/sde1


SCENARIO - altered_pvid_w_pv_label_present_check_and_repair:  Test for the alteration of the devicesfiles pvid when a pv label exists (2039977|2040482) 
Copying out blanked system.devices file to begin with
/tmp/system1945.devices -> hayes-01:/etc/lvm/devices/system.devices
adding entry to the devices file for /dev/sde1
creating PV on hayes-01 using device /dev/sde1
pvcreate --yes -ff   /dev/sde1
  Physical volume "/dev/sde1" successfully created.

Altered entry:
IDTYPE=sys_wwid IDNAME=naa.6d094660575ece002291bade2acdbd28 DEVNAME=/dev/sde1 PVID=c0rrup7HQrZNds PART=1 
Copying out altered system.devices file to hayes-01
/tmp/system496.devices -> hayes-01:/etc/lvm/devices/system.devices
path:/dev/sde1
lvmdevices --check
  Device /dev/sde1 has PVID sJsn2hYZOS6gPh2GdtWeLsgZd2iffqES (devices file c0rrup7HQrZNds)
  Updates needed for devices file.

lvmdevices --update
  Updated devices file to version 1.1.39

1.1.38 == 1.1.39
removing pv /dev/sde1 on hayes-01
  Labels on physical volume "/dev/sde1" successfully wiped.
removing entry from the devices file for /dev/sde1

Comment 11 errata-xmlrpc 2022-11-08 10:55:24 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