Bug 1806068

Summary: erroneous lvol created when attempting to use already in use writecache pool internal volume as a dm-cache pool
Product: Red Hat Enterprise Linux 8 Reporter: Corey Marthaler <cmarthal>
Component: lvm2Assignee: David Teigland <teigland>
lvm2 sub component: Cache Logical Volumes QA Contact: cluster-qe <cluster-qe>
Status: CLOSED ERRATA Docs Contact:
Severity: low    
Priority: medium CC: agk, heinzm, jbrassow, mcsontos, msnitzer, pasik, prajnoha, zkabelac
Version: 8.2   
Target Milestone: rc   
Target Release: 8.0   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: lvm2-2.03.09-2.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-11-04 02:00:25 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:

Description Corey Marthaler 2020-02-21 22:32:09 UTC
Description of problem:
This is similar to earlier bug 1806063, but instead of attempting to use the in-use internal cvol for another writecache volume, it's attempted to be used as a dm-cache pool.

[root@host-092 ~]# lvcreate --wipesignatures y  -L 1G -n origin_1 writecache_sanity @slow
  Logical volume "origin_1" created.
[root@host-092 ~]# lvcreate --wipesignatures y  -L 1G -n origin_2 writecache_sanity @slow
  Logical volume "origin_2" created.
[root@host-092 ~]# lvcreate  -L 1G -n multiple_origins writecache_sanity @fast
  Logical volume "multiple_origins" created.

[root@host-092 ~]# lvs -a -o +devices
  LV               VG                Attr       LSize   Pool   Origin  Devices        
  multiple_origins writecache_sanity -wi-a-----   1.00g                /dev/sdd1(0)   
  origin_1         writecache_sanity -wi-a-----   1.00g                /dev/sdc1(0)   
  origin_2         writecache_sanity -wi-a-----   1.00g                /dev/sdc1(256) 

[root@host-092 ~]# lvchange -an writecache_sanity
[root@host-092 ~]# lvconvert --yes --type writecache --cachevol writecache_sanity/multiple_origins writecache_sanity/origin_1
  Logical volume writecache_sanity/origin_1 now has write cache.

[root@host-092 ~]# lvs -a -o +devices,segtype
  LV                      VG                Attr       LSize   Pool                    Origin             Devices            Type      
  [multiple_origins_cvol] writecache_sanity Cwi---C---   1.00g                                            /dev/sdd1(0)       linear    
  origin_1                writecache_sanity Cwi---C---   1.00g [multiple_origins_cvol] [origin_1_wcorig]  origin_1_wcorig(0) writecache
  [origin_1_wcorig]       writecache_sanity owi---C---   1.00g                                            /dev/sdc1(0)       linear    
  origin_2                writecache_sanity -wi-------   1.00g                                            /dev/sdc1(256)     linear    

# Attempt to create dm-cache using same in-use internal volume (writecache_sanity/multiple_origins) and origin_2
[root@host-092 ~]# lvconvert --yes --type cache --cachepool writecache_sanity/multiple_origins_cvol writecache_sanity/origin_2
  WARNING: Converting writecache_sanity/multiple_origins_cvol to cache pool's data volume with metadata wiping.
  THIS WILL DESTROY CONTENT OF LOGICAL VOLUME (filesystem etc.)
  Cannot rename internal LV "multiple_origins_cvol".
  LV writecache_sanity/multiple_origins_cvol could not be converted to a cache pool.

# This results in erroneous lvols
[root@host-092 ~]# lvs -a -o +devices
  LV                      VG                Attr       LSize   Pool                    Origin             Devices           
  lvol0                   writecache_sanity -wi-------   8.00m                                            /dev/sdb1(0)      
  [multiple_origins_cvol] writecache_sanity Cwi---C---   1.00g                                            /dev/sdd1(0)      
  origin_1                writecache_sanity Cwi---C---   1.00g [multiple_origins_cvol] [origin_1_wcorig]  origin_1_wcorig(0)
  [origin_1_wcorig]       writecache_sanity owi---C---   1.00g                                            /dev/sdc1(0)      
  origin_2                writecache_sanity -wi-------   1.00g                                            /dev/sdc1(256)    

