Bug 1658224

Summary: Unable to create VDO volume on partitioned device
Product: Red Hat Enterprise Linux 8 Reporter: Andy Walsh <awalsh>
Component: vdoAssignee: Andy Walsh <awalsh>
Status: CLOSED CURRENTRELEASE QA Contact: Jakub Krysl <jkrysl>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 8.0CC: awalsh, jkrysl, limershe
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: 8.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: 6.2.0.293-10 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-06-14 01:01:35 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: 1653413    
Bug Blocks:    

Description Andy Walsh 2018-12-11 14:31:07 UTC
Description of problem:
Because of a change in behavior in the blkid utility, a partitioned device now causes blkid to exit with a status of 0, when the VDO Manager utility requires an exit status of 2 to continue without a --force option specified during the 'vdo create' operation.

Version-Release number of selected component (if applicable):
vdo-6.2.0.273-9.el8
util-linux-2.32.1-6.el8

How reproducible:
100%

Steps to Reproduce:
1. Partition a block device
2. Run 'vdo create' against it

Actual results:
vdo: ERROR - device is a physical volume; use --force to override

Expected results:
VDO instance 0 volume is ready at /dev/mapper/vdo0

Additional info:
The blkid utility was recently modified to allow an additional flag to be specified to restore the original behavior (--no-part-details).  The fix for this bug will require an updated dependency to require at least the new version of blkid (util-linux-2.32.1-7.el8).

I will paste the output in follow-up comments.

Comment 1 Andy Walsh 2018-12-11 14:33:51 UTC
Here is the output of a failure condition.

# No partition, blkid exits with 2 status.
[vagrant@rhel-8-nightly ~]$ lsblk
NAME   MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda    253:0    0  10G  0 disk
├─vda1 253:1    0   1G  0 part /boot
├─vda2 253:2    0   1G  0 part [SWAP]
└─vda3 253:3    0   8G  0 part /
vdb    253:16   0  20G  0 disk
[vagrant@rhel-8-nightly ~]$ sudo blkid -p /dev/vdb
[vagrant@rhel-8-nightly ~]$ echo $?
2

# Create a partition on the device, now blkid exits with a 0 status.
[vagrant@rhel-8-nightly ~]$ sudo parted
GNU Parted 3.2
Using /dev/vdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel msdos
(parted) mkpart pri "" 1M -1M
(parted)
Information: You may need to update /etc/fstab.

[vagrant@rhel-8-nightly ~]$ lsblk
NAME   MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda    253:0    0  10G  0 disk
├─vda1 253:1    0   1G  0 part /boot
├─vda2 253:2    0   1G  0 part [SWAP]
└─vda3 253:3    0   8G  0 part /
vdb    253:16   0  20G  0 disk
└─vdb1 253:17   0  20G  0 part
[vagrant@rhel-8-nightly ~]$ sudo blkid -p /dev/vdb
/dev/vdb: PTUUID="83516ab6" PTTYPE="dos"
[vagrant@rhel-8-nightly ~]$ echo $?
0
[vagrant@rhel-8-nightly ~]$ sudo blkid -p /dev/vdb1
/dev/vdb1: PART_ENTRY_SCHEME="dos" PART_ENTRY_UUID="83516ab6-01" PART_ENTRY_TYPE="0x83" PART_ENTRY_NUMBER="1" PART_ENTRY_OFFSET="2048" PART_ENTRY_SIZE="41938944" PART_ENTRY_DISK="253:16"
[vagrant@rhel-8-nightly ~]$ echo $?
0

# Now VDO fails to create.
[vagrant@rhel-8-nightly ~]$ sudo vdo create --name vdo0 --device /dev/vdb1 --verbose
    mkdir -p /run/lock/vdo
    touch /run/lock/vdo/_etc_vdoconf.yml.lock
    chmod 644 /run/lock/vdo/_etc_vdoconf.yml.lock
    touch /run/lock/vdo-config-singletons
Creating VDO vdo0
    grep MemAvailable /proc/meminfo
    pvcreate -qq --test /dev/vdb1
    blkid -p /dev/vdb1
vdo: ERROR - device is a physical volume; use --force to override

Comment 2 Andy Walsh 2018-12-11 14:34:27 UTC
The affected code in VDO Manager:

/usr/lib/python3.6/site-packages/vdo/vdomgmnt/VDOService.py
   1371     # If this is a physical volume that's not in use by any logical
   1372     # volumes the above check won't trigger an error. So do a second
   1373     # check that catches that.
   1374     try:
   1375       runCommand(['blkid', '-p', self.device])
   1376     except CommandError as e:
   1377       if e.getExitCode() == 2:
   1378         return
   1379     raise VDOServiceError('device is a physical volume;'
   1380                           + ' use --force to override',
   1381                           exitStatus = StateExitStatus)

