Bug 1241774 - blkid doesn't output PART_ENTRY_DISK for a partition on the dm device with sun label
Summary: blkid doesn't output PART_ENTRY_DISK for a partition on the dm device with su...
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: device-mapper-multipath   
(Show other bugs)
Version: 7.1
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Ben Marzinski
QA Contact: Lin Li
Steven J. Levine
URL:
Whiteboard:
Keywords:
Depends On:
Blocks: 1203710 1313485 1251250 1295577 1299589
TreeView+ depends on / blocked
 
Reported: 2015-07-10 05:35 UTC by Masahiro Matsuya
Modified: 2016-11-04 08:12 UTC (History)
6 users (show)

Fixed In Version: device-mapper-multipath-0.4.9-87.el7
Doc Type: Bug Fix
Doc Text:
The `kpartx` generated devices now have the same partition number as the actual partition number Previously, the `kpartx` generated device partition number did not match with the actual partition number. This was because `kpartx` was not counting sun partitions with no sectors when determining the partition number. With this fix, `kpartx` now counts sun partitions with no sectors when determining the partition number and the `kpartx` generated devices now have the same partition number as the actual partition number.
Story Points: ---
Clone Of:
: 1251250 1299589 (view as bug list)
Environment:
Last Closed: 2016-11-04 08:12:34 UTC
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:2536 normal SHIPPED_LIVE device-mapper-multipath bug fix and enhancement update 2016-11-03 14:18:10 UTC

Description Masahiro Matsuya 2015-07-10 05:35:35 UTC
Description of problem:

A customer tried to clear a partition on a multipath device with sun label during installation. But, it failed before clearing the partition with the following traceback.

anaconda 19.31.123-1 exception report
Traceback (most recent call first):
  File "/usr/lib/python2.7/site-packages/blivet/udev.py", line 587, in device_get_dm_partition_disk
    majorminor = info["ID_PART_ENTRY_DISK"]
  File "/usr/lib/python2.7/site-packages/blivet/devicetree.py", line 764, in addUdevDMDevice
    diskname = udev.device_get_dm_partition_disk(info)
  File "/usr/lib/python2.7/site-packages/blivet/devicetree.py", line 1205, in addUdevDevice
    device = self.addUdevDMDevice(info)
  File "/usr/lib/python2.7/site-packages/blivet/devicetree.py", line 2196, in _populate
    self.addUdevDevice(dev)
  File "/usr/lib/python2.7/site-packages/blivet/devicetree.py", line 2131, in populate
    self._populate()
  File "/usr/lib/python2.7/site-packages/blivet/__init__.py", line 483, in reset
    self.devicetree.populate(cleanupOnly=cleanupOnly)
  File "/usr/lib/python2.7/site-packages/blivet/__init__.py", line 186, in storageInitialize
    storage.reset()
  File "/usr/lib64/python2.7/threading.py", line 764, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/usr/lib64/python2.7/site-packages/pyanaconda/threads.py", line 211, in run
    threading.Thread.run(self, *args, **kwargs)
KeyError: 'ID_PART_ENTRY_DISK'

Local variables in innermost frame:
info: {'symlinks': ['/dev/disk/by-id/dm-name-mpatha1', '/dev/disk/by-id/dm-uuid-part1-mpath-360060160d910200044de8e52b014e511', '/dev/mapper/mpatha1'], 'DEVLINKS': '/dev/disk/by-id/dm-name-mpatha1 /dev/disk/by-id/dm-uuid-part1-mpath-360060160d910200044de8e52b014e511 /dev/mapper/mpatha1', 'DM_NAME': 'mpatha1', 'MAJOR': '253', 'DEVPATH': '/devices/virtual/block/dm-1', 'sysfs_path': '/devices/virtual/block/dm-1', 'DEVNAME': 'dm-1', 'DM_UUID': 'part1-mpath-360060160d910200044de8e52b014e511', 'TAGS': ':systemd:', 'DM_SUSPENDED': '0', 'DEVTYPE': 'disk', 'DM_UDEV_PRIMARY_SOURCE_FLAG': '1', 'SUBSYSTEM': 'block', 'USEC_INITIALIZED': '335503', 'DM_MULTIPATH_TIMESTAMP': '1432657663', 'ID_PART_TABLE_TYPE': 'sun', 'DM_UDEV_RULES_VSN': '2', 'DM_UDEV_DISABLE_LIBRARY_FALLBACK_FLAG': '1', 'MPATH_SBIN_PATH': '/sbin', 'MINOR': '1', 'name': 'dm-1'}
disk: None


