Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 2119473

Summary: lvm crashes during recreation of a PV with a uuid of a missing PV
Product: Red Hat Enterprise Linux 9 Reporter: Lukáš Zaoral <lzaoral>
Component: lvm2Assignee: David Teigland <teigland>
lvm2 sub component: Command-line tools QA Contact: cluster-qe <cluster-qe>
Status: CLOSED ERRATA Docs Contact:
Severity: unspecified    
Priority: unspecified CC: agk, cmarthal, heinzm, jbrassow, msnitzer, pcahyna, prajnoha, teigland, thornber, zkabelac
Version: 9.0Keywords: Triaged
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: lvm2-2.03.17-1.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 2121237 (view as bug list) Environment:
Last Closed: 2023-05-09 08:23:45 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: 2117937, 2121237    

Description Lukáš Zaoral 2022-08-18 15:49:01 UTC
Description of problem: lvm crashes during recreation of a PV with a uuid of a missing PV


Version-Release number of selected component (if applicable): lvm2-2.03.16-3.el9


How reproducible: always


Steps to Reproduce:

1. Get an empty disk (e.g. /dev/vdb).
2. Install lvm2 package.
2. Create one partition on /dev/vdb (e.g. using fdisk).
3. # pvcreate /dev/vdb1
4. # pvscan -u
  PV /dev/vdb1 with UUID LQbrRY-PusD-1f3b-bW0U-akcG-wEwy-s2DqBA                       lvm2 [<10.00 GiB]
  Total: 1 [<10.00 GiB] / in use: 0 [0   ] / in no VG: 1 [<10.00 GiB]
5. # wipefs -fa /dev/vdb1
6. # lvm pvcreate -ff --yes -v --uuid LQbrRY-PusD-1f3b-bW0U-akcG-wEwy-s2DqBA --norestorefile /dev/vdb1
  Devices file PVID LQbrRYPusD1f3bbW0UakcGwEwys2DqBA not found on device /dev/vdb1.
  Wiping signatures on new PV /dev/vdb1.
  WARNING: adding device /dev/vdb1 with PVID LQbrRYPusD1f3bbW0UakcGwEwys2DqBA which is already used for missing device.
Segmentation fault (core dumped)

Actual results: segmentation fault

Expected results: PV will be recreated without a crash.

Additional info:
Originally reported in bz2117937.  This is not critical because a workaround on rear's side exists (see https://bugzilla.redhat.com/show_bug.cgi?id=2117937#c4).

Coredump stack trace:

#0  0x00007f65a449f8e2 __strcmp_evex (libc.so.6 + 0xcd8e2)
#1  0x000055e3471c76ec device_id_add (lvm + 0xb96ec)
#2  0x000055e3471914fa pvcreate_each_device (lvm + 0x834fa)
#3  0x000055e34717715d pvcreate (lvm + 0x6915d)
#4  0x000055e34716a935 lvm_run_command (lvm + 0x5c935)
#5  0x000055e34716c561 lvm2_main (lvm + 0x5e561)
#6  0x00007f65a4411eb0 __libc_start_call_main (libc.so.6 + 0x3feb0)
#7  0x00007f65a4411f60 __libc_start_main@@GLIBC_2.34 (libc.so.6 + 0x3ff60)
#8  0x000055e347146e45 _start (lvm + 0x38e45)
ELF object binary architecture: AMD x86-64

Comment 1 David Teigland 2022-08-19 18:39:27 UTC
fixed on main branch
https://sourceware.org/git/?p=lvm2.git;a=commit;h=8c3cfc75c72696ae8b620555fcc4f815b0c1d6b6

Note that the test above requires the device to use IDTYPE=devname which causes the IDNAME to be cleared in the devices file when it becomes invalid.  The blank IDNAME field is what reveals the bug.  I used /dev/ram0 (which uses IDNAME=devname) to reproduced and verify.

Comment 2 Corey Marthaler 2022-08-24 21:22:24 UTC
Adding QA ack for 9.2

SCENARIO - recreation_of_brd_pv_using_uuid_after_device_goes_missing:  Ensure lvm can recreate a brd PV, which uses IDNAME=devname, using uuid once the device is wiped (bug 2119473) 
Loading block ram disk module

