Bug 1160044

Summary: [RFE] LVM cache: Ability to resize cache origin volume
Product: Red Hat Enterprise Linux 8 Reporter: Jonathan Earl Brassow <jbrassow>
Component: lvm2Assignee: Zdenek Kabelac <zkabelac>
lvm2 sub component: Cache Logical Volumes QA Contact: cluster-qe <cluster-qe>
Status: CLOSED ERRATA Docs Contact:
Severity: unspecified    
Priority: medium CC: agk, cmackows, cmarthal, gsitlani, heinzm, jbrassow, jmagrini, mcsontos, msnitzer, nperic, pasik, prajnoha, rmadhuso, teigland, torkil, zkabelac
Version: 8.1Keywords: FutureFeature, RFE, Triaged
Target Milestone: rc   
Target Release: 8.2   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: lvm2-2.03.14-1.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1189111 1959609 (view as bug list) Environment:
Last Closed: 2022-05-10 15:21:57 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:
Bug Depends On:    
Bug Blocks: 1119326, 1186924, 1189111, 1959609    

Description Jonathan Earl Brassow 2014-11-03 22:17:15 UTC
It should be possible for a user to resize (at least grow) the various logical volumes under a cache LV - the origin, the CacheDataLV, and CacheMetadataLV.

Comment 13 Zdenek Kabelac 2021-02-09 13:30:16 UTC
Support for resize of cached LV   (_corigin) is now supported via Bug 1899720 Comment 1.

Comment 18 David Teigland 2021-05-06 16:27:20 UTC
Should this bug include extending an LV with attached writecache in addition to extending an LV with attached cache?  These appear to be the two commits in which cache and writecache extending were enabled:

https://sourceware.org/git/?p=lvm2.git;a=commit;h=5ec24dfb0bb0c9e48d59d6fbb83262a7087964e1
https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ac09fa08aa7a10cc3f807830de5d625d499ed1b1

commit 5ec24dfb0bb0c9e48d59d6fbb83262a7087964e1
Author: Zdenek Kabelac <zkabelac>
Date:   Sun Feb 7 20:12:00 2021 +0100

    lv_resize: support resizing of cached volumes
    
    Automatically figure out resizable layer in the LV stack and
    resize it online.
    
    Split check for reshaped raids and postpone removal of
    unused space after finished reshaping after metadata archiving.
    
    Drop warning about unsupported automatic resize of monitored thin-pool.
    
    Currently there is not yet support for resize of writecache.

commit ac09fa08aa7a10cc3f807830de5d625d499ed1b1
Author: Zdenek Kabelac <zkabelac>
Date:   Sat Feb 20 22:22:51 2021 +0100

    lvextend: enable resize of writecached LV


I suspect we'll need some further tests developed, though, since I'm not seeing much right now.  commit b86eb913c18ca67415521b8003c04adf41a5496c seems to just verify that the lvextend command permits a dm-cache to be extended when it's used for thin pool data.

Comment 20 David Teigland 2021-05-06 17:55:23 UTC
Created bug 1957892 for lvextend with writecache, so this bug is only for lvextend with cache.

Comment 21 David Teigland 2021-05-06 19:47:39 UTC
Created a new test "lvextend-caches" that tests lvextend of an LV with an attached cache|writecache:
https://sourceware.org/git/?p=lvm2.git;a=blob;f=test/shell/lvextend-caches.sh

Comment 22 Corey Marthaler 2021-05-11 14:50:15 UTC
Updating this RFE to reflect that in 8.5 this is about the ability to resize the cache origin volume, and not the internal cache pool volumes. 