This means that blkid library didn't return ID_PART_ENTRY_DISK's value for this partition. This can be reproduced with blkid command.

The following partitions are on the multipath device.


# fdisk -l /dev/mapper/mpatha

Disk /dev/mapper/mpatha (Sun disk label): 255 heads, 63 sectors, 1044 cylinders
Units = sectors of 1 * 512 bytes

             Device Flag    Start       End    Blocks   Id  System
/dev/mapper/mpatha2             0   1000000    500000   83  Linux native
/dev/mapper/mpatha3             0  16771860   8385930    5  Whole disk
/dev/mapper/mpatha8       1012095  16771860   7879882+   f  unknown

# parted /dev/mapper/mpatha
(parted) print
Model: Linux device-mapper (multipath) (dm)
Disk /dev/mapper/mpatha: 16777216s
Sector size (logical/physical): 512B/512B
Partition Table: sun
Disk Flags: 

Number  Start     End        Size       File system  Flags
 2      0s        999999s    1000000s
 8      1012095s  16771859s  15759765s

NOTE: The partition 3 is always a whole disk in sun label device, it's not output here.


# ls -l /dev/mapper/mpatha*
lrwxrwxrwx. 1 root root 7 Jul 10 14:13 /dev/mapper/mpatha -> ../dm-2
lrwxrwxrwx. 1 root root 7 Jul 10 12:34 /dev/mapper/mpatha1 -> ../dm-3
lrwxrwxrwx. 1 root root 7 Jul 10 12:34 /dev/mapper/mpatha3 -> ../dm-4


According to the size (blocks) in /proc/partitions, the partition 2 is dm-3, and the partition 8 is dm-4.

# cat /proc/partitions 
major minor  #blocks  name
...snip...
 253        3     500000 dm-3
 253        4    7879882 dm-4

So, the partition 2 is /dev/mapper/mpatha1, and the partition 8 is /dev/mapper/mpatha3.

The following blkid command doesn't output the value of ID_PART_ENTRY_DISK.
# blkid -po udev /dev/mapper/mpatha1
ID_PART_TABLE_TYPE=sun
# blkid -po udev /dev/mapper/mpatha3
# 


It seems that it failed to find a partition in blkid_partlist_devno_to_partition().

static int blkid_partitions_probe_partition(blkid_probe pr)
{
...
        par = blkid_partlist_devno_to_partition(ls, devno);
        if (par) {


(gdb) print *ls
$2 = {next_partno = 9, next_parent = 0x0, nparts = 2, nparts_max = 32, parts = 0x61f830, l_tabs = {next = 0x61f818, 
    prev = 0x61f818}}

(gdb) print ls->parts[0]
$3 = {start = 0, size = 1000000, type = 131, typestr = '\000' <repeats 36 times>, flags = 0, partno = 2, 
  uuid = '\000' <repeats 36 times>, name = '\000' <repeats 127 times>, tab = 0x61f7d0}

   ===> partno = 2

(gdb) print ls->parts[1]
$4 = {start = 1012095, size = 15759765, type = 15, typestr = '\000' <repeats 36 times>, flags = 0, partno = 8, 
  uuid = '\000' <repeats 36 times>, name = '\000' <repeats 127 times>, tab = 0x61f7d0}

   ===> partno = 8


But, the partition number found in uuid is not 2 nor 8, but 1.

(gdb) print uuid
$7 = 0x61f320 "part1"

So, there is no matched partitios in ls->parts[]. But correctly, ls->parts[0] should be selected in blkid_partlist_devno_to_partition().


Version-Release number of selected component (if applicable):
Red Hat Enterprise Linux 7.1

How reproducible:
Always

Steps to Reproduce:
1. prepare RHEL7.1 machine with a multipath device
2. set sun label into the multipath device, and create two partitions (2 and 8)
3. run blkid command.
   # blkid -po udev /dev/mapper/mpatha1

Actual results:
It doesn't output the value of ID_PART_ENTRY_DISK, meaning that the major and minor number of the parent device (/dev/mapper/mpatha).

Expected results:
It outputs the value of ID_PART_ENTRY_DISK

Comment 1 Masahiro Matsuya 2015-07-10 09:05:20 UTC
After some investigation, I found kpartx (from device-mapper-multipath) set the uuid in read_sun_pt() in kpartx/sun.c. It read some blocks in the multipath device and get the 8 partition information.

$9 = {
{start_cylinder = 0, num_sectors = 0},
{start_cylinder = 0, num_sectors = 1078071040},
{start_cylinder = 0, num_sectors = 351010560},
{start_cylinder = 0, num_sectors = 0}, 
{start_cylinder = 0, num_sectors = 0}, 
{start_cylinder = 0, num_sectors = 0}, 
{start_cylinder = 0, num_sectors = 0}, 
{start_cylinder = 1056964608, num_sectors = 2507796480}}

The partitions with num_sectors = 0 are skipped, and get the following partition list including the 3 partitions.

(gdb) print slices[0]
$16 = {start = 0, size = 1000000, major = 0, minor = 0}
(gdb) print slices[1]
$17 = {start = 0, size = 16771860, major = 0, minor = 0}
(gdb) print slices[2]
$18 = {start = 1012095, size = 15759765, major = 0, minor = 0}

slices[0] is the partition 2 in the disk with the sun label.
slices[1] is the whole disk.
slices[2] is the partition 8 in the disk with the sun label.

slices[1] is ignored since it's overlapped with slices[2].

kpartx uses the index of slices[] array for the partition number in uuid. Precisely, it's index+1. 

For the partition 2, part1-xxx
For the partition 8, part3-xxx

So, the partition number in uuid doesn't match the partition number (2 and 8) in the disk with sun label.

I was not sure which component it's fixed in. util-linux or device-mapper-multipath. If it's fixed in device-mapper-multipath, the patch should be like this.

diff -up multipath-tools-130222/kpartx/sun.c.original multipath-tools-130222/kpartx/sun.c
--- multipath-tools-130222/kpartx/sun.c.original        2015-07-10 17:32:47.763111142 +0900
+++ multipath-tools-130222/kpartx/sun.c 2015-07-10 17:33:27.363111142 +0900
@@ -82,8 +82,6 @@ read_sun_pt(int fd, struct slice all, st
        for(i=0, n=0; i<SUN_DISK_MAXPARTITIONS; i++) {
                s = &l->partitions[i];
 
-               if (s->num_sectors == 0)
-                       continue;
                if (n < ns) {
                        sp[n].start = offset +
                                be32_to_cpu(s->start_cylinder) * be16_to_cpu(l->nsect) * be16_to_cpu(l->ntrks);


I'll change the component into device-mapper-multipath.

Comment 3 Ben Marzinski 2015-08-06 19:43:21 UTC
I've fixed the issue where kpartx is not correctly naming the partition device.  However, as you mentioned in Comment 2, this appears to be unrelated to the blkid issue.  Specifically, the blkid issue occurs exactly the same on a regular scsi device, without multipath being involved at all.

Comment 6 Ben Marzinski 2016-02-26 20:36:48 UTC
kpartx now correctly counts the zero sector sized partitions when determining that partition number, and names the partition devices correctly.

Comment 13 Lin Li 2016-07-16 13:49:36 UTC
Reproduced on device-mapper-multipath-0.4.9-77.el7
1. # rpm -qa | grep multipath
device-mapper-multipath-0.4.9-77.el7.x86_64
device-mapper-multipath-libs-0.4.9-77.el7.x86_64

2.# multipath -ll
mpatha (360fff19abdd9552f8a36e5355226ba27) dm-0 EQLOGIC ,100E-00         
size=50G features='0' hwhandler='0' wp=rw
|-+- policy='service-time 0' prio=1 status=active
| `- 3:0:0:0 sdb 8:16 active ready running
`-+- policy='service-time 0' prio=1 status=enabled
  `- 4:0:0:0 sdc 8:32 active ready running

3.# fdisk -l /dev/mapper/mpatha

Disk /dev/mapper/mpatha (Sun disk label): 64 heads, 32 sectors, 51210 cylinders
Units = sectors of 1 * 512 bytes

             Device Flag    Start       End    Blocks   Id  System
/dev/mapper/mpatha2  u  104775680 104878080     51200   82  Linux swap
/dev/mapper/mpatha3             0 104878080  52439040    5  Whole disk
/dev/mapper/mpatha8         45056    345666    150305   83  Linux native

4.# parted /dev/mapper/mpatha
GNU Parted 3.1
Using /dev/mapper/mpatha
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print                                                            
Model: Linux device-mapper (multipath) (dm)
Disk /dev/mapper/mpatha: 53.7GB
Sector size (logical/physical): 512B/512B
Partition Table: sun
Disk Flags: 

Number  Start   End     Size    File system  Flags
 8      23.1MB  177MB   154MB
 2      53.6GB  53.7GB  52.4MB

5.# ls -l /dev/mapper/mpatha*
lrwxrwxrwx. 1 root root 7 Jul 16 15:14 /dev/mapper/mpatha -> ../dm-0
lrwxrwxrwx. 1 root root 7 Jul 16  2016 /dev/mapper/mpatha1 -> ../dm-1
lrwxrwxrwx. 1 root root 7 Jul 16  2016 /dev/mapper/mpatha2 -> ../dm-2

6.# blkid -po udev /dev/mapper/mpatha1
ID_FS_UUID=dc3cae86-81ea-406e-9207-05a857264a0c
ID_FS_UUID_ENC=dc3cae86-81ea-406e-9207-05a857264a0c
ID_FS_TYPE=xfs
ID_FS_USAGE=filesystem

7.# blkid -po udev /dev/mapper/mpatha2
ID_FS_UUID=AiQMMf-nFYA-Kita-GweC-NuPx-ScQl-i3WOHl
ID_FS_UUID_ENC=AiQMMf-nFYA-Kita-GweC-NuPx-ScQl-i3WOHl
ID_FS_VERSION=LVM2\x20001
ID_FS_TYPE=LVM2_member
ID_FS_USAGE=raid



Verified on device-mapper-multipath-0.4.9-93.el7
1. # rpm -qa | grep multipath 
device-mapper-multipath-libs-0.4.9-93.el7.x86_64
device-mapper-multipath-0.4.9-93.el7.x86_64
device-mapper-multipath-sysvinit-0.4.9-93.el7.x86_64
device-mapper-multipath-debuginfo-0.4.9-93.el7.x86_64

2.# multipath -ll
mpatha (36001405848565fc8934460cac7148f3d) dm-0 LIO-ORG ,st72-io         
size=10G features='0' hwhandler='0' wp=rw
|-+- policy='service-time 0' prio=1 status=active
| `- 3:0:0:0  sdb 8:16 active ready running
`-+- policy='service-time 0' prio=1 status=enabled
  `- 4:0:0:0  sdc 8:32 active ready running

3.# fdisk -l /dev/mapper/mpatha

Disk /dev/mapper/mpatha (Sun disk label): 64 heads, 32 sectors, 10240 cylinders
Units = sectors of 1 * 512 bytes

             Device Flag    Start       End    Blocks   Id  System
/dev/mapper/mpatha2  u   20869120  20971520     51200   82  Linux swap
/dev/mapper/mpatha3             0  20971520  10485760    5  Whole disk
/dev/mapper/mpatha8        346112    435678     44783   83  Linux native

4.# parted /dev/mapper/mpatha
GNU Parted 3.1
Using /dev/mapper/mpatha
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print                                                            
Model: Linux device-mapper (multipath) (dm)
Disk /dev/mapper/mpatha: 10.7GB
Sector size (logical/physical): 512B/512B
Partition Table: sun
Disk Flags: 

Number  Start   End     Size    File system  Flags
 8      177MB   223MB   45.9MB
 2      10.7GB  10.7GB  52.4MB

5.# ls -l /dev/mapper/mpatha*
lrwxrwxrwx. 1 root root 7 Jul 16 15:34 /dev/mapper/mpatha -> ../dm-0
lrwxrwxrwx. 1 root root 7 Jul 16 12:00 /dev/mapper/mpatha1 -> ../dm-1
lrwxrwxrwx. 1 root root 7 Jul 16 15:34 /dev/mapper/mpatha2 -> ../dm-6
lrwxrwxrwx. 1 root root 7 Jul 16 12:00 /dev/mapper/mpatha3 -> ../dm-7
lrwxrwxrwx. 1 root root 8 Jul 16 15:34 /dev/mapper/mpatha8 -> ../dm-10

 the partition 2 is /dev/mapper/mpatha2, and the partition 8 is /dev/mapper/mpatha8.

6.# # blkid -po udev /dev/mapper/mpatha2
ID_PART_ENTRY_SCHEME=sun
ID_PART_ENTRY_TYPE=0x82
ID_PART_ENTRY_FLAGS=0x1
ID_PART_ENTRY_NUMBER=2
ID_PART_ENTRY_OFFSET=20869120
ID_PART_ENTRY_SIZE=102400
ID_PART_ENTRY_DISK=253:0

7.# blkid -po udev /dev/mapper/mpatha8
ID_PART_ENTRY_SCHEME=sun
ID_PART_ENTRY_TYPE=0x83
ID_PART_ENTRY_NUMBER=8
ID_PART_ENTRY_OFFSET=346112
ID_PART_ENTRY_SIZE=89566
ID_PART_ENTRY_DISK=253:0


Test result: the kpartx generated devices have the same partition number as the actual partition number

Comment 15 errata-xmlrpc 2016-11-04 08:12:34 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, 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-2536.html


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