Bug 1909699

Summary: Thin-pool using ~16GB of metadata uses different limit for lvm2 and thin tools
Product: Red Hat Enterprise Linux 8 Reporter: nikhil kshirsagar <nkshirsa>
Component: lvm2Assignee: Zdenek Kabelac <zkabelac>
lvm2 sub component: Thin Provisioning QA Contact: cluster-qe <cluster-qe>
Status: CLOSED ERRATA Docs Contact:
Severity: medium    
Priority: urgent CC: agk, bubrown, cluster-qe, cmarthal, heinzm, jbrassow, ldigby, loberman, mcsontos, mgandhi, msnitzer, nkshirsa, nweddle, prajnoha, revers, rhandlin, thornber, zkabelac
Version: 8.2Keywords: Triaged
Target Milestone: rc   
Target Release: 8.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: lvm2-2.03.11-3.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1441153 Environment:
Last Closed: 2021-05-18 15:02:04 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: 1441153    
Bug Blocks: 1899798    

Comment 1 Zdenek Kabelac 2021-02-01 14:42:10 UTC
Solved upstream with these patches:

https://www.redhat.com/archives/lvm-devel/2021-February/msg00001.html
https://www.redhat.com/archives/lvm-devel/2021-February/msg00002.html
https://www.redhat.com/archives/lvm-devel/2021-February/msg00003.html

tested in lvm2 test suite:

https://www.redhat.com/archives/lvm-devel/2021-February/msg00010.html

----

Initial support for thin-pool used slightly smaller max size 15.81GiB
for thin-pool metadata. However the real limit later settled at 15.88GiB
(difference is ~64MiB - 16448 4K blocks).

lvm2 could not simply increase the size as it has been using hard cropping
of the loaded metadata device to avoid warnings printing warning of kernel
when the size was bigger (i.e. due to bigger extent_size).

This patch adds the new lvm.conf configurable setting:
allocation/thin_pool_crop_metadata
which defaults to 0 -> no crop of metadata beyond 15.81GiB.
Only user with these sizes of metadata will be affected.

Without cropping lvm2 now limits metadata allocation size to 15.88GiB.
Any space beyond is currently not used by thin-pool target.
Even if i.e. bigger LV is used for metadata via lvconvert,
or allocated bigger because of to large extent size.

With cropping enabled (=1) lvm2 preserves the old limitation
15.81GiB and should allow to work in the evironement with
older lvm2 tools (i.e. older distribution).

Thin-pool metadata with size bigger then 15.81G is now using CROP_METADATA
flag within lvm2 metadata, so older lvm2 recognizes an
incompatible thin-pool and cannot activate such pool!

Users should use uncropped version as it is not suffering
from various issues between thin_repair results and allocated
metadata LV as thin_repair limit is 15.88GiB
Users should use cropping only when really needed!

Patch also better handles resize of thin-pool metadata and prevents resize
beoyond usable size 15.88GiB. Resize beyond 15.81GiB automatically
switches pool to no-crop version. Even with existing bigger thin-pool
metadata command 'lvextend -l+1 vg/pool_tmeta' does the change.

Patch gives better controls 'coverted' metadata LV and
reports less confusing message during conversion.

Patch set also moves the code for updating min/max into pool_manip.c
for better sharing with cache_pool code.

Comment 2 Zdenek Kabelac 2021-02-01 15:12:43 UTC
*** Bug 1681968 has been marked as a duplicate of this bug. ***

Comment 3 Zdenek Kabelac 2021-02-01 15:31:58 UTC
*** Bug 1899798 has been marked as a duplicate of this bug. ***

Comment 8 Corey Marthaler 2021-02-16 22:44:35 UTC
Fix verified in the latest rpms.

kernel-4.18.0-287.el8    BUILT: Thu Feb 11 03:15:20 CST 2021
lvm2-2.03.11-4.el8    BUILT: Thu Feb 11 04:35:23 CST 2021
lvm2-libs-2.03.11-4.el8    BUILT: Thu Feb 11 04:35:23 CST 2021

[root@hayes-03 ~]# vgcreate tpvg /dev/sd[bcd]1
  Volume group "tpvg" successfully created
[root@hayes-03 ~]# vgs
  VG   #PV #LV #SN Attr   VSize  VFree 
  tpvg   3   0   0 wz--n- <1.31t <1.31t
[root@hayes-03 ~]# lvcreate -n pool0 -L 50G tpvg
  Logical volume "pool0" created.
[root@hayes-03 ~]# lvcreate -n pool0meta -L 10G tpvg
  Logical volume "pool0meta" created.
[root@hayes-03 ~]# lvconvert --type thin-pool --poolmetadata tpvg/pool0meta tpvg/pool0
  Thin pool volume with chunk size 64.00 KiB can address at most <15.88 TiB of data.
  WARNING: Converting tpvg/pool0 and tpvg/pool0meta to thin pool's data and metadata volumes with metadata wiping.
  THIS WILL DESTROY CONTENT OF LOGICAL VOLUME (filesystem etc.)
