-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable CONFIG_DM_WRITECACHE module in kernel #5020
Comments
Am I write in thinking that the writes are cached on an SSD (since Pis have no persistent memory) until they are committed to the slow device? |
Correct. There is an SSD in USB caddy. PI4 can use it up to ~350 MB/s write. I would use a 300GB SSD partition in front of the HDD drives. In this way I get a performant speed but still high capacity (and cheap). The writecache can do the flush during the night. The PI's USB 3 speed matches the SSD speed and the extra CPU load isn't really noticable. So overall I see this a good combination to increase speed and eliminate IO bottlneck. ps.: yes, I know this wears out the SSD but this is acceptable for those who uses cache to speed up. |
For Pi 4 (which has high speed USB and PCIe), enable DM_WRITECACHE as a module to allow an external SSD to be used as a fast write cache for a slower storage device. See: #5020 Signed-off-by: Phil Elwell <[email protected]>
I've enabled DM_WRITECACHE as a module on Pi 4s - see 9bc1ec5. |
For Pi 4 (which has high speed USB and PCIe), enable DM_WRITECACHE as a module to allow an external SSD to be used as a fast write cache for a slower storage device. See: #5020 Signed-off-by: Phil Elwell <[email protected]>
For Pi 4 (which has high speed USB and PCIe), enable DM_WRITECACHE as a module to allow an external SSD to be used as a fast write cache for a slower storage device. See: #5020 Signed-off-by: Phil Elwell <[email protected]>
kernel: configs: Enable DM_WRITECACHE module on BCM2711 See: raspberrypi/linux#5020 kernel: configs: Add CONFIG_EEPROM_AT25=m See: raspberrypi/linux#5018
kernel: configs: Enable DM_WRITECACHE module on BCM2711 See: raspberrypi/linux#5020 kernel: configs: Add CONFIG_EEPROM_AT25=m See: raspberrypi/linux#5018
@pelwell Thank you for enabling the feature. The updated kernel arrived and I can serve some test data. TL/DR: DM_WRITECACHE can give back the native speed of the SSD with the space of the HDD. The feature in nutshell: DM_WRITECACHE as its name says helps in the writing the data. If you have a fast SSD and a slow HDD then you can bring the fast SSD on front of the HDD and all the writes will happen on the SSD first and then flushed to the slower HDD in the background. It has pros and cons so please do your research before using the feature. Here, I focus on how does it work on RPI 4. More details here: https://man7.org/linux/man-pages/man7/lvmcache.7.html The cache works in this way:
In the attachment you can see the dstat printout where the sda is the SSD (Samsung SSD 870 EVO 500GB) on USB 3.0 port and the sdc is the HDD (Western Digital WD20SPZX) on USB 2.0* port. *The WD HDD is connected to the USB 2.0 port because this is a DM-SMR drive which has ~10GB PMR area and the rest is SMR. While it is writing to the PMR then it can write ~70-90 MB/s but once that area is full then the speed falls to 2-5 MB/s. This is how SMR disks work so the USB 2.0 port is fine for it. Note that the CPU utilization is mainly generated by the 2 dd copy threads. So as you can see from the attachment DM_WRITECACHE can combine the raw performance of the different storage arrays smartly. We can reach 325 MB/s read bandwidth while there is free space in the cache. This is the weak point of the solution which is already noticed by the people of the internet but no solution yet: IMPORTANT, at the first try I created a 300GB cache and I attached it to my HDD's volume. Then the system failed with the activation due to short of memory. This setup required ~4,2 GB of free RAM which was more than challenging on a 4GB RPI model (SWAP doesn't play). This was the error message: Ok, it didn't work so I tried to decommission the setup and tried to uncache the volume. Here comes the twist: to detach the cache first it tries to activate the volume to flush the cache first to preserve the data. Of course this fails because short of memory so the detachment fails as well. (Yeah, it was never used so the cache is empty but this is the process :) ) Nevertheless the solution works as it is documented (besides being a memory beast) and still can boost databases and similar IO intensive applications which require only few tens of GB cache. |
For Pi 4 (which has high speed USB and PCIe), enable DM_WRITECACHE as a module to allow an external SSD to be used as a fast write cache for a slower storage device. See: raspberrypi#5020 Signed-off-by: Phil Elwell <[email protected]>
For Pi 4 (which has high speed USB and PCIe), enable DM_WRITECACHE as a module to allow an external SSD to be used as a fast write cache for a slower storage device. See: raspberrypi#5020 Signed-off-by: Phil Elwell <[email protected]>
For Pi 4 (which has high speed USB and PCIe), enable DM_WRITECACHE as a module to allow an external SSD to be used as a fast write cache for a slower storage device. See: raspberrypi#5020 Signed-off-by: Phil Elwell <[email protected]>
For Pi 4 (which has high speed USB and PCIe), enable DM_WRITECACHE as a module to allow an external SSD to be used as a fast write cache for a slower storage device. See: #5020 Signed-off-by: Phil Elwell <[email protected]>
For Pi 4 (which has high speed USB and PCIe), enable DM_WRITECACHE as a module to allow an external SSD to be used as a fast write cache for a slower storage device. See: #5020 Signed-off-by: Phil Elwell <[email protected]>
@szasza576 okay to close? |
@popcornmix yes, it is working. Please close the ticket. Thank you. |
For Pi 4 (which has high speed USB and PCIe), enable DM_WRITECACHE as a module to allow an external SSD to be used as a fast write cache for a slower storage device. See: raspberrypi#5020 Signed-off-by: Phil Elwell <[email protected]>
For Pi 4 (which has high speed USB and PCIe), enable DM_WRITECACHE as a module to allow an external SSD to be used as a fast write cache for a slower storage device. See: raspberrypi#5020 Signed-off-by: Phil Elwell <[email protected]>
For Pi 4 (which has high speed USB and PCIe), enable DM_WRITECACHE as a module to allow an external SSD to be used as a fast write cache for a slower storage device. See: raspberrypi#5020 Signed-off-by: Phil Elwell <[email protected]>
For Pi 4 (which has high speed USB and PCIe), enable DM_WRITECACHE as a module to allow an external SSD to be used as a fast write cache for a slower storage device. See: #5020 Signed-off-by: Phil Elwell <[email protected]>
For Pi 4 (which has high speed USB and PCIe), enable DM_WRITECACHE as a module to allow an external SSD to be used as a fast write cache for a slower storage device. See: raspberrypi#5020 Signed-off-by: Phil Elwell <[email protected]>
For Pi 4 (which has high speed USB and PCIe), enable DM_WRITECACHE as a module to allow an external SSD to be used as a fast write cache for a slower storage device. See: raspberrypi#5020 Signed-off-by: Phil Elwell <[email protected]>
For Pi 4 (which has high speed USB and PCIe), enable DM_WRITECACHE as a module to allow an external SSD to be used as a fast write cache for a slower storage device. See: #5020 Signed-off-by: Phil Elwell <[email protected]>
For Pi 4 (which has high speed USB and PCIe), enable DM_WRITECACHE as a module to allow an external SSD to be used as a fast write cache for a slower storage device. See: raspberrypi#5020 Signed-off-by: Phil Elwell <[email protected]>
For Pi 4 (which has high speed USB and PCIe), enable DM_WRITECACHE as a module to allow an external SSD to be used as a fast write cache for a slower storage device. See: raspberrypi#5020 Signed-off-by: Phil Elwell <[email protected]>
For Pi 4 (which has high speed USB and PCIe), enable DM_WRITECACHE as a module to allow an external SSD to be used as a fast write cache for a slower storage device. See: #5020 Signed-off-by: Phil Elwell <[email protected]>
For Pi 4 (which has high speed USB and PCIe), enable DM_WRITECACHE as a module to allow an external SSD to be used as a fast write cache for a slower storage device. See: #5020 Signed-off-by: Phil Elwell <[email protected]>
For Pi 4 (which has high speed USB and PCIe), enable DM_WRITECACHE as a module to allow an external SSD to be used as a fast write cache for a slower storage device. See: #5020 Signed-off-by: Phil Elwell <[email protected]>
For Pi 4 (which has high speed USB and PCIe), enable DM_WRITECACHE as a module to allow an external SSD to be used as a fast write cache for a slower storage device. See: #5020 Signed-off-by: Phil Elwell <[email protected]>
For Pi 4 (which has high speed USB and PCIe), enable DM_WRITECACHE as a module to allow an external SSD to be used as a fast write cache for a slower storage device. See: raspberrypi#5020 Signed-off-by: Phil Elwell <[email protected]>
For Pi 4 (which has high speed USB and PCIe), enable DM_WRITECACHE as a module to allow an external SSD to be used as a fast write cache for a slower storage device. See: #5020 Signed-off-by: Phil Elwell <[email protected]>
BugLink: https://bugs.launchpad.net/bugs/1975599 For Pi 4 (which has high speed USB and PCIe), enable DM_WRITECACHE as a module to allow an external SSD to be used as a fast write cache for a slower storage device. See: raspberrypi/linux#5020 Signed-off-by: Phil Elwell <[email protected]> (cherry picked from commit 9bc1ec59bd8db07e41067717aeea2749314ec801 rpi-5.15.y) Signed-off-by: Juerg Haefliger <[email protected]> Acked-by: Tim Gardner <[email protected]> Acked-by: Stefan Bader <[email protected]> Signed-off-by: Juerg Haefliger <[email protected]>
Describe the bug
Please compile the kernel with enabled CONFIG_DM_WRITECACHE module.
There are already several Device Mapper enabled in the kernel but his would be very helpful to speed up slow HDDs.
Enabling the module doesn't impact the default behaviour of the system hence it doesn't impact others.
Thank you in advance.
Steps to reproduce the behaviour
Try to load the module:
sudo modprobe dm-writecache
or
Try to create a cached LV:
Device (s)
Raspberry Pi 4 Mod. B
System
Raspberry Pi reference 2022-01-28
version c073992a577d160d8c30bfcf746d2208951c0537 (clean) (release) (start_cd)
5.15.36-v8+
Logs
No response
Additional context
https://github.com/raspberrypi/linux/blob/rpi-5.15.y/drivers/md/Kconfig#L332
The text was updated successfully, but these errors were encountered: