Bug 1300964 - Partitions are not correctly recognized in LVM2 when using devices/external_device_info_source="udev"
Partitions are not correctly recognized in LVM2 when using devices/external_d...
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: lvm2 (Show other bugs)
6.8
All Linux
unspecified Severity medium
: rc
: ---
Assigned To: Peter Rajnoha
cluster-qe@redhat.com
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2016-01-22 03:50 EST by Peter Rajnoha
Modified: 2016-05-10 21:20 EDT (History)
10 users (show)

See Also:
Fixed In Version: lvm2-2.02.141-1.el6
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-05-10 21:20:29 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2016:0964 normal SHIPPED_LIVE lvm2 bug fix and enhancement update 2016-05-10 18:57:40 EDT

  None (edit)
Description Peter Rajnoha 2016-01-22 03:50:38 EST
Currently, when devices/external_device_info_souce="udev" is configured, lvm2 uses udev database records to make a decision whether a disk contains partition table. Such disk is filtered out. LVM2 uses two variables coming from blkid scan within udev to decide on this:

  - ID_PART_TABLE_TYPE="<partition_table_type>"
  - ID_PART_ENTRY_DISK="major:minor"

The ID_PART_TABLE_TYPE is set for both whole disks as well as partitions while the ID_PART_ENTRY_DISK is set only for partitions (the major:minor is the major:minor of whole disk for this partition).

The filter looks whether ID_PART_TABLE_TYPE is the only one set and if yes, such device is filtered in lvm2 as we should prefere partitions over whole device.

The bug here is that the ID_PART_ENTRY_DISK blkid variable was introduce in addition later in util-linux v2.19. The version used in (current) RHEL6.7/RHEL6.8 is still v2.17.

This means the ID_PART_TABLE_TYPE is set for both whole device and partitions, but there's no ID_PART_ENTRY_DISK to see a difference between these two. We need to use some other variable that is available, if at all, to decide on this.

