Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1859411

Summary: Second attempt to write cache origin that's already cached shouldn't result in left over device after cmd failure
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.3Flags: pm-rhel: mirror+
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:07:38 UTC
Description of problem:

# create origin
[root@hayes-03 ~]# lvcreate --wipesignatures y  -L 4G -n single writecache_sanity @slow
  Logical volume "single" created.

# convert to writecache w/ one cmd and no pool device created yet
[root@hayes-03 ~]# lvconvert --type writecache --cachedevice /dev/sdp1 --cachesize 2G writecache_sanity/single
  Creating cachevol LV single_cache with size 2.00 GiB.
  Logical volume "single_cache" created.
  Using writecache block size 512 for unknown file system block size, logical block size 512, physical block size 4096.
  Logical volume writecache_sanity/single now has writecache.

[root@hayes-03 ~]# lvs -a -o +devices,segtype
  LV                  VG                Attr       LSize Pool                Origin          Data%  Meta%  Move Log Cpy%Sync Convert Devices          Type
  single              writecache_sanity Cwi-a-C--- 4.00g [single_cache_cvol] [single_wcorig] 0.00                                    single_wcorig(0) writecache
  [single_cache_cvol] writecache_sanity Cwi-aoC--- 2.00g                                                                             /dev/sdp1(0)     linear
  [single_wcorig]     writecache_sanity owi-aoC--- 4.00g                                                                             /dev/sde1(0)     linear

# Try the exact same conversion attempt again, should fail and not create any devices 
[root@hayes-03 ~]# lvconvert --type writecache --cachedevice /dev/sdp1 --cachesize 2G writecache_sanity/single
  Creating cachevol LV single_cache with size 2.00 GiB.
  Logical volume "single_cache" created.
  Using writecache block size 512 for unknown file system block size, logical block size 512, physical block size 4096.
  Logical Volume "single_cache_cvol" already exists in volume group "writecache_sanity"

# Ends up with "single_cache" device left over
[root@hayes-03 ~]# lvs -a -o +devices,segtype
  LV                  VG                Attr       LSize Pool                Origin          Data%  Meta%  Move Log Cpy%Sync Convert Devices          Type
  single              writecache_sanity Cwi-a-C--- 4.00g [single_cache_cvol] [single_wcorig] 0.00                                    single_wcorig(0) writecache
  single_cache        writecache_sanity -wi------- 2.00g                                                                             /dev/sdp1(512)   linear
  [single_cache_cvol] writecache_sanity Cwi-aoC--- 2.00g                                                                             /dev/sdp1(0)     linear
  [single_wcorig]     writecache_sanity owi-aoC--- 4.00g                                                                             /dev/sde1(0)     linear


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-23 20:14:41 UTC
pushed to master
https://sourceware.org/git/?p=lvm2.git;a=commit;h=7a507583d97c1f4b11d5f1a94958f65cf42b6f9f

# lvs test
  LV        VG   Attr       LSize   Pool            Origin      
  ww        test Cwi---C--- 128.00m [ww_cache_cvol] [ww_wcorig]

# lvconvert --type writecache --cachesize 64M --cachedevice /dev/sdb test/ww
  Command on LV test/ww does not accept LV type writecache.
  Command not permitted on LV test/ww.

Comment 4 Corey Marthaler 2020-08-18 00:07:43 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-dbusd-2.03.09-5.el8    BUILT: Wed Aug 12 15:49:44 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-02 ~]# vgs
  VG                #PV #LV #SN Attr   VSize   VFree  
  writecache_sanity  13   0   0 wz--n- <19.50t <19.50t
[root@hayes-02 ~]# lvcreate --wipesignatures y  -L 4G -n single writecache_sanity @slow
  Logical volume "single" created.

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

[root@hayes-02 ~]# lvs -a -o +devices,segtype
  LV                  VG                Attr       LSize Pool                Origin          Data%  Meta%  Move Log Cpy%Sync Convert Devices          Type      
  single              writecache_sanity Cwi-a-C--- 4.00g [single_cache_cvol] [single_wcorig] 0.00                                    single_wcorig(0) writecache
  [single_cache_cvol] writecache_sanity Cwi-aoC--- 2.00g                                                                             /dev/sdp1(0)     linear    
  [single_wcorig]     writecache_sanity owi-aoC--- 4.00g                                                                             /dev/sdo1(0)     linear
    
[root@hayes-02 ~]# lvconvert --type writecache --cachedevice /dev/sdp1 --cachesize 2G writecache_sanity/single
  Command on LV writecache_sanity/single does not accept LV type writecache.
  Command not permitted on LV writecache_sanity/single.

[root@hayes-02 ~]# lvs -a -o +devices,segtype
  LV                  VG                Attr       LSize Pool                Origin          Data%  Meta%  Move Log Cpy%Sync Convert Devices          Type      
  single              writecache_sanity Cwi-a-C--- 4.00g [single_cache_cvol] [single_wcorig] 0.00                                    single_wcorig(0) writecache
  [single_cache_cvol] writecache_sanity Cwi-aoC--- 2.00g                                                                             /dev/sdp1(0)     linear    
  [single_wcorig]     writecache_sanity owi-aoC--- 4.00g                                                                             /dev/sdo1(0)     linear

Comment 7 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