Bug 1964622

Summary: unable to remove writecache converted thinpool volume
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: medium    
Priority: medium CC: agk, heinzm, jbrassow, mcsontos, msnitzer, prajnoha, zkabelac
Version: 8.5Keywords: Triaged
Target Milestone: beta   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: lvm2-2.03.12-3.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-11-09 19:45:54 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 2021-05-25 19:12:03 UTC
Description of problem:
I assume this is the exact bug mentioned here:
https://bugzilla.redhat.com/show_bug.cgi?id=1957898#c4

I thought this may have been fixed in the latest lvm rpms when attempting this but it appears it's not. Filing this to track this for rhel8.5

[root@hayes-01 ~]# lvcreate -n wc -L 2G snapper_thinp /dev/sdc1
  Logical volume "wc" created.

[root@hayes-01 ~]# lvchange -an snapper_thinp/wc

[root@hayes-01 ~]# lvconvert --yes --type writecache --cachevol snapper_thinp/wc  snapper_thinp/POOL
  Using writecache block size 512 for unknown file system block size, logical block size 512, physical block size 512.
  Logical volume snapper_thinp/POOL now has writecache.

[root@hayes-01 ~]# lvs -a -o +devices
  LV                  VG            Attr       LSize Pool      Origin              Data%  Meta%  Move Log Cpy%Sync Convert Devices             
  POOL                snapper_thinp twi-a-t--- 1.00g                               0.00   10.94                            POOL_tdata(0)       
  [POOL_tdata]        snapper_thinp Cwi-aoC--- 1.00g [wc_cvol] [POOL_tdata_wcorig] 0.00                                    POOL_tdata_wcorig(0)
  [POOL_tdata_wcorig] snapper_thinp owi-aoC--- 1.00g                                                                       /dev/sdb1(1)        
  [POOL_tmeta]        snapper_thinp ewi-ao---- 4.00m                                                                       /dev/sdh1(0)        
  [lvol0_pmspare]     snapper_thinp ewi------- 4.00m                                                                       /dev/sdb1(0)        
  [wc_cvol]           snapper_thinp Cwi-aoC--- 2.00g                                                                       /dev/sdc1(0)        

[root@hayes-01 ~]# lvremove -f snapper_thinp
  LV segment POOL_tdata:0-4294967295 is incorrectly listed as being used by LV wc_cvol
  Internal error: LV segments corrupted in wc_cvol.


Version-Release number of selected component (if applicable):
kernel-4.18.0-305.7.el8.kpq1    BUILT: Mon May 17 12:55:07 CDT 2021
lvm2-2.03.12-1.el8    BUILT: Sat May 22 01:53:57 CDT 2021
lvm2-libs-2.03.12-1.el8    BUILT: Sat May 22 01:53:57 CDT 2021

Comment 1 David Teigland 2021-06-02 14:21:40 UTC
this was included in the bz mentioned above, this was the relevant part for this bz:

fix to allow removing a thin pool that has writecache on the data LV:
https://sourceware.org/git/?p=lvm2.git;a=commit;h=4a746f7ffcc8e61c9cb5ce9f9e8a061d1ef6b28e

Comment 3 Corey Marthaler 2021-06-15 20:21:52 UTC
Marking Verified:Tested in that latest rpms.

kernel-4.18.0-310.el8    BUILT: Thu May 27 14:24:00 CDT 2021
lvm2-2.03.12-3.el8    BUILT: Tue Jun 15 11:37:17 CDT 2021
lvm2-libs-2.03.12-3.el8    BUILT: Tue Jun 15 11:37:17 CDT 2021


[root@hayes-02 ~]# lvcreate --yes  --thinpool POOL -L 1G --profile thin-performance --zero y --poolmetadatasize 4M snapper_thinp
  Thin pool volume with chunk size 64.00 KiB can address at most <15.88 TiB of data.
  Logical volume "POOL" created.
[root@hayes-02 ~]# lvcreate --yes  -L 1G -n wcpool snapper_thinp /dev/sdc1
  Logical volume "wcpool" created.
[root@hayes-02 ~]# lvchange -an snapper_thinp/wcpool
[root@hayes-02 ~]# lvconvert --yes --type writecache --cachevol snapper_thinp/wcpool snapper_thinp/POOL
  Using writecache block size 512 for unknown file system block size, logical block size 512, physical block size 4096.
  Logical volume snapper_thinp/POOL now has writecache.