Do you really want to convert tpvg/pool0 and tpvg/pool0meta? [y/n]: y
  Converted tpvg/pool0 and tpvg/pool0meta to thin pool.
[root@hayes-03 ~]# lvcreate -n thin1 -V 1T --thinpool pool0 tpvg
  WARNING: Sum of all thin volume sizes (1.00 TiB) exceeds the size of thin pool tpvg/pool0 (50.00 GiB).
  WARNING: You have not turned on protection against thin pools running out of space.
  WARNING: Set activation/thin_pool_autoextend_threshold below 100 to trigger automatic extension of thin pools before they get full.
  Logical volume "thin1" created.

[root@hayes-03 ~]# lvs -a -o +devices
  LV              VG   Attr       LSize  Pool  Origin Data%  Meta%  Move Log Cpy%Sync Convert Devices         
  [lvol0_pmspare] tpvg ewi------- 10.00g                                                      /dev/sdb1(15360)
  pool0           tpvg twi-aotz-- 50.00g              0.00   0.16                             pool0_tdata(0)  
  [pool0_tdata]   tpvg Twi-ao---- 50.00g                                                      /dev/sdb1(0)    
  [pool0_tmeta]   tpvg ewi-ao---- 10.00g                                                      /dev/sdb1(12800)
  thin1           tpvg Vwi-a-tz--  1.00t pool0        0.00
                                                    
[root@hayes-03 ~]# lvextend --poolmetadatasize 16G tpvg/pool0
  Reached maximum pool metadata size <15.88 GiB (4065 extents).
  Thin pool will use metadata without cropping.
  WARNING: Sum of all thin volume sizes (1.00 TiB) exceeds the size of thin pools (50.00 GiB).
  WARNING: You have not turned on protection against thin pools running out of space.
  WARNING: Set activation/thin_pool_autoextend_threshold below 100 to trigger automatic extension of thin pools before they get full.
  Size of logical volume tpvg/pool0_tmeta changed from 10.00 GiB (2560 extents) to <15.88 GiB (4065 extents).
  Logical volume tpvg/pool0_tmeta successfully resized.

[root@hayes-03 ~]# lvs -a -o +devices,seg_pe_ranges
  LV              VG   Attr       LSize   Pool  Origin Data%  Meta%  Move Log Cpy%Sync Convert Devices          PE Ranges            
  [lvol0_pmspare] tpvg ewi------- <15.88g                                                      /dev/sdb1(15360) /dev/sdb1:15360-17919
  [lvol0_pmspare] tpvg ewi------- <15.88g                                                      /dev/sdb1(19425) /dev/sdb1:19425-20929
  pool0           tpvg twi-aotz--  50.00g              0.00   0.11                             pool0_tdata(0)   pool0_tdata:0-12799  
  [pool0_tdata]   tpvg Twi-ao----  50.00g                                                      /dev/sdb1(0)     /dev/sdb1:0-12799    
  [pool0_tmeta]   tpvg ewi-ao---- <15.88g                                                      /dev/sdb1(12800) /dev/sdb1:12800-15359
  [pool0_tmeta]   tpvg ewi-ao---- <15.88g                                                      /dev/sdb1(17920) /dev/sdb1:17920-19424
  thin1           tpvg Vwi-a-tz--   1.00t pool0        0.00                                                                          

Feb 16 16:21:16 hayes-03 kernel: device-mapper: thin: Data device (dm-1) discard unsupported: Disabling discard passdown.
Feb 16 16:21:16 hayes-03 systemd[1]: Started Device-mapper event daemon.
Feb 16 16:21:16 hayes-03 dmeventd[27734]: dmeventd ready for processing.
Feb 16 16:21:16 hayes-03 lvm[27734]: Monitoring thin pool tpvg-pool0.
Feb 16 16:21:39 hayes-03 dmeventd[27734]: No longer monitoring thin pool tpvg-pool0.
Feb 16 16:21:40 hayes-03 kernel: device-mapper: thin: Data device (dm-1) discard unsupported: Disabling discard passdown.
Feb 16 16:21:40 hayes-03 lvm[27734]: Monitoring thin pool tpvg-pool0-tpool.
Feb 16 16:21:56 hayes-03 dmeventd[27734]: No longer monitoring thin pool tpvg-pool0-tpool.
Feb 16 16:21:56 hayes-03 kernel: device-mapper: thin: 253:2: growing the metadata device from 2621440 to 4161600 blocks
Feb 16 16:21:56 hayes-03 lvm[27734]: Monitoring thin pool tpvg-pool0-tpool.

Comment 10 errata-xmlrpc 2021-05-18 15:02:04 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:1659