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 2138459

Summary: lvmdevices can end up thinking a base device is partitioned after the mpath device on top was; ("WARNING: devices file is missing ... using multipath component /dev/sda.")
Product: Red Hat Enterprise Linux 9 Reporter: Corey Marthaler <cmarthal>
Component: lvm2Assignee: LVM and device-mapper development team <lvm-team>
lvm2 sub component: Devices, Filtering and Stacking QA Contact: cluster-qe <cluster-qe>
Status: CLOSED DUPLICATE Docs Contact:
Severity: low    
Priority: unspecified CC: agk, heinzm, jbrassow, msnitzer, prajnoha, teigland, zkabelac
Version: 9.1Flags: pm-rhel: mirror+
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-03-08 18:13:22 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 Corey Marthaler 2022-10-28 22:47:59 UTC
Description of problem:

# This device is not partitioned
[root@virt-529 ~]# pvcreate /dev/sda
  Physical volume "/dev/sda" successfully created.
[root@virt-529 ~]# pvremove /dev/sda
  Labels on physical volume "/dev/sda" successfully wiped.

# Use it to create a mpath device
[root@virt-529 ~]# multipath /dev/sda
671.221351 | mpatha: addmap [0 62914560 multipath 0 1 alua 1 1 service-time 0 1 1 8:0 1]
create: mpatha (36001405f75d70b72da84a83b3cac425a) undef LIO-ORG,cluster135057-d
size=30G features='0' hwhandler='1 alua' wp=undef
`-+- policy='service-time 0' prio=50 status=undef
  `- 6:0:0:0 sda 8:0 undef ready running

# Partition that mpath device
[root@virt-529 ~]# /usr/tests/sts-rhel9.2/bin/dice -p 1  -d /dev/mapper/mpatha
Using gpt label
Disk size: 30719 MB
Num partitions: 1
Adding new primary partition: (40, 62914519) = 30719 MB
Committing changes

# A pvcreate of /dev/mapper/mpatha (on top of /dev/sda) will properly warn that the mpatha IS partitioned

# pvcreate mpatha1 instead
[root@virt-529 ~]# pvcreate --yes /dev/mapper/mpatha1
  WARNING: devices file is missing /dev/mapper/mpatha (253:2) using multipath component /dev/sda.
  See lvmdevices --update for devices file update.
  Physical volume "/dev/mapper/mpatha1" successfully created.
[root@virt-529 ~]# echo $?
0

[root@virt-529 ~]# dmsetup ls
mpatha  (253:2)
mpatha1 (253:3)

# The underling sda device appears to remain NON partitioned
[root@virt-529 ~]# cat /proc/partitions | grep sda
   8        0   31457280 sda

[root@virt-529 ~]# pvremove /dev/mapper/mpatha1
  WARNING: devices file is missing /dev/mapper/mpatha (253:2) using multipath component /dev/sda.
  See lvmdevices --update for devices file update.
  Labels on physical volume "/dev/mapper/mpatha1" successfully wiped.

[root@virt-529 ~]# multipath -ff mpatha
[root@virt-529 ~]# multipath -W
successfully reset wwids

[root@virt-529 ~]# cat /etc/lvm/devices/system.devices 
# LVM uses devices listed in this file.
# Created by LVM command pvremove pid 4093 at Sat Oct 29 00:25:36 2022
VERSION=1.1.732
IDTYPE=sys_wwid IDNAME=naa.6001405f75d70b72da84a83b3cac425a DEVNAME=/dev/sda PVID=.
IDTYPE=mpath_uuid IDNAME=part1-mpath-36001405f75d70b72da84a83b3cac425a DEVNAME=/dev/mapper/mpatha1 PVID=.

[root@virt-529 ~]# lvmdevices --deldev /dev/mapper/mpatha1
  Devices file mpath_uuid part1-mpath-36001405f75d70b72da84a83b3cac425a PVID none last seen on /dev/mapper/mpatha1 not found.
[root@virt-529 ~]# lvmdevices --deldev /dev/sda


# Now there's no way to use the non partitioned base device now that the mpath volume was deleted

[root@virt-529 ~]#  cat /proc/partitions | grep sda
   8        0   31457280 sda
[root@virt-529 ~]# pvcreate /dev/sda
  Cannot use /dev/sda: device is partitioned
[root@virt-529 ~]# pvcreate -ff /dev/sda
  Cannot use /dev/sda: device is partitioned