[root@hayes-02 ~]# lvs -a -o +devices
  LV                 VG           Attr       LSize   Pool         Origin          Data%  Meta%  Move Log Cpy%Sync Convert Devices            
  corigin            cache_sanity owi-aoC---   5.95g [pool_cpool] [corigin_corig] 0.42   12.92           0.00             corigin_corig(0)   
  [corigin_corig]    cache_sanity owi-aoC---   5.95g                                                                      /dev/sdk1(0)       
  [lvol0_pmspare]    cache_sanity ewi-------  12.00m                                                                      /dev/sdb1(0)       
  online_resize      cache_sanity swi-a-s--- 500.00m              corigin         0.14                                    /dev/sdb1(3)       
  [pool_cpool]       cache_sanity Cwi---C---   4.00g                              0.42   12.92           0.00             pool_cpool_cdata(0)
  [pool_cpool_cdata] cache_sanity Cwi-ao----   4.00g                                                                      /dev/sdf1(0)       
  [pool_cpool_cmeta] cache_sanity ewi-ao----  12.00m                                                                      /dev/sdf1(1024)    

[root@hayes-02 ~]# lvextend -L +500M /dev/cache_sanity/corigin
  Size of logical volume cache_sanity/corigin_corig changed from 5.46 GiB (1399 extents) to 5.95 GiB (1524 extents).

[root@hayes-02 ~]# lvextend -L +500M -r /dev/cache_sanity/pool_cpool
  Can't resize internal logical volume cache_sanity/pool_cpool.
[root@hayes-02 ~]# lvextend -L +500M -r /dev/cache_sanity/pool_cpool_cdata
  Can't resize internal logical volume cache_sanity/pool_cpool_cdata.
[root@hayes-02 ~]# lvextend -L +500M -r /dev/cache_sanity/pool_cpool_cmeta
  Can't resize internal logical volume cache_sanity/pool_cpool_cmeta.

Comment 23 Corey Marthaler 2021-05-11 23:15:54 UTC
Bug 1959626 likely blocks the verification of this feature.

Comment 24 Corey Marthaler 2021-06-01 15:46:35 UTC
Marking Verified:Tested in the latest lvm rpms.

kernel-4.18.0-305.7.el8.kpq1    BUILT: Mon May 17 12:55:07 CDT 2021
lvm2-2.03.12-2.el8    BUILT: Tue Jun  1 06:55:37 CDT 2021
lvm2-libs-2.03.12-2.el8    BUILT: Tue Jun  1 06:55:37 CDT 2021
device-mapper-1.02.177-2.el8    BUILT: Tue Jun  1 06:55:37 CDT 2021
device-mapper-libs-1.02.177-2.el8    BUILT: Tue Jun  1 06:55:37 CDT 2021



SCENARIO - [open_XFS_on_cache_origin_fsadm_resize_attempts]
Create a cached XFS filesystem, mount it, snapshot it, and resize the ORIGIN while online

*** Cache info for this scenario ***
*  origin (slow):  /dev/sdf1
*  pool (fast):    /dev/sdj1
************************************

Adding "slow" and "fast" tags to corresponding pvs
Create origin (slow) volume
lvcreate --yes --wipesignatures y  -L 4G -n corigin cache_sanity @slow

Create cache data and cache metadata (fast) volumes
lvcreate --yes  -L 4G -n pool cache_sanity @fast
lvcreate --yes  -L 12M -n pool_meta cache_sanity @fast

Create cache pool volume by combining the cache data and cache metadata (fast) volumes with policy: mq  mode: writethrough
lvconvert --yes --type cache-pool --cachepolicy mq --cachemode writethrough -c 32 --poolmetadata cache_sanity/pool_meta cache_sanity/pool
  WARNING: Converting cache_sanity/pool and cache_sanity/pool_meta to cache pool's data and metadata volumes with metadata wiping.
  THIS WILL DESTROY CONTENT OF LOGICAL VOLUME (filesystem etc.)
Create cached volume by combining the cache pool (fast) and origin (slow) volumes
lvconvert --yes --type cache --cachemetadataformat 2 --cachepool cache_sanity/pool cache_sanity/corigin

Placing an XFS filesystem on origin volume
Mounting origin volume

