Bug 1549498

Summary: Infinite loop in case of LV and PV have the same name
Product: Red Hat Enterprise Linux 7 Reporter: Welterlen Benoit <bwelterl>
Component: dracutAssignee: Lukáš Nykrýn <lnykryn>
Status: CLOSED ERRATA QA Contact: Release Test Team <release-test-team-automation>
Severity: urgent Docs Contact:
Priority: urgent    
Version: 7.4CC: bwelterl, dracut-maint-list, fkrska, harald, jstodola, pchavan, pkotvan
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: dracut-033-546.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-10-30 11:26:36 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: 1546815, 1549617, 1551061    

Description Welterlen Benoit 2018-02-27 09:40:41 UTC
Description of problem:
With LVM, if a LV has the same name than the PV, an infinite loop occurs in check_vol_slaves_all : 
dracut-functions.sh :
check_vol_slaves_all() {
    local _lv _vg _pv
    for i in /dev/mapper/*; do
        [[ $i == /dev/mapper/control ]] && continue
        _lv=$(get_maj_min $i)
        if [[ $_lv = $2 ]]; then
>>>>>            _vg=$(lvm lvs --noheadings -o vg_name $i 2>/dev/null)
            # strip space
            _vg="${_vg//[[:space:]]/}"
            if [[ $_vg ]]; then
>>>>>                for _pv in $(lvm vgs --noheadings -o pv_name "$_vg" 2>/dev/null)
                do
                    check_block_and_slaves_all $1 $(get_maj_min $_pv)
                done
                return 0
            fi
        fi
    done
    return 1
}

Version-Release number of selected component (if applicable):
dracut-033-502.el7.x86_64 - RHEL 7.4

How reproducible:
Easy

Steps to Reproduce:
1. pvcreate vg_swap  /dev/mapper/vg_swap
2. vgcreate vg_swap /dev/mapper/vg_swap
3. lvcreate -L100 vg_swap
4. > dracut loops

  PV                     VG                  Fmt  Attr PSize   PFree                                                                                                                                                                                                                                                 
  /dev/mapper/vg_swap vg_swap lvm2 a--  100.00m    0 

Actual results:
Infinite loop, can't install new kernel with security fixes.

Expected results:
Initramfs generated

Additional info:
Workaround is to rename the VG

Comment 2 Lukáš Nykrýn 2018-03-01 13:31:22 UTC
I think we need to backport:
https://github.com/dracutdevs/dracut/commit/9ed6eb741f0bc0178167e7063751eb2bb4ac6de5

Comment 4 Jan Stodola 2018-03-28 10:16:35 UTC
Welterlen, I'm not able to reproduce this issue with dracut-033-502.el7 and the following steps:

[root@localhost ~]# pvcreate /dev/mapper/vg_swap 
  Physical volume "/dev/mapper/vg_swap" successfully created.
[root@localhost ~]# vgcreate vg_swap /dev/mapper/vg_swap 
  Volume group "vg_swap" successfully created
[root@localhost ~]# lvcreate -l 100%FREE -n vg_swap vg_swap
  Logical volume "vg_swap" created.
[root@localhost ~]#

[root@localhost ~]# pvs
  PV                  VG      Fmt  Attr PSize  PFree
  /dev/mapper/vg_swap vg_swap lvm2 a--  <2.00g    0 
[root@localhost ~]# lvs
  LV      VG      Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  vg_swap vg_swap -wi-a----- <2.00g                                                    
[root@localhost ~]# dracut /tmp/test
[root@localhost ~]# rpm -q dracut
dracut-033-502.el7.x86_64
[root@localhost ~]#

Is there something else I need to run?

Comment 5 Welterlen Benoit 2018-03-28 13:19:20 UTC
Hello Jan,

If the device is not automatically included to be managed by the initramfs, you have to add it :

dracut --force -vvvv /tmp/test  --add-device /dev/mapper/vg_swap

else it would not be listed.

Let me know if it still works.

Benoit

Comment 6 Jan Stodola 2018-03-28 13:46:30 UTC
Thank you, Benoit!
I can reproduce it now with the --add-device dracut option.

Comment 7 Harald Hoyer 2018-03-29 06:33:48 UTC
This should fix the issue:

https://github.com/dracutdevs/dracut/commit/e64dafd1f2489f1d926cce3e3bfd33f62b29b192

Comment 8 Welterlen Benoit 2018-03-29 07:52:20 UTC
And this one pointed by Lukas ?
https://github.com/dracutdevs/dracut/commit/9ed6eb741f0bc0178167e7063751eb2bb4ac6de5

Comment 9 Harald Hoyer 2018-03-29 09:57:56 UTC
(In reply to Welterlen Benoit from comment #8)
> And this one pointed by Lukas ?
> https://github.com/dracutdevs/dracut/commit/
> 9ed6eb741f0bc0178167e7063751eb2bb4ac6de5

This improves the performance, if you have a lot of device-mapper devices.

Comment 13 Jan Stodola 2018-07-25 12:33:04 UTC
Reproduced on RHEL-7.5 GA using a multipath device:

[root@localhost ~]# pvcreate /dev/mapper/mpatha1 
WARNING: xfs signature detected on /dev/mapper/mpatha1 at offset 0. Wipe it? [y/n]: y  
  Wiping xfs signature on /dev/mapper/mpatha1.
  Physical volume "/dev/mapper/mpatha1" successfully created.
[root@localhost ~]# vgcreate mpatha1 /dev/mapper/mpatha1 
  Volume group "mpatha1" successfully created
[root@localhost ~]# lvcreate -l 100%FREE -n mpath1 mpath1
  Volume group "mpath1" not found
  Cannot process volume group mpath1
[root@localhost ~]# lvcreate -l 100%FREE -n mpatha1 mpatha1
  Logical volume "mpatha1" created.
[root@localhost ~]# pvs
  PV                  VG      Fmt  Attr PSize PFree
  /dev/mapper/mpatha1 mpatha1 lvm2 a--  5.99g    0 
[root@localhost ~]# lvs
  LV      VG      Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  mpatha1 mpatha1 -wi-a----- 5.99g                                                    
[root@localhost ~]# dracut --force -vvvv /tmp/test --add-device /dev/mapper/mpatha1
Executing: /usr/sbin/dracut --force -vvvv /tmp/test --add-device /dev/mapper/mpatha1
^C[root@localhost ~]# rpm -q dracut
dracut-033-535.el7.x86_64
[root@localhost ~]#

Verified with dracut-033-547.el7:

[root@localhost ~]# dracut --force -vvvv /tmp/test --add-device /dev/mapper/mpatha1
Executing: /usr/sbin/dracut --force -vvvv /tmp/test --add-device /dev/mapper/mpatha1
dracut module 'modsign' will not be installed, because command 'keyctl' could not be found!
dracut module 'busybox' will not be installed, because command 'busybox' could not be found!
...
*** Creating initramfs image file '/tmp/test' done ***
[root@localhost ~]# ls -l /tmp/test 
-rw-------. 1 root root 22805437 Jul 25 14:12 /tmp/test
[root@localhost ~]# rpm -q dracut
dracut-033-547.el7.x86_64
[root@localhost ~]#

Moving to VERIFIED.

Comment 15 errata-xmlrpc 2018-10-30 11:26:36 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://access.redhat.com/errata/RHBA-2018:3232