Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 2059644

Summary: request for memory usage warning when setting up dm-writecache
Product: Red Hat Enterprise Linux 9 Reporter: John Pittman <jpittman>
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, cmarthal, djeffery, heinzm, jbrassow, mcsontos, msnitzer, prajnoha, teigland, zkabelac
Version: 9.0Keywords: FutureFeature, Triaged
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: lvm2-2.03.16-1.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 2095490 2095492 (view as bug list) Environment:
Last Closed: 2022-11-15 11:20:43 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: 2095490, 2095492    

Description John Pittman 2022-03-01 15:50:43 UTC
Description of problem:

When larger dm-writecache devices are created, memory usage may be excessive and unexpected.  Requesting some calculation at lvcreate time to say "warning, this will take up x memory, if you have less than y total memory, you may need to think about adding additional ram".  This is just a suggestion, other warning ideas may be better.

Also requesting the presence of the large memory footprint be added to the lvm documentation.

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

lvm2-2.03.12-10.el8.

How reproducible:

Every time

Steps to Reproduce:

Create large dm-writecache device.  Observe memory use.

Actual results:

Large memory use.

Expected results:

If large memory use is expected, there should be a warning at lvcreate and also a mention in the documentation.

Comment 1 David Teigland 2022-03-01 17:45:24 UTC
(Moving this to RHEL9 as a new feature which can then be backported to RHEL8.)

This same thing was requested by Corey in bug 1855038 (which was autoclosed.)

When setting up writecache, if the cachevol size is > 50% of main memory, I'll have it print:
WARNING: writecache will use X GiB of system memory (Y GiB).

And if the cachevol size is > 90% of memory, I'll follow this warning with a confirmation prompt:
Continue to use writecache? [y/n]


I've already added the following to lvmcache(7) man page:

   dm-writecache memory usage
       The amount of main system memory used by dm-writecache can be a factor
       when selecting the writecache cachevol size and the writecache block
       size.

       • writecache block size 4096: each 100 GiB of writecache cachevol uses
         slighly over 2 GiB of system memory.

       • writecache block size 512: each 100 GiB of writecache cachevol uses a
         little over 16 GiB of system memory.

Comment 2 David Teigland 2022-03-02 17:55:51 UTC
man page update:
https://sourceware.org/git/?p=lvm2.git;a=commit;h=6144dac897728a4857294d70645df8ed7a5ff11f
lvconvert warning:
https://sourceware.org/git/?p=lvm2.git;a=commit;h=bef1363c0064f42e8063571143a428ad163d1bd9

# lvconvert --type writecache --cachevol fast2 test/main
Erase all existing data on test/fast2? [y/n]: y
  WARNING: writecache size 400.00 GiB will use 8 GiB of system memory (15 GiB).
  Logical volume test/main now has writecache.

# lvconvert --type writecache --cachevol fast2 test/main
Erase all existing data on test/fast2? [y/n]: y
  WARNING: writecache size 700.00 GiB will use 15 GiB of system memory (15 GiB).
Continue adding writecache? [y/n]: n
  Conversion aborted.

Comment 8 Corey Marthaler 2022-07-15 02:18:44 UTC
Marking Verified:Tested in the latest rpms.

# RHEL9.1 

kernel-5.14.0-127.el9    BUILT: Sat Jul  9 06:54:36 AM CDT 2022
lvm2-2.03.16-2.el9    BUILT: Thu Jul 14 11:45:18 AM CDT 2022
lvm2-libs-2.03.16-2.el9    BUILT: Thu Jul 14 11:45:18 AM CDT 2022

   dm-writecache memory usage
       The amount of main system memory used by dm-writecache can be a factor when selecting the writecache cachevol size and the writecache block size.

       ⢠writecache block size 4096: each 100 GiB of writecache cachevol uses slighly over 2 GiB of system memory.

       ⢠writecache block size 512: each 100 GiB of writecache cachevol uses a little over 16 GiB of system memory.


[root@hayes-03 ~]# lvs -a -o +devices
  LV    VG         Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert Devices
  wc_lv vdo_sanity -wi-a----- 2.00t                                                     /dev/sdi1(142467)
  wc_lv vdo_sanity -wi-a----- 2.00t                                                     /dev/sde1(0)
  wc_lv vdo_sanity -wi-a----- 2.00t                                                     /dev/sdd1(0)
  write vdo_sanity -wi------- 6.00t                                                     /dev/sdf1(0)
  write vdo_sanity -wi------- 6.00t                                                     /dev/sdg1(0)
  write vdo_sanity -wi------- 6.00t                                                     /dev/sdh1(0)    
  write vdo_sanity -wi------- 6.00t                                                     /dev/sdi1(0)

[root@hayes-03 ~]# lvconvert --yes --type writecache --cachevol vdo_sanity/write vdo_sanity/wc_lv
  Using writecache block size 4096 for unknown file system block size, logical block size 512, physical block size 4096.
  WARNING: unable to detect a file system block size on vdo_sanity/wc_lv
  WARNING: using a writecache block size larger than the file system block size may corrupt the file system.
  WARNING: writecache size 6.00 TiB will use 132 GiB of system memory (251 GiB).
  Logical volume vdo_sanity/wc_lv now has writecache.

Comment 13 errata-xmlrpc 2022-11-15 11:20:43 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:8358