adding entry to the devices file for /dev/ram6
creating PV on hayes-01 using device /dev/ram6
pvcreate --yes -ff   /dev/ram6
  Physical volume "/dev/ram6" successfully created.
PV uuid for /dev/ram6: UnPPU9M2CpjZFovviKRkBJ9NsnQvsw8G
Wiping brd header (wipefs -fa /dev/ram6)
/dev/ram6: 8 bytes were erased at offset 0x00000218 (LVM2_member): 4c 56 4d 32 20 30 30 31
pvcreate -ff --yes -v --uuid UnPPU9M2CpjZFovviKRkBJ9NsnQvsw8G --norestorefile /dev/ram6

  Devices file PVID UnPPU9M2CpjZFovviKRkBJ9NsnQvsw8G not found on device /dev/ram6.
  Wiping signatures on new PV /dev/ram6.
  WARNING: adding device /dev/ram6 with PVID UnPPU9M2CpjZFovviKRkBJ9NsnQvsw8G which is already used for missing device.

pv-recreation failed with a valid uuid and wiped header (bug 2119473)
Aug 24 16:18:02 hayes-01 kernel: pvcreate[157676]: segfault at 0 ip 00007fb45bdb8192 sp 00007ffe16f5ff48 error 4 in libc-2.28.so[7fb45bcf0000+1bc000]
Aug 24 16:18:02 hayes-01 kernel: Code: 0f 1f 84 00 00 00 00 00 f3 0f 1e fa 89 f8 31 d2 c5 c5 ef ff 09 f0 25 ff 0f 00 00 3d 80 0f 00 00 0f 8f 52 03 00 00 c5 fe 6f 0f <c5> f5 74 06 c5f

