Bug 1828617

Summary: vgscan --mknodes creates all device mapper nodes, not just vg/lvs
Product: [Community] LVM and device-mapper Reporter: Michael Hudson-Doyle <michael.hudson>
Component: lvm2Assignee: Zdenek Kabelac <zkabelac>
lvm2 sub component: Activating existing Logical Volumes QA Contact: cluster-qe <cluster-qe>
Status: NEW --- Docs Contact:
Severity: unspecified    
Priority: high CC: agk, heinzm, jbrassow, michael.hudson, msnitzer, prajnoha, thornber, zkabelac
Version: 2.02.185Flags: pm-rhel: lvm-technical-solution?
pm-rhel: lvm-test-coverage?
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 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:
Attachments:
Description Flags
vgscan -vvvv --mknodes' output none

Description Michael Hudson-Doyle 2020-04-27 22:32:46 UTC
Description of problem:


Version-Release number of selected component (if applicable):

This was observed with the 2.03.07-1ubuntu1 package on Ubuntu 20.04 but I don't think this code has changed in a long time.

How reproducible:

100%

Steps to Reproduce:
1. Have a system with multipath nodes:

# ls -l /dev/mapper/
total 0
crw------- 1 root root 10, 236 Apr 24 05:57 control
lrwxrwxrwx 1 root root       7 Apr 27 22:26 mpatha -> ../dm-0
lrwxrwxrwx 1 root root       7 Apr 27 22:26 mpatha-part1 -> ../dm-1


2. Remove the nodes: 

# rm -rf /dev/mapper/mpath*

3. Run vgscan:

# vgscan --mknodes


Actual results:

/dev/mapper is now full of block devices, not symlinks:

# ls -l /dev/mapper/
total 0
crw------- 1 root root  10, 236 Apr 24 05:57 control
brw-rw---- 1 root disk 253,   0 Apr 27 22:28 mpatha
brw-rw---- 1 root disk 253,   1 Apr 27 22:28 mpatha-part1


Expected results:

I would not expect scanning for vgs to do anything with device mapper nodes that are not related to lvm.

Additional info:

It's fairly easy to see why this happens:

Passing --mknodes to vgscan means it calls vgmknodes.
vgmknodes calls lv_mknodes(cmd, NULL)
lv_mknodes(cmd, NULL) calls dm_mknodes(NULL)
dm_mknodes(NULL) makes nodes for all device mapper nodes

This causes problems because in an installer, we watch for udev block events, and call vgscan to see if any vgs have appeared. This sometimes races with udev's own event processing to the extent that udev does not create links in /dev/mapper because the block devices are already there. Later code assumes the udev created symlinks and gets confused.

Comment 1 Zdenek Kabelac 2020-04-29 11:45:38 UTC
Hi

Can you please attach  'vgscan -vvvv --mknodes' output.

Comment 2 Zdenek Kabelac 2020-04-29 12:10:25 UTC
A side comment -  --mknode should never ever be used on a system with running udev -  it's not compatible and basically it's serving the purpose only in cases of emergency when udev is malfunctioning.

Placing such command into 'regular' boot procedure on system with running udev is wrong by design.

Comment 3 Michael Hudson-Doyle 2020-04-29 19:55:52 UTC
Created attachment 1683072 [details]
vgscan -vvvv --mknodes' output

Here's the output requested. Good to know that --mknodes is not meant to be used with udev -- perhaps we can get a warning added to the man page?