[root@host-092 ~]# lvconvert --yes --type cache --cachepool writecache_sanity/multiple_origins_cvol writecache_sanity/origin_2
  WARNING: Converting writecache_sanity/multiple_origins_cvol to cache pool's data volume with metadata wiping.
  THIS WILL DESTROY CONTENT OF LOGICAL VOLUME (filesystem etc.)
  Cannot rename internal LV "multiple_origins_cvol".
  LV writecache_sanity/multiple_origins_cvol could not be converted to a cache pool.

[root@host-092 ~]# lvconvert --yes --type cache --cachepool writecache_sanity/multiple_origins_cvol writecache_sanity/origin_2
  WARNING: Converting writecache_sanity/multiple_origins_cvol to cache pool's data volume with metadata wiping.
  THIS WILL DESTROY CONTENT OF LOGICAL VOLUME (filesystem etc.)
  Cannot rename internal LV "multiple_origins_cvol".
  LV writecache_sanity/multiple_origins_cvol could not be converted to a cache pool.

[root@host-092 ~]# lvs -a -o +devices
  LV                      VG                Attr       LSize   Pool                    Origin             Devices           
  lvol0                   writecache_sanity -wi-------   8.00m                                            /dev/sdb1(0)      
  lvol1                   writecache_sanity -wi-------   8.00m                                            /dev/sdb1(2)      
  lvol2                   writecache_sanity -wi-------   8.00m                                            /dev/sdb1(4)      
  [multiple_origins_cvol] writecache_sanity Cwi---C---   1.00g                                            /dev/sdd1(0)      
  origin_1                writecache_sanity Cwi---C---   1.00g [multiple_origins_cvol] [origin_1_wcorig]  origin_1_wcorig(0)
  [origin_1_wcorig]       writecache_sanity owi---C---   1.00g                                            /dev/sdc1(0)      
  origin_2                writecache_sanity -wi-------   1.00g                                            /dev/sdc1(256)    


Version-Release number of selected component (if applicable):
kernel-4.18.0-179.el8    BUILT: Fri Feb 14 17:03:01 CST 2020
lvm2-2.03.08-1.el8    BUILT: Tue Feb 11 07:40:33 CST 2020
lvm2-libs-2.03.08-1.el8    BUILT: Tue Feb 11 07:40:33 CST 2020
lvm2-dbusd-2.03.08-1.el8    BUILT: Tue Feb 11 07:42:51 CST 2020
lvm2-lockd-2.03.08-1.el8    BUILT: Tue Feb 11 07:40:33 CST 2020
boom-boot-1.0-1.el8    BUILT: Fri Nov 29 05:18:30 CST 2019
device-mapper-1.02.169-1.el8    BUILT: Tue Feb 11 07:40:33 CST 2020
device-mapper-libs-1.02.169-1.el8    BUILT: Tue Feb 11 07:40:33 CST 2020
device-mapper-event-1.02.169-1.el8    BUILT: Tue Feb 11 07:40:33 CST 2020
device-mapper-event-libs-1.02.169-1.el8    BUILT: Tue Feb 11 07:40:33 CST 2020


How reproducible:
Everytime

Comment 1 David Teigland 2020-05-22 19:13:42 UTC
fix in master:
https://sourceware.org/git/?p=lvm2.git;a=commit;h=74a211cfd30e93d9388de5ac1ee22e630c840e94

[root@null-01 lvm.git]# lvs -a test
  LV                VG   Attr       LSize  Pool              Origin        
  main              test Cwi---C--- 64.00m [main_cache_cvol] [main_wcorig]
  main2             test -wi------- 32.00m                                
  [main_cache_cvol] test Cwi---C--- 40.00m                                
  [main_wcorig]     test owi---C--- 64.00m           