# Where is LVM getting the partitioned state from? Maybe it is actually partitioned?


Version-Release number of selected component (if applicable):
kernel-5.14.0-170.kpq1.el9    BUILT: Fri Sep 30 12:48:45 PM CEST 2022
lvm2-2.03.17-0.1.20221014git04097d9.el9.test    BUILT: Fri Oct 14 08:40:16 PM CEST 2022
lvm2-libs-2.03.17-0.1.20221014git04097d9.el9.test    BUILT: Fri Oct 14 08:40:16 PM CEST 2022


How reproducible:
Everytime

Comment 1 Corey Marthaler 2022-10-28 23:20:38 UTC
This test case was for bug 2052064.

This same behavior occurs on rhel8.7 as well.
kernel-4.18.0-425.el8    BUILT: Fri Sep  9 11:51:56 CDT 2022
lvm2-2.03.14-6.el8    BUILT: Fri Jul 29 05:40:53 CDT 2022
lvm2-libs-2.03.14-6.el8    BUILT: Fri Jul 29 05:40:53 CDT 2022


SCENARIO - partitioned_mpath_device_PV:  Check for 'excluded: device is partitioned' message when creating a PV from a partitioned mpath device already existing in the devicesfile (bug 2052064) 
Copying out blanked system.devices file to begin with
/tmp/system858.devices -> hayes-01:/etc/lvm/devices/system.devices
multipath /dev/sde
create: mpathc (36d094660575ece002291bade2acdbd28) undef DELL,PERC H330 Adp
size=1.8T features='0' hwhandler='0' wp=undef
`-+- policy='service-time 0' prio=1 status=undef
  `- 0:2:4:0  sde 8:64  undef ready running

setting mpath base to:mpathc
adding entry to the devices file for /dev/mapper/mpathc
Using gpt label
Disk size: 1907199 MB
Num partitions: 1
Adding new primary partition: (40, 3905945559) = 1907199 MB
Committing changes
adding entry to the devices file for /dev/mapper/mpathc1
  Physical volume "/dev/mapper/mpathc1" successfully created.

  Devices file /dev/mapper/mpathc is excluded: device is partitioned.
  WARNING: D-Bus notification failed: Connection timed out

  Devices file /dev/mapper/mpathc is excluded: device is partitioned.
  Labels on physical volume "/dev/mapper/mpathc1" successfully wiped.
removing entry from the devices file for /dev/mapper/mpathc1
WARNING: Heartbeat did not respond at start of command.  Check btimed service on remote host
removing entry from the devices file for /dev/mapper/mpathc
multipath -f mpathc
multipath -W
successfully reset wwids
adding entry to the devices file for /dev/sde
creating PV on hayes-01 using device /dev/sde
pvcreate --yes -ff  --zero y /dev/sde
  Devices file /dev/sde is excluded: device is partitioned.
  Cannot use /dev/sde: device is partitioned
Traceback (most recent call last):

Comment 2 David Teigland 2022-11-08 20:50:56 UTC
> [root@virt-529 ~]# pvcreate /dev/sda
>  Cannot use /dev/sda: device is partitioned

I see the same thing.  If you run wipefs on the device at this point, it will show the partition info, here's what I see:

$ wipefs /dev/sdf
DEVICE OFFSET       TYPE UUID LABEL
sdf    0x200        gpt       
sdf    0xe8c0bffe00 gpt       
sdf    0x1fe        PMBR      

and if you run wipefs -a /dev/sdf it will erase it all and then pvcreate will work.

$ wipefs -a /dev/sdf
/dev/sdf: 8 bytes were erased at offset 0x00000200 (gpt): 45 46 49 20 50 41 52 54
/dev/sdf: 8 bytes were erased at offset 0xe8c0bffe00 (gpt): 45 46 49 20 50 41 52 54
/dev/sdf: 2 bytes were erased at offset 0x000001fe (PMBR): 55 aa
/dev/sdf: calling ioctl to re-read partition table: Success
$ pvcreate /dev/sdf
  Physical volume "/dev/sdf" successfully created.

In the original sequence above, there is no step to erase the partitions from the dice command, which could be added for a symmetrical setup/teardown.
However, pvcreate -f has traditionally been able to erase partition data if you haven't already.  GPT partitions is a case where that doesn't work, as reported in bug 1977734 which this should probably be a dup of.

Comment 3 David Teigland 2023-03-08 18:13:22 UTC

*** This bug has been marked as a duplicate of bug 1977734 ***