Bug 1802683

Summary: should writecache volumes be allowed to be used as thin pool meta volumes if they're not allowed to be used for thin pool data volumes?
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.2   
Target Milestone: rc   
Target Release: 8.0   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: lvm2-2.03.08-2.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-04-28 16:59:23 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-02-13 17:28:22 UTC
Description of problem:
SCENARIO - [attempt_to_create_pool_from_already_writecached_vol]
Attempt to stack a writecache pool on top of a cache volume

*** Writecache info for this scenario ***
*  origin (slow):  /dev/sdg1
*  pool (fast):    /dev/sdh1
************************************

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

Create cache data and cache metadata (fast) volumes
lvcreate  -L 2G -n pool writecache_sanity @fast

Deactivte both fast and slow volumes before conversion to writecache
Create writecached volume by combining the cache pool (fast) and origin (slow) volumes
lvconvert --yes --type writecache --cachesettings ' low_watermark=49 high_watermark=77 writeback_jobs=1938 autocommit_blocks=2896 autocommit_time=2784' --cachevol writecache_sanity/pool writecache_sanity/stack1
Activating volume: stack1

lvcreate  -L 8M -n meta2 writecache_sanity /dev/sdh1

Attempt to create a new cache pool volume by combining an existing writecached volume and the new metadata volume
lvconvert --yes --type cache-pool --poolmetadata writecache_sanity/meta2 writecache_sanity/stack1
  Command on LV writecache_sanity/stack1 does not accept LV type writecache.
  Command not permitted on LV writecache_sanity/stack1.

# This *would* work if using dm-cache
Attempt to create a new thin pool volume by combining the existing writecached volume and the new metadata volume
lvconvert --yes --type thin-pool --poolmetadata writecache_sanity/meta2 writecache_sanity/stack1
  Command on LV writecache_sanity/stack1 does not accept LV type writecache.
  Command not permitted on LV writecache_sanity/stack1.

# If the above isn't supported, should writecache vols be allowed to be used as meta data devices then either?
Attempt to create a new thin pool volume by combining the existing writecached volume (as the meta device) and the new linear (named meta)
[root@hayes-02 ~]# lvconvert --yes --type thin-pool --poolmetadata writecache_sanity/stack1 writecache_sanity/meta2
  Thin pool volume with chunk size 64.00 KiB can address at most 15.81 TiB of data.
  WARNING: Converting writecache_sanity/meta2 and writecache_sanity/stack1 to thin pool's data and metadata volumes with metadata wiping.
  THIS WILL DESTROY CONTENT OF LOGICAL VOLUME (filesystem etc.)
  Converted writecache_sanity/meta2 and writecache_sanity/stack1 to thin pool.
[root@hayes-02 ~]# lvs -a -o +devices
  LV                   VG                Attr       LSize Pool        Origin               Data%  Meta% Cpy%Sync Convert Devices              
  [lvol0_pmspare]      writecache_sanity ewi------- 4.00g                                                                /dev/sdb1(0)         
  meta2                writecache_sanity twi-a-tz-- 8.00m                                  0.00   0.40                   meta2_tdata(0)       
  [meta2_tdata]        writecache_sanity Twi-ao---- 8.00m                                                                /dev/sdh1(512)       
  [meta2_tmeta]        writecache_sanity ewi-aoC--- 4.00g [pool_cvol] [meta2_tmeta_wcorig] 0.01                          meta2_tmeta_wcorig(0)
  [meta2_tmeta_wcorig] writecache_sanity owi-aoC--- 4.00g                                                                /dev/sdg1(0)         
  [pool_cvol]          writecache_sanity Cwi-aoC--- 2.00g                                                                /dev/sdh1(0)         


Version-Release number of selected component (if applicable):
kernel-4.18.0-173.el8    BUILT: Fri Jan 24 06:02:03 CST 2020
lvm2-2.03.08-1.el8    BUILT: Tue Feb 11 07:40:33 CST 2020
lvm2-libs-2.03.08-1.el8    BUILT: Tue Feb 11 07:40:33 CST 2020
device-mapper-1.02.169-1.el8    BUILT: Tue Feb 11 07:40:33 CST 2020
device-mapper-libs-1.02.169-1.el8    BUILT: Tue Feb 11 07:40:33 CST 2020
device-mapper-event-1.02.169-1.el8    BUILT: Tue Feb 11 07:40:33 CST 2020
device-mapper-event-libs-1.02.169-1.el8    BUILT: Tue Feb 11 07:40:33 CST 2020