[root@null-01 lvm.git]# lvconvert --type writecache --cachevol test/main_cache_cvol test/main2 
  LV test/main_cache_cvol is already used as a cachevol.

[root@null-01 lvm.git]# lvconvert --type cache --cachepool test/main_cache_cvol test/main2 
  LV test/main_cache_cvol is already used as a cachevol.

[root@null-01 lvm.git]# lvconvert --type cache --cachevol test/main_cache_cvol test/main2 
  LV test/main_cache_cvol is already used as a cachevol.

Comment 5 Corey Marthaler 2020-06-15 22:49:05 UTC
Fix verified in the latest rpms.

kernel-4.18.0-208.el8    BUILT: Thu May 28 09:44:03 CDT 2020
lvm2-2.03.09-2.el8    BUILT: Fri May 29 11:29:58 CDT 2020
lvm2-libs-2.03.09-2.el8    BUILT: Fri May 29 11:29:58 CDT 2020
lvm2-dbusd-2.03.09-2.el8    BUILT: Fri May 29 11:32:49 CDT 2020
lvm2-lockd-2.03.09-2.el8    BUILT: Fri May 29 11:29:58 CDT 2020
boom-boot-1.1-2.el8    BUILT: Tue May 26 08:45:48 CDT 2020
device-mapper-1.02.171-2.el8    BUILT: Fri May 29 11:29:58 CDT 2020
device-mapper-libs-1.02.171-2.el8    BUILT: Fri May 29 11:29:58 CDT 2020
device-mapper-event-1.02.171-2.el8    BUILT: Fri May 29 11:29:58 CDT 2020
device-mapper-event-libs-1.02.171-2.el8    BUILT: Fri May 29 11:29:58 CDT 2020
device-mapper-persistent-data-0.8.5-3.el8    BUILT: Wed Nov 27 07:05:21 CST 2019


[root@hayes-03 ~]# lvs -a -o +devices
  LV                      VG                Attr       LSize Pool                    Origin            Data%  Meta%  Move Log Cpy%Sync Convert Devices           
  [multiple_origins_cvol] writecache_sanity Cwi---C--- 1.00g                                                                                   /dev/sdh1(0)      
  origin_1                writecache_sanity Cwi---C--- 1.00g [multiple_origins_cvol] [origin_1_wcorig]                                         origin_1_wcorig(0)
  [origin_1_wcorig]       writecache_sanity owi---C--- 1.00g                                                                                   /dev/sdf1(0)      
  origin_2                writecache_sanity -wi------- 1.00g                                                                                   /dev/sdf1(256)    
  origin_3                writecache_sanity -wi------- 1.00g                                                                                   /dev/sdf1(512)    
[root@hayes-03 ~]# 
[root@hayes-03 ~]# lvconvert --yes --type cache --cachepool writecache_sanity/multiple_origins_cvol writecache_sanity/origin_2
  LV writecache_sanity/multiple_origins_cvol is already used as a cachevol.
[root@hayes-03 ~]# lvs -a -o +devices,segtype
  LV                      VG                Attr       LSize Pool                    Origin            Data%  Meta%  Move Log Cpy%Sync Convert Devices            Type      
  [multiple_origins_cvol] writecache_sanity Cwi---C--- 1.00g                                                                                   /dev/sdh1(0)       linear    
  origin_1                writecache_sanity Cwi---C--- 1.00g [multiple_origins_cvol] [origin_1_wcorig]                                         origin_1_wcorig(0) writecache
  [origin_1_wcorig]       writecache_sanity owi---C--- 1.00g                                                                                   /dev/sdf1(0)       linear    
  origin_2                writecache_sanity -wi------- 1.00g                                                                                   /dev/sdf1(256)     linear    
  origin_3                writecache_sanity -wi------- 1.00g                                                                                   /dev/sdf1(512)     linear

Comment 8 errata-xmlrpc 2020-11-04 02:00:25 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 (lvm2 bug fix and enhancement update), 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-2020:4546