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.
(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.
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.
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.
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