Writing files to /mnt/corigin
Checking files on /mnt/corigin
Making snapshot of origin volume
lvcreate --yes  -s /dev/cache_sanity/corigin -c 16 -n online_resize -L 500M
Resize the open snapshoted ORIGIN XFS filesystem multiple times with lvextend/fsadm on hayes-01
RESIZING CACHE VOLUMES IS NOW SUPPORTED IN 8.5
(lvextend -L +500M -r /dev/cache_sanity/corigin)
FS: 3848 >= 4369
LV: 4194304.00 eq 4706304.00
Checking files on /mnt/corigin

(lvextend -L +500M -r /dev/cache_sanity/corigin)
FS: 4369 >= 4889
LV: 4706304.00 eq 5218304.00
Checking files on /mnt/corigin

(lvextend -L +500M -r /dev/cache_sanity/corigin)
FS: 4889 >= 5410
LV: 5218304.00 eq 5730304.00
Checking files on /mnt/corigin

(lvextend -L +500M -r /dev/cache_sanity/corigin)
FS: 5410 >= 5930
LV: 5730304.00 eq 6242304.00
Checking files on /mnt/corigin

(lvextend -L +500M -r /dev/cache_sanity/corigin)
FS: 5930 >= 6451
LV: 6242304.00 eq 6754304.00
Checking files on /mnt/corigin

(lvextend -L +500M -r /dev/cache_sanity/corigin)
FS: 6451 >= 6971
LV: 6754304.00 eq 7266304.00
Checking files on /mnt/corigin

(lvextend -L +500M -r /dev/cache_sanity/corigin)
FS: 6971 >= 7492
LV: 7266304.00 eq 7778304.00
Checking files on /mnt/corigin

(lvextend -L +500M -r /dev/cache_sanity/corigin)
FS: 7492 >= 8013
LV: 7778304.00 eq 8290304.00
Checking files on /mnt/corigin

(lvextend -L +500M -r /dev/cache_sanity/corigin)
FS: 8013 >= 8533
LV: 8290304.00 eq 8802304.00
Checking files on /mnt/corigin

(lvextend -L +500M -r /dev/cache_sanity/corigin)
FS: 8533 >= 9054
LV: 8802304.00 eq 9314304.00
Checking files on /mnt/corigin

Removing snap volume cache_sanity/online_resize
lvremove -f /dev/cache_sanity/online_resize
Uncaching cache origin (lvconvert --yes --uncache cache_sanity/corigin) from cache pool
Removing cache origin volume cache_sanity/corigin
lvremove -f /dev/cache_sanity/corigin

Comment 34 Corey Marthaler 2021-11-16 20:43:14 UTC
Marking Verified in the latest rpms.

kernel-4.18.0-348.4.el8.kpq0    BUILT: Wed Oct 27 15:00:32 CDT 2021
lvm2-2.03.14-1.el8    BUILT: Wed Oct 20 10:18:17 CDT 2021
lvm2-libs-2.03.14-1.el8    BUILT: Wed Oct 20 10:18:17 CDT 2021


SCENARIO - [open_EXT4_on_cache_origin_fsadm_resize_attempts]
Create a cached EXT4 filesystem, mount it, snapshot it, and resize the ORIGIN while online

*** Cache info for this scenario ***
*  origin (slow):  /dev/sde1
*  pool (fast):    /dev/sdj1
************************************

Adding "slow" and "fast" tags to corresponding pvs
Create origin (slow) volume
lvcreate --yes --wipesignatures y  -L 4G -n corigin cache_sanity @slow

Create cache data and cache metadata (fast) volumes
lvcreate --yes  -L 4G -n pool cache_sanity @fast
lvcreate --yes  -L 12M -n pool_meta cache_sanity @fast