[root@hayes-02 ~]# lvs -a -o +devices
  LV                  VG            Attr       LSize Pool          Origin              Data%  Meta%  Move Log Cpy%Sync Convert Devices             
  POOL                snapper_thinp twi-a-tz-- 1.00g                                   0.00   10.94                            POOL_tdata(0)       
  [POOL_tdata]        snapper_thinp Cwi-aoC--- 1.00g [wcpool_cvol] [POOL_tdata_wcorig] 0.00                                    POOL_tdata_wcorig(0)
  [POOL_tdata_wcorig] snapper_thinp owi-aoC--- 1.00g                                                                           /dev/sde1(1)        
  [POOL_tmeta]        snapper_thinp ewi-ao---- 4.00m                                                                           /dev/sdo1(0)        
  [lvol0_pmspare]     snapper_thinp ewi------- 4.00m                                                                           /dev/sde1(0)        
  [wcpool_cvol]       snapper_thinp Cwi-aoC--- 1.00g                                                                           /dev/sdc1(0)        
[root@hayes-02 ~]# lvremove -f snapper_thinp
  Logical volume "POOL" successfully removed.

Comment 7 Corey Marthaler 2021-06-23 20:45:37 UTC
Fixed in the latest lvm build. Marking verified.

kernel-4.18.0-314.el8    BUILT: Tue Jun 15 11:04:32 CDT 2021
lvm2-2.03.12-4.el8    BUILT: Tue Jun 22 03:35:27 CDT 2021
lvm2-libs-2.03.12-4.el8    BUILT: Tue Jun 22 03:35:27 CDT 2021


SCENARIO - [display_thin_snap]
Create a snapshot and then display it a couple ways
Making pool volume
lvcreate --yes   --zero y -L 4M -n meta snapper_thinp /dev/sdc1 /dev/sde1
lvcreate --yes   --zero y -L 1G -n POOL snapper_thinp /dev/sdc1 /dev/sde1
lvcreate --yes  -L 400M -n wcpool snapper_thinp /dev/sdd1
lvchange -an snapper_thinp/wcpool
Converting *writecached* volume to thin pool data device
lvconvert --yes --type writecache --cachevol snapper_thinp/wcpool snapper_thinp/POOL
Create thin pool volume by combining the cached thin data and meta volumes
lvconvert --zero y --thinpool snapper_thinp/POOL --poolmetadata meta --yes
  WARNING: Converting snapper_thinp/POOL and snapper_thinp/meta to thin pool's data and metadata volumes with metadata wiping.
  THIS WILL DESTROY CONTENT OF LOGICAL VOLUME (filesystem etc.)

Making origin volume
lvcreate --yes  --virtualsize 1G -T snapper_thinp/POOL -n origin
lvcreate --yes  -V 1G -T snapper_thinp/POOL -n other1
  WARNING: Sum of all thin volume sizes (2.00 GiB) exceeds the size of thin pool snapper_thinp/POOL (1.00 GiB).
lvcreate --yes  -V 1G -T snapper_thinp/POOL -n other2
  WARNING: Sum of all thin volume sizes (3.00 GiB) exceeds the size of thin pool snapper_thinp/POOL (1.00 GiB).
lvcreate --yes  --virtualsize 1G -T snapper_thinp/POOL -n other3
  WARNING: Sum of all thin volume sizes (4.00 GiB) exceeds the size of thin pool snapper_thinp/POOL (1.00 GiB).
lvcreate --yes  --virtualsize 1G -T snapper_thinp/POOL -n other4
  WARNING: Sum of all thin volume sizes (5.00 GiB) exceeds the size of thin pool snapper_thinp/POOL (1.00 GiB).
lvcreate --yes  --virtualsize 1G -T snapper_thinp/POOL -n other5
  WARNING: Sum of all thin volume sizes (6.00 GiB) exceeds the size of thin pool snapper_thinp/POOL (1.00 GiB).
Making snapshot of origin volume
lvcreate --yes  -y -k n -s /dev/snapper_thinp/origin -n display_snap
Display snapshot using lvdisplay
Display snapshot using lvs
Display snapshot using lvscan
Removing snap volume snapper_thinp/display_snap
lvremove -f /dev/snapper_thinp/display_snap
Removing thin origin and other virtual thin volumes
Removing pool snapper_thinp/POOL

Comment 10 errata-xmlrpc 2021-11-09 19:45:54 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-2021:4431