Linux – Possible to get SSD TRIM (discard) working on ext4 + LVM + software RAID in Linux

linuxlvmraidssdtrim

We use RAID1+0 with md on Linux (currently 2.6.37) to create an md device, then use LVM to provide volume management on top of the device, and then use ext4 as our filesystem on the LVM volume groups.

With SSDs as the drives, we'd like to see the TRIM commands propagate through the layers (ext4 -> LVM -> md -> SSD) to the devices.

It looks like recent 2.6.3x kernels have had a lot of new SSD-related TRIM support added, including lots more coverage of Device Mapper scenarios, but we still can't seem to get it to cascade down properly.

Is this possible yet? If so, how? If not, is any progress being made?

Best Answer

UPD. 2020-06-17

Looking back through commits history from 2020:

2 years later there're commits in regards for md (LSR), the one among them:

— Basically in a few months since I edited my answer previously, Linux kernel became able to support block discards in the setup.


Previous versions of the answer:

UPD. 2012-07-17 UPD.: Thanks to Wodin for letting me know — according to lkml.org/lkml/2012/3/11/261 this functional has been addedproposed recently. proposed != accepted, though.

UPD. 2011-02-01 Not possible, cause Linux Soft RAID doesn't support this (yet?).