We can't make a difference by looking at the DEVTYPE variable only which is set to "disk" for whole device and "partition" for partitions, because device abstractions like DM (and MD possibly) have DEVTYPE variable set to "disk" all the time, no matter if it's whole device or partition (from pure device point of view, it's true, because partition on a DM device is just another DM device stacked on top of the other one from kernel point of view.

Fix this "partition check" by carefully selecting best set of variables which are available in udev db to make proper decision about whole devices and their partitions, even for device abstractions like DM.

If there's no such reliable set of variable in udev db to make this decision, switch the code to using it's own original scan instead (check for libbblkid version etc.).
Comment 2 Peter Rajnoha 2016-01-22 03:55:42 EST
Note: the devices/external_device_info_souce="udev" is not used by default. But we should still fix this as it can cause incorrect devices to be filtered out when someone switches to this device info source.
Comment 3 Peter Rajnoha 2016-02-02 07:44:31 EST
Fixed by this patch:

https://git.fedorahosted.org/cgit/lvm2.git/commit/?id=ec43f55445966b5075fa8083921d182a0a138326

For example:

[root@rhel6-a ~]# lvmconfig devices/external_device_info_source
external_device_info_source="udev"

[root@rhel6-a ~]# lsblk
NAME                        MAJ:MIN RM  SIZE RO TYPE  MOUNTPOINT
vda                         252:0    0   10G  0 disk  
|-vda1                      252:1    0  500M  0 part  /boot
`-vda2                      252:2    0  9.5G  0 part  
  |-VolGroup-lv_root (dm-0) 253:0    0  7.6G  0 lvm   /
  `-VolGroup-lv_swap (dm-1) 253:1    0    2G  0 lvm   [SWAP]
sda                           8:0    0    4G  0 disk  
`-sda1                        8:1    0    4G  0 part  
sdb                           8:16   0    4G  0 disk  
`-test (dm-3)               253:3    0   32M  0 dm    
  `-test1 (dm-4)            253:4    0 31.4M  0 part  
sdd                           8:48   0    4G  0 disk  
`-md127                       9:127  0    4G  0 raid1 
  `-md127p1                 259:0    0    4G  0 md    
sdc                           8:32   0    4G  0 disk  
`-md127                       9:127  0    4G  0 raid1 
  `-md127p1                 259:0    0    4G  0 md    
sde                           8:64   0    4G  0 disk 

Without this patch:

[root@rhel6-a ~]# pvs -vvvv &> log

[root@rhel6-a ~]# grep "Skipping: Partition table signature found" log
#filters/filter-partitioned.c:30         /dev/sda: Skipping: Partition table signature found [udev:0x7f2fcc806930]
#filters/filter-partitioned.c:30         /dev/vda: Skipping: Partition table signature found [udev:0x7f2fcc806930]
#filters/filter-partitioned.c:30         /dev/sda1: Skipping: Partition table signature found [udev:0x7f2fcba6f810]
#filters/filter-partitioned.c:30         /dev/vda1: Skipping: Partition table signature found [udev:0x7f2fcba6f810]
#filters/filter-partitioned.c:30         /dev/vda2: Skipping: Partition table signature found [udev:0x7f2fcc803500]
#filters/filter-partitioned.c:30         /dev/mapper/test: Skipping: Partition table signature found [udev:0x7f2fcc7fb190]
#filters/filter-partitioned.c:30         /dev/md127: Skipping: Partition table signature found [udev:0x7f2fcc805130]
#filters/filter-partitioned.c:30         /dev/mapper/test: Skipping: Partition table signature found [udev:0x7f2fcc805190]

With this patch applied:

[root@rhel6-a ~]# pvs -vvvv &> log

[root@rhel6-a ~]# grep "Skipping: Partition table signature found" log
#filters/filter-partitioned.c:30         /dev/sda: Skipping: Partition table signature found [udev:0x7f37342ef3b0]
#filters/filter-partitioned.c:30         /dev/vda: Skipping: Partition table signature found [udev:0x7f37342ef3b0]
#filters/filter-partitioned.c:30         /dev/mapper/test: Skipping: Partition table signature found [udev:0x7f373354e610]
#filters/filter-partitioned.c:30         /dev/md127: Skipping: Partition table signature found [udev:0x7f373354e640]
#filters/filter-partitioned.c:30         /dev/mapper/test: Skipping: Partition table signature found [udev:0x7f37342f16a0]


So the difference is that partitions are *not* filtered now. Only whole devices with partition tables on them should be filtered.
Comment 6 Roman Bednář 2016-02-29 07:06:31 EST
Verified. Partitions are no longer filtered when 'external_device_info_souce="udev"' is used.

# lvmconfig devices/external_device_info_source
external_device_info_source="udev"

# lsblk
NAME                          MAJ:MIN RM  SIZE RO TYPE  MOUNTPOINT
vda                           252:0    0  8.2G  0 disk  
├─vda1                        252:1    0  500M  0 part  /boot
└─vda2                        252:2    0  7.7G  0 part  
  ├─vg_virt274-lv_root (dm-0) 253:0    0  6.9G  0 lvm   /
  └─vg_virt274-lv_swap (dm-1) 253:1    0  840M  0 lvm   [SWAP]
sdb                             8:16   0   10G  0 disk  
└─md0                           9:0    0   10G  0 raid1 
  └─md0p1                     259:0    0   10G  0 md    
sda                             8:0    0   10G  0 disk  
sdc                             8:32   0   10G  0 disk  
└─md0                           9:0    0   10G  0 raid1 
  └─md0p1                     259:0    0   10G  0 md 
   
# pvs -vvvv &> log

# grep "Skipping: Partition table signature found" log
#filters/filter-partitioned.c:27         /dev/md0: Skipping: Partition table signature found
#filters/filter-partitioned.c:27         /dev/vda: Skipping: Partition table signature found


Tested on:
2.6.32-616.el6.x86_64

lvm2-2.02.141-2.el6    BUILT: Wed Feb 10 14:49:03 CET 2016
lvm2-libs-2.02.141-2.el6    BUILT: Wed Feb 10 14:49:03 CET 2016
lvm2-cluster-2.02.141-2.el6    BUILT: Wed Feb 10 14:49:03 CET 2016
udev-147-2.71.el6    BUILT: Wed Feb 10 14:07:17 CET 2016
device-mapper-1.02.115-2.el6    BUILT: Wed Feb 10 14:49:03 CET 2016
device-mapper-libs-1.02.115-2.el6    BUILT: Wed Feb 10 14:49:03 CET 2016
device-mapper-event-1.02.115-2.el6    BUILT: Wed Feb 10 14:49:03 CET 2016
device-mapper-event-libs-1.02.115-2.el6    BUILT: Wed Feb 10 14:49:03 CET 2016
device-mapper-persistent-data-0.6.2-0.1.rc1.el6    BUILT: Wed Feb 10 16:52:15 CET 2016
cmirror-2.02.141-2.el6    BUILT: Wed Feb 10 14:49:03 CET 2016
Comment 8 errata-xmlrpc 2016-05-10 21:20:29 EDT
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, 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://rhn.redhat.com/errata/RHBA-2016-0964.html

Note You need to log in before you can comment on or make changes to this bug.