Comment 1 Corey Marthaler 2020-02-13 22:56:19 UTC
Looks like the fact that this works is a fluke and needs to be restricted since the uncache and removal doesn't work.

[root@hayes-02 ~]# lvconvert --uncache writecache_sanity/stack1

[root@hayes-02 ~]# lvs -a -o +devices
  LV                   VG                Attr       LSize Pool        Origin               Data%  Meta%  Move Log Cpy%Sync Convert Devices
  [lvol0_pmspare]      writecache_sanity ewi------- 4.00g                                                                          /dev/sdb1(0)     
  meta2                writecache_sanity twi-a-tz-- 8.00m                                  0.00   0.40                             meta2_tdata(0)
  [meta2_tdata]        writecache_sanity Twi-ao---- 8.00m                                                                          /dev/sdc1(512)
  [meta2_tmeta]        writecache_sanity ewi-aoC--- 4.00g [pool_cvol] [meta2_tmeta_wcorig] 0.01                                    meta2_tmeta_wcorig(0)
  [meta2_tmeta_wcorig] writecache_sanity owi-aoC--- 4.00g                                                                          /dev/sdf1(0)
  [pool_cvol]          writecache_sanity Cwi-aoC--- 2.00g                                                                          /dev/sdc1(0)

[root@hayes-02 ~]# lvremove -f writecache_sanity
  LV segment meta2_tmeta:0-4294967295 is incorrectly listed as being used by LV pool_cvol
  Internal error: LV segments corrupted in pool_cvol.

Comment 2 David Teigland 2020-02-13 23:27:00 UTC
fix in master:
https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=db1d66859f8086467979b2d7e32843f70e4436e1

(When swapping, the thin code uses a whitelist of acceptable metadata LV types, but in this lvconvert case it uses a blacklist of unacceptable metadata LV types which is prone to breaking when new LV types are introduced.)

Comment 3 Marian Csontos 2020-02-24 16:21:11 UTC
Corey, could you ack please?

Comment 6 Corey Marthaler 2020-02-24 21:33:47 UTC
Fix verified in the latest rpms.

kernel-4.18.0-179.el8    BUILT: Fri Feb 14 17:03:01 CST 2020
lvm2-2.03.08-2.el8    BUILT: Mon Feb 24 11:21:38 CST 2020
lvm2-libs-2.03.08-2.el8    BUILT: Mon Feb 24 11:21:38 CST 2020
device-mapper-1.02.169-2.el8    BUILT: Mon Feb 24 11:21:38 CST 2020
device-mapper-libs-1.02.169-2.el8    BUILT: Mon Feb 24 11:21:38 CST 2020
device-mapper-event-1.02.169-2.el8    BUILT: Mon Feb 24 11:21:38 CST 2020
device-mapper-event-libs-1.02.169-2.el8    BUILT: Mon Feb 24 11:21:38 CST 2020



[root@hayes-02 ~]# lvs -a -o +devices
  LV              VG                Attr       LSize Pool        Origin          Data%  Meta%  Move Log Cpy%Sync Convert Devices         
  meta2           writecache_sanity -wi-a----- 8.00m                                                                     /dev/sdh1(0)    
  [pool_cvol]     writecache_sanity Cwi-aoC--- 2.00g                                                                     /dev/sdm1(0)    
  stack1          writecache_sanity Cwi-a-C--- 4.00g [pool_cvol] [stack1_wcorig] 0.00                                    stack1_wcorig(0)
  [stack1_wcorig] writecache_sanity owi-aoC--- 4.00g                                                                     /dev/sde1(0)    
[root@hayes-02 ~]# lvconvert --yes --type cache-pool --poolmetadata writecache_sanity/meta2 writecache_sanity/stack1
  Command on LV writecache_sanity/stack1 does not accept LV type writecache.
  Command not permitted on LV writecache_sanity/stack1.
[root@hayes-02 ~]# lvconvert --yes --type thin-pool --poolmetadata writecache_sanity/meta2 writecache_sanity/stack1
  Command on LV writecache_sanity/stack1 does not accept LV type writecache.
  Command not permitted on LV writecache_sanity/stack1.
[root@hayes-02 ~]# lvconvert --yes --type thin-pool --poolmetadata writecache_sanity/stack1 writecache_sanity/meta2
  Pool metadata LV writecache_sanity/stack1 is of an unsupported type.

Comment 8 errata-xmlrpc 2020-04-28 16:59:23 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, 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/RHEA-2020:1881