Bug 1859412

Summary: either "_cache" should be a reserved string or single cmd conversion attempts should try a different name for its tmp volume after it finds "origin_cache" is already taken
Product: Red Hat Enterprise Linux 8 Reporter: Corey Marthaler <cmarthal>
Component: lvm2Assignee: LVM and device-mapper development team <lvm-team>
lvm2 sub component: Cache Logical Volumes QA Contact: cluster-qe <cluster-qe>
Status: CLOSED ERRATA Docs Contact:
Severity: low    
Priority: unspecified CC: agk, heinzm, jbrassow, mcsontos, msnitzer, pasik, prajnoha, teigland, zkabelac
Version: 8.3   
Target Milestone: rc   
Target Release: 8.0   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: lvm2-2.03.09-4.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-11-04 02:00:38 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-07-22 00:13:32 UTC
Description of problem:
[root@hayes-03 ~]# lvcreate --wipesignatures y  -L 4G -n corey writecache_sanity @slow
  Logical volume "corey" created.
[root@hayes-03 ~]# lvcreate --wipesignatures y  -L 4G -n corey_cache writecache_sanity @slow
  Logical volume "corey_cache" created.

[root@hayes-03 ~]# lvs -a -o +devices
  LV          VG                Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert Devices
  corey       writecache_sanity -wi-a----- 4.00g                                                     /dev/sde1(0)
  corey_cache writecache_sanity -wi-a----- 4.00g                                                     /dev/sde1(1024)

[root@hayes-03 ~]# lvconvert --type writecache --cachedevice /dev/sdf1 --cachesize 2G writecache_sanity/corey
  Creating cachevol LV corey_cache with size 2.00 GiB.
  Logical Volume "corey_cache" already exists in volume group "writecache_sanity"
  Failed to create cachevol LV

[root@hayes-03 ~]# lvconvert --test --type writecache --cachedevice /dev/sdf1 --cachesize 2G writecache_sanity/corey
  TEST MODE: Metadata will NOT be updated and volumes will not be (de)activated.
  Creating cachevol LV corey_cache with size 2.00 GiB.
  Logical Volume "corey_cache" already exists in volume group "writecache_sanity"
  Failed to create cachevol LV


Version-Release number of selected component (if applicable):
kernel-4.18.0-221.el8    BUILT: Thu Jun 25 16:28:39 CDT 2020
lvm2-2.03.09-3.el8    BUILT: Mon Jun 29 13:50:23 CDT 2020
lvm2-libs-2.03.09-3.el8    BUILT: Mon Jun 29 13:50:23 CDT 2020
lvm2-dbusd-2.03.09-3.el8    BUILT: Mon Jun 29 13:53:38 CDT 2020
lvm2-lockd-2.03.09-3.el8    BUILT: Mon Jun 29 13:50:23 CDT 2020
boom-boot-1.2-2.el8    BUILT: Mon Jun 29 08:27:02 CDT 2020
device-mapper-1.02.171-3.el8    BUILT: Mon Jun 29 13:50:23 CDT 2020
device-mapper-libs-1.02.171-3.el8    BUILT: Mon Jun 29 13:50:23 CDT 2020
device-mapper-event-1.02.171-3.el8    BUILT: Mon Jun 29 13:50:23 CDT 2020
device-mapper-event-libs-1.02.171-3.el8    BUILT: Mon Jun 29 13:50:23 CDT 2020

Comment 1 David Teigland 2020-07-22 16:39:30 UTC
Reserved suffixes are added to top level LV names when they become hidden.  When creating a cachevol, lvm is creating a top level LV name which needs to exist next to other top level LVs.  The _cvol suffix is then added to the cachevol name when it's attached, e.g. corey_cache is the top level LV name, it becomes corey_cache_cvol when attached, and corey_cache again when detached.  So, that leaves trying different names when necessary to avoid a collision, e.g. corey_cache%d.

Comment 2 David Teigland 2020-07-23 18:23:40 UTC
pushed to master:
https://sourceware.org/git/?p=lvm2.git;a=commit;h=085760992dc68efbda8fe8e1ad4a5a2eccef9139

# lvs -a test
  LV       VG   Attr       LSize 
  ww_cache test -wi------- 4.00m

# lvcreate --type writecache --cachesize 64M --cachedevice /dev/sdc -n ww -L 128M test /dev/sdb
  Logical volume "ww" created.
  Creating cachevol LV ww_cache0 with size 64.00 MiB.
  Logical volume "ww_cache0" created.
  Using writecache block size 512 for unknown file system block size, logical block size 512, physical block size 512.
  Logical volume test/ww now has writecache.

# lvs -a test
  LV               VG   Attr       LSize   Pool             Origin      Data%  
  ww               test Cwi-a-C--- 128.00m [ww_cache0_cvol] [ww_wcorig] 0.00  
  ww_cache         test -wi-------   4.00m                                    
  [ww_cache0_cvol] test Cwi-aoC---  64.00m                                    
  [ww_wcorig]      test owi-aoC--- 128.00m               

# lvconvert --splitcache test/ww
  Logical volume test/ww writecache has been detached.

# lvs -a test
  LV        VG   Attr       LSize   
  ww        test -wi-a----- 128.00m
  ww_cache  test -wi-------   4.00m
  ww_cache0 test -wi-------  64.00m

Comment 5 Corey Marthaler 2020-08-17 16:51:37 UTC
Fix verified in the latest rpms.

kernel-4.18.0-232.el8    BUILT: Mon Aug 10 02:17:54 CDT 2020
lvm2-2.03.09-5.el8    BUILT: Wed Aug 12 15:51:50 CDT 2020
lvm2-libs-2.03.09-5.el8    BUILT: Wed Aug 12 15:51:50 CDT 2020
lvm2-lockd-2.03.09-5.el8    BUILT: Wed Aug 12 15:51:50 CDT 2020
device-mapper-1.02.171-5.el8    BUILT: Wed Aug 12 15:51:50 CDT 2020
device-mapper-libs-1.02.171-5.el8    BUILT: Wed Aug 12 15:51:50 CDT 2020
device-mapper-event-1.02.171-5.el8    BUILT: Wed Aug 12 15:51:50 CDT 2020
device-mapper-event-libs-1.02.171-5.el8    BUILT: Wed Aug 12 15:51:50 CDT 2020


[root@hayes-01 ~]# lvcreate --wipesignatures y  -L 4G -n corey writecache_sanity @slow
  Logical volume "corey" created.
[root@hayes-01 ~]# lvcreate --wipesignatures y  -L 4G -n corey_cache writecache_sanity @slow
  Logical volume "corey_cache" created.
[root@hayes-01 ~]# lvs -a -o +devices
  LV          VG                Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert Devices        
  corey       writecache_sanity -wi-a----- 4.00g                                                     /dev/sdb1(0)   
  corey_cache writecache_sanity -wi-a----- 4.00g                                                     /dev/sdb1(1024)

[root@hayes-01 ~]# lvconvert --type writecache --cachedevice /dev/sdf1 --cachesize 2G writecache_sanity/corey
  Creating cachevol LV corey_cache0 with size 2.00 GiB.
  Logical volume "corey_cache0" created.
  Using writecache block size 512 for unknown file system block size, logical block size 512, physical block size 512.
  Logical volume writecache_sanity/corey now has writecache.

Comment 8 errata-xmlrpc 2020-11-04 02:00:38 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