Comment 3 Pavel Cahyna 2022-10-14 12:35:18 UTC
(In reply to David Teigland from comment #1)

> Note that the test above requires the device to use IDTYPE=devname which
> causes the IDNAME to be cleared in the devices file when it becomes invalid.
> The blank IDNAME field is what reveals the bug.  I used /dev/ram0 (which
> uses IDNAME=devname) to reproduced and verify.

Indeed. The bug originally happened on a PowerVM LPAR, where the virtual SCSI disks are using IDTYPE=devname:

# LVM uses devices listed in this file.
# Created by LVM command vgchange pid 637 at Fri Aug 26 12:22:22 2022
VERSION=1.1.5
IDTYPE=devname IDNAME=/dev/sda3 DEVNAME=/dev/sda3 PVID=r9h2EoNfx5FhWY7D4OWxrSU54xu0TkM1 PART=3
IDTYPE=devname IDNAME=/dev/sdc1 DEVNAME=/dev/sdc1 PVID=aWqxcHZzJ70D3rmEQI3b7ch9LkTGHYFw PART=1

probably because the devices don't have any ID:

# sg_vpd --page=di /dev/sda
fetching VPD page failed: Numerical argument out of domain
sg_vpd failed: Numerical argument out of domain

# sg_inq -e /dev/sda
VPD INQUIRY, page code=0x00:
   Supported VPD pages:
     0x0        Supported VPD pages
     0x80       Unit serial number
     0xb1       Block device characteristics (sbc3)
     0xfa

This could be a problem anyway, because in RHEL 9 the /sev/sd* device names started being assigned very unpredictably. Would it be possible to identify disks by their serial number if there is no WWID? These disks have a serial number:

# sg_vpd --page=0x80 /dev/sda
Unit serial number VPD page:
  Unit serial number: 00fac60100004c000000017bead7ca41.72

and it can be seen under /dev/disk/by-id
# ls -l /dev/disk/by-id
lrwxrwxrwx. 1 root root  9 Aug 26 12:22 scsi-SAIX_VDASD_00fac60100004c000000017bead7ca41.72 -> ../../sda
lrwxrwxrwx. 1 root root  9 Aug 26 12:22 scsi-SAIX_VDASD_00fac60100004c000000017bead7ca41.73 -> ../../sdb
lrwxrwxrwx. 1 root root  9 Aug 26 12:22 scsi-SAIX_VDASD_00fac60100004c000000017bead7ca41.74 -> ../../sdc
lrwxrwxrwx. 1 root root  9 Aug 26 12:22 scsi-SAIX_VDASD_00fac60100004c000000017bead7ca41.75 -> ../../sdd

Comment 4 David Teigland 2022-10-14 14:32:43 UTC
(In reply to Pavel Cahyna from comment #3)
> This could be a problem anyway, because in RHEL 9 the /sev/sd* device names
> started being assigned very unpredictably. Would it be possible to identify
> disks by their serial number if there is no WWID? These disks have a serial
> number:
> 
> # sg_vpd --page=0x80 /dev/sda
> Unit serial number VPD page:
>   Unit serial number: 00fac60100004c000000017bead7ca41.72

Yes, and lvm does already attempt to use a serial number by reading /sys/dev/block/major:minor/device/serial.  But, it looks like that sysfs file is not populated with the serial number that sg_vpd found.  Could you check that the /sys/.../serial value is indeed missing or empty for this device?  Also could you check if /sys/dev/block/major:minor/device/vpd_pg80 (or vpd_pg83) files exist?  In RHEL9.1 lvm will begin using vpd_pg83 to get wwids, and it's possible that we could use the vpd_pg80 sysfs file to get a serial number if it's reported there.

Comment 5 Pavel Cahyna 2022-10-17 09:40:19 UTC
There is no /sys/dev/block/major:minor/device/serial (nor vpd_pg83, but I think that this is expected, since the disk does not support page 0x83). There is vpd_pg80, it has binary content:

# od -a /sys/dev/block/8:16/device/vpd_pg80
0000000 nul nul nul   $   0   0   f   a   c   6   0   1   0   0   0   0
0000020   4   c   0   0   0   0   0   0   0   1   7   b   e   a   d   7
0000040   c   a   4   1   .   2   4 nul
0000050

(it is not the same system as I used before, so the serial numbers will differ. The content corresponds somehow to what sg_vpd reports:
# sg_vpd --page=0x80 /dev/sdb
Unit serial number VPD page:
  Unit serial number: 00fac60100004c000000017bead7ca41.24
with the exception of the NUL and $ characters.)

There is also a wwid file, but reading it returns ENXIO.

(This is for /dev/sdb, but the actual PV is on /dev/sdb3, which does not have /sys/dev/block/major:minor/device .)

kernel is 5.14.0-162.6.1.el9_1.ppc64le, lvm2 is lvm2-2.03.16-3.el9.ppc64le.

Comment 6 Pavel Cahyna 2022-10-19 09:22:41 UTC
(In reply to David Teigland from comment #4)

> In RHEL9.1 lvm will begin using vpd_pg83 to get
> wwids, and it's possible that we could use the vpd_pg80 sysfs file to get a
> serial number if it's reported there.

Should I open a separate RFE for that issue?

Comment 7 David Teigland 2022-10-19 17:33:49 UTC
(In reply to Pavel Cahyna from comment #6)
> (In reply to David Teigland from comment #4)
> 
> > In RHEL9.1 lvm will begin using vpd_pg83 to get
> > wwids, and it's possible that we could use the vpd_pg80 sysfs file to get a
> > serial number if it's reported there.
> 
> Should I open a separate RFE for that issue?

yes that would be helpful

Comment 8 David Teigland 2022-10-21 20:02:56 UTC
> > wwids, and it's possible that we could use the vpd_pg80 sysfs file to get a
> > serial number if it's reported there.
> 
> Should I open a separate RFE for that issue?

I ran into this same issue elsewhere and created bug 2136906

Comment 12 Corey Marthaler 2022-11-18 17:16:53 UTC
Marking Verified:Tested in the latest rpms.

kernel-5.14.0-176.el9    BUILT: Wed Oct 12 03:57:18 AM CDT 2022
lvm2-2.03.17-1.el9    BUILT: Thu Nov 10 10:02:16 AM CST 2022
lvm2-libs-2.03.17-1.el9    BUILT: Thu Nov 10 10:02:16 AM CST 2022


SCENARIO - recreation_of_brd_pv_using_uuid_after_device_goes_missing:  Ensure lvm can recreate a brd PV, which uses IDNAME=devname, using uuid once the device is wiped (bug 2119473|2121237) 
Loading block ram disk module

adding entry to the devices file for /dev/ram6
creating PV on hayes-03 using device /dev/ram6
pvcreate --yes -ff   /dev/ram6
  Physical volume "/dev/ram6" successfully created.
PV uuid for /dev/ram6: n3FWpCz2jrYT2cIZx5ye4grIr6zC4aN1
Wiping brd header (wipefs -fa /dev/ram6)
/dev/ram6: 8 bytes were erased at offset 0x00000218 (LVM2_member): 4c 56 4d 32 20 30 30 31
pvcreate -ff --yes -v --uuid n3FWpCz2jrYT2cIZx5ye4grIr6zC4aN1 --norestorefile /dev/ram6
  Physical volume "/dev/ram6" successfully created.

  Devices file PVID n3FWpCz2jrYT2cIZx5ye4grIr6zC4aN1 not found on device /dev/ram6.
  Wiping signatures on new PV /dev/ram6.
  WARNING: adding device /dev/ram6 with PVID n3FWpCz2jrYT2cIZx5ye4grIr6zC4aN1 which is already used for missing device device_id none.
  Set up physical volume for "/dev/ram6" with 32768 available sectors.
  Zeroing start of device /dev/ram6.
  Writing physical volume data to disk "/dev/ram6".

Checking for segfault notification (bug 2119473|2121237)

Re-scanning lvm PVs (pvscan --cache)
  pvscan[61821] PV /dev/ram6 not used.
removing pv /dev/ram6 on hayes-03
  Labels on physical volume "/dev/ram6" successfully wiped.
removing entry from the devices file for /dev/ram6

Unloading block ram disk module

Comment 17 Corey Marthaler 2023-01-12 19:09:40 UTC
Marking VERIFIED in the latest build as well.

kernel-5.14.0-229.el9    BUILT: Thu Jan  5 05:38:37 PM CET 2023
lvm2-2.03.17-4.el9    BUILT: Tue Jan 10 06:40:12 PM CET 2023
lvm2-libs-2.03.17-4.el9    BUILT: Tue Jan 10 06:40:12 PM CET 2023


SCENARIO - recreation_of_brd_pv_using_uuid_after_device_goes_missing:  Ensure lvm can recreate a brd PV, which uses IDNAME=devname, using uuid once the device is wiped (bug 2119473|2121237) 
Loading block ram disk module

adding entry to the devices file for /dev/ram6
creating PV on virt-540.cluster-qe.lab.eng.brq.redhat.com using device /dev/ram6
pvcreate --yes -ff   /dev/ram6
  Physical volume "/dev/ram6" successfully created.
PV uuid for /dev/ram6: HBQVUslCL6vP2OIdTtDtUOvFaHrH4ZDi
Wiping brd header (wipefs -fa /dev/ram6)
/dev/ram6: 8 bytes were erased at offset 0x00000218 (LVM2_member): 4c 56 4d 32 20 30 30 31
pvcreate -ff --yes -v --uuid HBQVUslCL6vP2OIdTtDtUOvFaHrH4ZDi --norestorefile /dev/ram6
  Physical volume "/dev/ram6" successfully created.

  Devices file PVID HBQVUslCL6vP2OIdTtDtUOvFaHrH4ZDi not found on device /dev/ram6.
  Wiping signatures on new PV /dev/ram6.
  WARNING: adding device /dev/ram6 with PVID HBQVUslCL6vP2OIdTtDtUOvFaHrH4ZDi which is already used for missing device device_id none.
  Set up physical volume for "/dev/ram6" with 32768 available sectors.
  Zeroing start of device /dev/ram6.
  Writing physical volume data to disk "/dev/ram6".

Checking for segfault notification (bug 2119473|2121237)

Re-scanning lvm PVs (pvscan --cache)
  pvscan[40948] PV /dev/ram6 not used.
removing pv /dev/ram6 on virt-540.cluster-qe.lab.eng.brq.redhat.com
  Labels on physical volume "/dev/ram6" successfully wiped.
removing entry from the devices file for /dev/ram6

Unloading block ram disk module

Comment 19 errata-xmlrpc 2023-05-09 08:23:45 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-2023:2544