Bug 1957898

Summary: Allow thin-pool data to be extended when writecache is on top
Product: Red Hat Enterprise Linux 8 Reporter: David Teigland <teigland>
Component: lvm2Assignee: David Teigland <teigland>
lvm2 sub component: Cache Logical Volumes QA Contact: cluster-qe <cluster-qe>
Status: CLOSED ERRATA Docs Contact:
Severity: unspecified    
Priority: high CC: agk, cmarthal, heinzm, jbrassow, mcsontos, msnitzer, prajnoha, zkabelac
Version: 8.3Keywords: Triaged
Target Milestone: betaFlags: pm-rhel: mirror+
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: lvm2-2.03.12-4.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 David Teigland 2021-05-06 18:04:41 UTC
Description of problem:

With the ability to lvextend a writecache LV (in bug 1957892), we can now allow writecache to be used for thin pool data.

See bug 1899720 for the related RFE to use cache for thin pool data.


Version-Release number of selected component (if applicable):


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 1 David Teigland 2021-05-06 21:34:47 UTC
added in
https://sourceware.org/git/?p=lvm2.git;a=commit;h=6b00c8c9109b0b6111d4adb9918cccc407ac448f

added new test for lvextend of thin pool data with both cache and writecache attached:
https://sourceware.org/git/?p=lvm2.git;a=blob;f=test/shell/lvextend-caches-on-thindata.sh

Comment 2 Corey Marthaler 2021-05-19 01:28:33 UTC
These are the basic two scenarios to be tested here correct? First, that a wc origin volume can even be used as a thinpool volume, and Second, that it can be extend?

[root@host-086 ~]# lvcreate --yes --wipesignatures y -ay  -L 1G -n wc_origin test
  Logical volume "wc_origin" created.
[root@host-086 ~]# lvcreate --yes -ay -L 500M -n wc_pool test /dev/sdc
  Logical volume "wc_pool" created.
[root@host-086 ~]# lvchange -an test/wc_pool
[root@host-086 ~]# lvconvert --yes --type writecache --cachevol test/wc_pool test/wc_origin
  Using writecache block size 512 for unknown file system block size, logical block size 512, physical block size 512.
  Logical volume test/wc_origin now has writecache.
[root@host-086 ~]# lvs -a -o +devices
  LV                 VG            Attr       LSize   Pool           Origin             Data%  Meta%  Move Log Cpy%Sync Convert Devices            
  wc_origin          test          Cwi-a-C---   1.00g [wc_pool_cvol] [wc_origin_wcorig] 0.00                                    wc_origin_wcorig(0)
  [wc_origin_wcorig] test          owi-aoC---   1.00g                                                                           /dev/sdb(0)        
  [wc_pool_cvol]     test          Cwi-aoC--- 500.00m                                                                           /dev/sdc(0)        

[root@host-086 ~]# lvcreate --yes  --profile thin-performance --zero y -L 4M -n meta test /dev/sdd
  Logical volume "meta" created.

# basic test 1
[root@host-086 ~]# lvconvert --zero y --thinpool test/wc_origin --poolmetadata meta --yes
  LV test/wc_origin with type writecache cannot be used as a thin pool LV.

# basic test 2
[root@host-086 ~]# lvextend -L +1G test/wc_origin_tdata
  Logical volume wc_origin_tdata not found in volume group test.

Comment 3 David Teigland 2021-05-19 19:27:21 UTC
(In reply to Corey Marthaler from comment #2)
> These are the basic two scenarios to be tested here correct? First, that a
> wc origin volume can even be used as a thinpool volume, and Second, that it
> can be extend?

Correct.

> # basic test 1
> [root@host-086 ~]# lvconvert --zero y --thinpool test/wc_origin
> --poolmetadata meta --yes
>   LV test/wc_origin with type writecache cannot be used as a thin pool LV.

OK, too many ways to do the same thing, I'd been attaching a writecache to an existing thin pool data, i.e.
lvconvert --type thin-pool test/main
lvconvert --type writecache --cachevol fast test/main

I'll enable the other way around, converting an LV to a thin pool while it has a writecache attached, i.e.
lvconvert --type writecache --cachevol fast test/main
lvconvert --type thin-pool test/main

(BTW, I've just found a new bug that prevents lvremove of this thing once you've created it.)

> # basic test 2
> [root@host-086 ~]# lvextend -L +1G test/wc_origin_tdata
>   Logical volume wc_origin_tdata not found in volume group test.

use the thin pool name without _tdata, for better or worse, the existing tradition seems to assume you mean the data sub LV.

# lvs test
  LV   VG   Attr       LSize   
  main test twi---tz-- 128.00m

# lvs -a test
  LV                  VG   Attr       LSize   Pool        Origin              
  [fast_cvol]         test Cwi---C--- 128.00m                                
  [lvol0_pmspare]     test ewi-------   4.00m                                
  main                test twi---tz-- 128.00m                                
  [main_tdata]        test Cwi---C--- 128.00m [fast_cvol] [main_tdata_wcorig]
  [main_tdata_wcorig] test owi---C--- 128.00m                                
  [main_tmeta]        test ewi-------   4.00m                                

# lvextend -L+128M test/main
  Size of logical volume test/main_tdata_wcorig changed from 128.00 MiB (32 extents) to 256.00 MiB (64 extents).
  Logical volume test/main successfully resized.

# lvs -a test
  LV                  VG   Attr       LSize   Pool        Origin              
  [fast_cvol]         test Cwi---C--- 128.00m                                
  [lvol0_pmspare]     test ewi-------   4.00m                                
  main                test twi---tz-- 256.00m                                
  [main_tdata]        test Cwi---C--- 256.00m [fast_cvol] [main_tdata_wcorig]
  [main_tdata_wcorig] test owi---C--- 256.00m                                
  [main_tmeta]        test ewi-------   4.00m

Comment 4 David Teigland 2021-05-24 21:16:04 UTC
fix to allow converting an LV with a writecache to a thin pool:
https://sourceware.org/git/?p=lvm2.git;a=commit;h=a65f8e0a62b9ab3c2fc909a63abfa0e933619a8c

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


# lvcreate -n main -L1G -an test /dev/sdd
  WARNING: Logical volume test/main not zeroed.
  Logical volume "main" created.

# lvcreate -n fast -L128M -an test /dev/sde
  WARNING: Logical volume test/fast not zeroed.
  Logical volume "fast" created.

# lvconvert --type writecache --cachevol fast test/main
Erase all existing data on test/fast? [y/n]: y
  Using writecache block size 512 for unknown file system block size, logical block size 512, physical block size 512.
  Logical volume test/main now has writecache.

# lvs -a test
  LV            VG   Attr       LSize   Pool        Origin        
  [fast_cvol]   test Cwi---C--- 128.00m                          
  main          test Cwi---C---   1.00g [fast_cvol] [main_wcorig]
  [main_wcorig] test owi---C---   1.00g                          

# lvconvert --type thin-pool test/main
  Thin pool volume with chunk size 64.00 KiB can address at most <15.88 TiB of data.
  WARNING: Converting test/main to thin pool's data volume with metadata wiping.
  THIS WILL DESTROY CONTENT OF LOGICAL VOLUME (filesystem etc.)
Do you really want to convert test/main? [y/n]: y
  Converted test/main to thin pool.

# lvs -a test
  LV                  VG   Attr       LSize   Pool        Origin              
  [fast_cvol]         test Cwi---C--- 128.00m                                
  [lvol0_pmspare]     test ewi-------   4.00m                                
  main                test twi---tz--   1.00g                                
  [main_tdata]        test Cwi---C---   1.00g [fast_cvol] [main_tdata_wcorig]
  [main_tdata_wcorig] test owi---C---   1.00g                                
  [main_tmeta]        test ewi-------   4.00m                                

# lvremove test/main
  Logical volume "main" successfully removed.

Comment 8 Corey Marthaler 2021-06-15 19:38:00 UTC
Marian, this may still need the additional fix mentioned in comment #4?

Bug 1964622, or "fix to allow removing a thin pool that has writecache on the data LV" is fixed now in lvm2-2.03.12-3, however it appears the "fix to allow converting an LV with a writecache to a thin pool" is not in lvm2-2.03.12-3.


# WRITECACHE TO THINPOOL
[root@hayes-01 ~]# lvcreate --yes  --profile thin-performance --zero y -L 4M -n meta snapper_thinp /dev/sdb1 /dev/sdd1
  Logical volume "meta" created.
[root@hayes-01 ~]# lvcreate --yes  --profile thin-performance --zero y -L 1G -n POOL snapper_thinp /dev/sdb1 /dev/sdd1
  Logical volume "POOL" created.
[root@hayes-01 ~]# lvcreate --yes  -L 1G -n wcpool snapper_thinp /dev/sdc1
  Logical volume "wcpool" created.
[root@hayes-01 ~]# lvchange -an snapper_thinp/wcpool
[root@hayes-01 ~]# # Create writecached volume by combining the cache pool (fast) and origin (slow) volumes
[root@hayes-01 ~]# 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 512.
  Logical volume snapper_thinp/POOL now has writecache.
[root@hayes-01 ~]# lvs -a -o +devices,segtype
  LV            VG            Attr       LSize Pool          Origin        Data%  Meta%  Move Log Cpy%Sync Convert Devices        Type
  POOL          snapper_thinp Cwi-a-C--- 1.00g [wcpool_cvol] [POOL_wcorig] 0.00                                    POOL_wcorig(0) writecache
  [POOL_wcorig] snapper_thinp owi-aoC--- 1.00g                                                                     /dev/sdb1(1)   linear
  meta          snapper_thinp -wi-a----- 4.00m                                                                     /dev/sdb1(0)   linear
  [wcpool_cvol] snapper_thinp Cwi-aoC--- 1.00g                                                                     /dev/sdc1(0)   linear
[root@hayes-01 ~]# # Create thin pool volume by combining the cached thin data and meta volumes
[root@hayes-01 ~]# lvconvert --zero y --thinpool snapper_thinp/POOL --poolmetadata meta --yes
  LV snapper_thinp/POOL with type writecache cannot be used as a thin pool LV.

Comment 9 Marian Csontos 2021-06-17 14:27:02 UTC
Both patches from comment 4 are included in the lvm2-2.03.12-3, so this might need something else. David could you have a look, please?

Comment 10 David Teigland 2021-06-17 15:35:16 UTC
You're probably missing this one:

https://sourceware.org/git/?p=lvm2.git;a=commit;h=6b00c8c9109b0b6111d4adb9918cccc407ac448f

writecache: allow attaching to thin pool data

Comment 11 David Teigland 2021-06-17 15:37:02 UTC
(In reply to David Teigland from comment #10)
> You're probably missing this one:
> 
> https://sourceware.org/git/?p=lvm2.git;a=commit;
> h=6b00c8c9109b0b6111d4adb9918cccc407ac448f
> 
> writecache: allow attaching to thin pool data

Sorry, it looks like that one is already listed in comment 1, so maybe there's something else.

Comment 12 David Teigland 2021-06-17 15:44:55 UTC
> # lvconvert --zero y --thinpool snapper_thinp/POOL --poolmetadata meta --yes
> LV snapper_thinp/POOL with type writecache cannot be used as a thin pool LV.

That command, were "POOL" already has a writecache attached to it, should be enabled by this commit:

https://sourceware.org/git/?p=lvm2.git;a=commit;h=a65f8e0a62b9ab3c2fc909a63abfa0e933619a8c

commit a65f8e0a62b9ab3c2fc909a63abfa0e933619a8c
Author: David Teigland <teigland>
Date:   Wed May 19 14:36:40 2021 -0500

    enable command syntax for thin and writecache
    
    converting an LV with a writecache to thin pool data in
    addition to previous attaching writecache to thin pool data

diff --git a/tools/command-lines.in b/tools/command-lines.in
index 1107c1e026e1..67c37ffd033b 100644
--- a/tools/command-lines.in
+++ b/tools/command-lines.in
@@ -534,7 +534,7 @@ RULE: all and lv_is_visible
 
 ---
 
-lvconvert --type thin-pool LV_linear_striped_raid_cache_error_zero
+lvconvert --type thin-pool LV_linear_striped_raid_cache_writecache_error_zero
 OO: --stripes_long Number, --stripesize SizeKB,
 OO_LVCONVERT_THINPOOL, OO_LVCONVERT_POOL, OO_LVCONVERT
 OP: PV ...
@@ -566,7 +566,7 @@ RULE: --poolmetadata not --readahead --stripesize --stripes_long
 # This command syntax is deprecated, and the primary forms
 # of creating a pool or swapping metadata should be used.
 
-lvconvert --thinpool LV_linear_striped_raid_cache_thinpool
+lvconvert --thinpool LV_linear_striped_raid_cache_writecache_thinpool
 OO: --stripes_long Number, --stripesize SizeKB,
 OO_LVCONVERT_THINPOOL, OO_LVCONVERT_POOL, OO_LVCONVERT
 OP: PV ...


Corey, could you check the lvconvert --help output and see if that command definition includes "writecache"?

Comment 13 Corey Marthaler 2021-06-17 20:02:15 UTC
lvm2-2.03.12-3.el8    BUILT: Tue Jun 15 11:37:17 CDT 2021


[root@hayes-01 ~]# lvconvert --help 2>&1 | grep writecache
  Attach a writecache to an LV, converts the LV to type writecache.
  lvconvert --type writecache --cachevol LV LV
  Add a writecache to an LV, using a specified cache device.
  lvconvert --type writecache --cachedevice PV LV

Comment 14 David Teigland 2021-06-17 21:05:04 UTC
Confirmed the problem.  The patch correctly updated the two equivalent command forms:

  lvconvert --type thin-pool LV
  lvconvert --thinpool LV

to permit LV with writecache.

However, in comment 4 I only tested the first, traditional, command form, and never ran the second.  It turns out that the lvconvert code has an extra type check that is used only for the second command form.  That type check needs to be corrected.

Comment 15 David Teigland 2021-06-17 21:20:38 UTC
fix for error in comment 8:
https://sourceware.org/git/?p=lvm2.git;a=commit;h=c35f7722d588009edad22d59c68c82150bb5c216

# lvcreate -n main -L64M -an ram /dev/ram0
  WARNING: Logical volume ram/main not zeroed.
  Logical volume "main" created.

# lvcreate -n fast -L64M -an ram /dev/ram1
  WARNING: Logical volume ram/fast not zeroed.
  Logical volume "fast" created.

# lvconvert --type writecache --cachevol fast ram/main
Erase all existing data on ram/fast? [y/n]: y
  Using writecache block size 512 for unknown file system block size, logical block size 512, physical block size 4096.
  Logical volume ram/main now has writecache.

# lvs -a ram
  LV            VG  Attr       LSize  Pool        Origin        
  [fast_cvol]   ram Cwi---C--- 64.00m                          
  main          ram Cwi---C--- 64.00m [fast_cvol] [main_wcorig]
  [main_wcorig] ram owi---C--- 64.00m                          

# lvconvert --thinpool ram/main
  Thin pool volume with chunk size 64.00 KiB can address at most 15.88 TiB of data.
  WARNING: Converting ram/main to thin pool's data volume with metadata wiping.
  THIS WILL DESTROY CONTENT OF LOGICAL VOLUME (filesystem etc.)
Do you really want to convert ram/main? [y/n]: y
  Converted ram/main to thin pool.

# lvs -a ram
  LV                  VG  Attr       LSize  Pool        Origin              
  [fast_cvol]         ram Cwi---C--- 64.00m                                
  [lvol0_pmspare]     ram ewi-------  4.00m                                
  main                ram twi---tz-- 64.00m                                
  [main_tdata]        ram Cwi---C--- 64.00m [fast_cvol] [main_tdata_wcorig]
  [main_tdata_wcorig] ram owi---C--- 64.00m                                
  [main_tmeta]        ram ewi-------  4.00m

Comment 16 Corey Marthaler 2021-06-24 02:58:21 UTC
Marking Verified:Tested in the latest rpms.

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


[root@hayes-03 ~]# lvcreate --yes  --profile thin-performance --zero y -L 4M -n meta snapper_thinp /dev/sde1 /dev/sdd1
  Logical volume "meta" created.
[root@hayes-03 ~]# lvcreate --yes  --profile thin-performance --zero y -L 1G -n POOL snapper_thinp /dev/sde1 /dev/sdd1
  Logical volume "POOL" created.
[root@hayes-03 ~]# lvcreate --yes  -L 1G -n wcpool snapper_thinp /dev/sdc1
  Logical volume "wcpool" created.

[root@hayes-03 ~]# lvchange -an snapper_thinp/wcpool
[root@hayes-03 ~]# 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-03 ~]# lvconvert --zero y --thinpool snapper_thinp/POOL --poolmetadata meta --yes
  Thin pool volume with chunk size 64.00 KiB can address at most <15.88 TiB of data.
  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.)
  Converted snapper_thinp/POOL and snapper_thinp/meta to thin pool.
[root@hayes-03 ~]# lvs -a -o +devices,segtype
  LV                  VG            Attr       LSize Pool          Origin              Data%  Meta%  Move Log Cpy%Sync Convert Devices              Type      
  POOL                snapper_thinp twi-a-tz-- 1.00g                                   0.00   10.94                            POOL_tdata(0)        thin-pool 
  [POOL_tdata]        snapper_thinp Cwi-aoC--- 1.00g [wcpool_cvol] [POOL_tdata_wcorig] 0.00                                    POOL_tdata_wcorig(0) writecache
  [POOL_tdata_wcorig] snapper_thinp owi-aoC--- 1.00g                                                                           /dev/sde1(1)         linear    
  [POOL_tmeta]        snapper_thinp ewi-ao---- 4.00m                                                                           /dev/sde1(0)         linear    
  [lvol0_pmspare]     snapper_thinp ewi------- 4.00m                                                                           /dev/sdc1(256)       linear    
  [wcpool_cvol]       snapper_thinp Cwi-aoC--- 1.00g                                                                           /dev/sdc1(0)         linear    

[root@hayes-03 ~]# lvextend -L +1G snapper_thinp/POOL_tdata
  Size of logical volume snapper_thinp/POOL_tdata_wcorig changed from 1.00 GiB (256 extents) to 2.00 GiB (512 extents).
  Logical volume snapper_thinp/POOL successfully resized.
[root@hayes-03 ~]# lvs -a -o +devices
  LV                  VG            Attr       LSize Pool          Origin              Data%  Meta%  Move Log Cpy%Sync Convert Devices             
  POOL                snapper_thinp twi-a-tz-- 2.00g                                   0.00   11.04                            POOL_tdata(0)       
  [POOL_tdata]        snapper_thinp Cwi-aoC--- 2.00g [wcpool_cvol] [POOL_tdata_wcorig] 0.00                                    POOL_tdata_wcorig(0)
  [POOL_tdata_wcorig] snapper_thinp owi-aoC--- 2.00g                                                                           /dev/sde1(1)        
  [POOL_tmeta]        snapper_thinp ewi-ao---- 4.00m                                                                           /dev/sde1(0)        
  [lvol0_pmspare]     snapper_thinp ewi------- 4.00m                                                                           /dev/sdc1(256)      
  [wcpool_cvol]       snapper_thinp Cwi-aoC--- 1.00g                                                                           /dev/sdc1(0)

Comment 20 Corey Marthaler 2021-07-07 21:07:52 UTC
Marking Verified in the latest kernel/rpms. Thinp + writecache extension regression scenarios passed.

kernel-4.18.0-319.el8    BUILT: Mon Jun 28 20:52:51 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

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