Comment 3 Andy Walsh 2018-12-11 14:43:31 UTC
By installing the updated util-linux package (2.32.1-7.el8) and updating the VDOService.py to include the '--no-part-details', I am now able to create a VDO volume on top of a partition once again.

[vagrant@rhel-8-nightly util-linux]$ rpm -qa util-linux
util-linux-2.32.1-7.el8.x86_64

# Updated the blkid call to use --no-part-details:
   1371     # If this is a physical volume that's not in use by any logical
   1372     # volumes the above check won't trigger an error. So do a second
   1373     # check that catches that.
   1374     try:
   1375       runCommand(['blkid', '-p', '--no-part-details', self.device])
   1376     except CommandError as e:
   1377       if e.getExitCode() == 2:
   1378         return
   1379     raise VDOServiceError('device is a physical volume;'
   1380                           + ' use --force to override',
   1381                           exitStatus = StateExitStatus)


[vagrant@rhel-8-nightly util-linux]$ sudo blkid -p /dev/vdb
/dev/vdb: PTUUID="15a53d51" PTTYPE="dos"
[vagrant@rhel-8-nightly util-linux]$ echo $?
0
[vagrant@rhel-8-nightly util-linux]$ sudo blkid -p --no-part-details /dev/vdb
/dev/vdb: PTUUID="15a53d51" PTTYPE="dos"
[vagrant@rhel-8-nightly util-linux]$ echo $?
0
[vagrant@rhel-8-nightly util-linux]$ sudo blkid -p /dev/vdb1
/dev/vdb1: PART_ENTRY_SCHEME="dos" PART_ENTRY_UUID="15a53d51-01" PART_ENTRY_TYPE="0x83" PART_ENTRY_NUMBER="1" PART_ENTRY_OFFSET="2048" PART_ENTRY_SIZE="41938944" PART_ENTRY_DISK="253:16"
[vagrant@rhel-8-nightly util-linux]$ echo $?
0
[vagrant@rhel-8-nightly util-linux]$ sudo blkid -p --no-part-details /dev/vdb1
[vagrant@rhel-8-nightly util-linux]$ echo $?
2
[vagrant@rhel-8-nightly util-linux]$ sudo vdo create --name vdo0 --device /dev/vdb1 --verbose
Creating VDO vdo0
    grep MemAvailable /proc/meminfo
    pvcreate -qq --test /dev/vdb1
    blkid -p --no-part-details /dev/vdb1
    modprobe kvdo
    vdoformat --uds-checkpoint-frequency=0 --uds-memory-size=0.25 /dev/vdb1
    vdodumpconfig /dev/vdb1
Starting VDO vdo0
    dmsetup status vdo0
    grep MemAvailable /proc/meminfo
    modprobe kvdo
    vdodumpconfig /dev/vdb1
    vdodumpconfig /dev/vdb1
    dmsetup create vdo0 --uuid VDO-6bc4c504-d463-49cd-9e97-5d6e51da8128 --table '0 33489040 vdo V2 /dev/vdb1 5242368 4096 32768 16380 on auto vdo0 maxDiscard 1 ack 1 bio 4 bioRotationInterval 64 cpu 2 hash 1 logical 1 physical 1'
    dmsetup status vdo0
Starting compression on VDO vdo0
    dmsetup message vdo0 0 compression on
    vdodmeventd -r vdo0
    dmsetup status vdo0
VDO instance 1 volume is ready at /dev/mapper/vdo0

Comment 4 Andy Walsh 2018-12-11 14:58:04 UTC
> Steps to Reproduce:
> 1. Partition a block device
> 2. Run 'vdo create' against it

This is a bit too vague.

1. Partition a block device (i.e. /dev/vdb)
2. Run 'vdo create' against the new partition (i.e. /dev/vdb1)

Comment 5 Jakub Krysl 2018-12-11 15:11:56 UTC
This is reproducible on loopdev and virtual disk, probably only on those. Tested on real SATA drive and could not hit it, blkid of new partition does not return anything there and exits with 2. On loopdev it returns UUID and exits with 0.

Comment 7 Jakub Krysl 2018-12-17 15:03:23 UTC
kmod-kvdo-6.2.0.293-38.el8.x86_64
vdo-6.2.0.293-10.el8.x86_64

blkid now treats loopdevs the same way as real devices, so vdo can be created there without issues:
# blkid /dev/sda
# echo $?
2
# blkid /dev/loop1
# echo $?
2
# vdo create --name vdo --device /dev/loop1
Creating VDO vdo
Starting VDO vdo
Starting compression on VDO vdo
VDO instance 15 volume is ready at /dev/mapper/vdo