Create cache pool volume by combining the cache data and cache metadata (fast) volumes with policy: cleaner  mode: writethrough
lvconvert --yes --type cache-pool --cachepolicy cleaner --cachemode writethrough -c 64 --poolmetadata cache_sanity/pool_meta cache_sanity/pool
  WARNING: Converting cache_sanity/pool and cache_sanity/pool_meta to cache pool's data and metadata volumes with metadata wiping.
  THIS WILL DESTROY CONTENT OF LOGICAL VOLUME (filesystem etc.)
Create cached volume by combining the cache pool (fast) and origin (slow) volumes
lvconvert --yes --type cache --cachemetadataformat 1 --cachepool cache_sanity/pool cache_sanity/corigin

Placing an EXT filesystem on origin volume
mke2fs 1.45.6 (20-Mar-2020)
Mounting origin volume

Writing files to /mnt/corigin
Checking files on /mnt/corigin
Making snapshot of origin volume
lvcreate --yes  -s /dev/cache_sanity/corigin -c 16 -n online_resize -L 500M
Resize the open snapshoted ORIGIN EXT4 filesystem multiple times with lvextend/fsadm on hayes-01
RESIZING CACHE VOLUMES IS NOW SUPPORTED IN 8.5
(lvextend -L +500M -r /dev/cache_sanity/corigin)
resize2fs 1.45.6 (20-Mar-2020)
FS: 3770 >= 4286
LV: 4194304.00 eq 4706304.00
Checking files on /mnt/corigin

(lvextend -L +500M -r /dev/cache_sanity/corigin)
resize2fs 1.45.6 (20-Mar-2020)
FS: 4286 >= 4802
LV: 4706304.00 eq 5218304.00
Checking files on /mnt/corigin

(lvextend -L +500M -r /dev/cache_sanity/corigin)
resize2fs 1.45.6 (20-Mar-2020)
FS: 4802 >= 5317
LV: 5218304.00 eq 5730304.00
Checking files on /mnt/corigin

(lvextend -L +500M -r /dev/cache_sanity/corigin)
resize2fs 1.45.6 (20-Mar-2020)
FS: 5317 >= 5833
LV: 5730304.00 eq 6242304.00
Checking files on /mnt/corigin

(lvextend -L +500M -r /dev/cache_sanity/corigin)
resize2fs 1.45.6 (20-Mar-2020)
FS: 5833 >= 6347
LV: 6242304.00 eq 6754304.00
Checking files on /mnt/corigin

(lvextend -L +500M -r /dev/cache_sanity/corigin)
resize2fs 1.45.6 (20-Mar-2020)
FS: 6347 >= 6863
LV: 6754304.00 eq 7266304.00
Checking files on /mnt/corigin

(lvextend -L +500M -r /dev/cache_sanity/corigin)
resize2fs 1.45.6 (20-Mar-2020)
WARNING: Heartbeat did not respond at start of command.  Check btimed service on remote host
FS: 6863 >= 7379
LV: 7266304.00 eq 7778304.00
Checking files on /mnt/corigin

(lvextend -L +500M -r /dev/cache_sanity/corigin)
resize2fs 1.45.6 (20-Mar-2020)
FS: 7379 >= 7895
LV: 7778304.00 eq 8290304.00
Checking files on /mnt/corigin

(lvextend -L +500M -r /dev/cache_sanity/corigin)
resize2fs 1.45.6 (20-Mar-2020)
FS: 7895 >= 8411
LV: 8290304.00 eq 8802304.00
Checking files on /mnt/corigin

(lvextend -L +500M -r /dev/cache_sanity/corigin)
resize2fs 1.45.6 (20-Mar-2020)
FS: 8411 >= 8926
LV: 8802304.00 eq 9314304.00
Checking files on /mnt/corigin

Removing snap volume cache_sanity/online_resize
lvremove -f /dev/cache_sanity/online_resize
Uncaching cache origin (lvconvert --yes --uncache cache_sanity/corigin) from cache pool
Removing cache origin volume cache_sanity/corigin
lvremove -f /dev/cache_sanity/corigin

Comment 36 errata-xmlrpc 2022-05-10 15:21:57 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-2022:2038