Linux – SSD TRIM (discard) problems with ext4 on Crucial C300 SSDs with CentOS 5.5

centosext4linuxssdtrim

Playing around with using a modern kernel (2.6.37 currently) on an older OS (CentOS 5.5) so we can get TRIM (discard) working on our SSDs (Crucial C300s).

The most recent hdparm (9.37) concurs that the C300 supports TRIM:

./hdparm -I /dev/sdc | grep TRIM
       *    Data Set Management TRIM supported (limit unknown)
       *    Deterministic read data after TRIM

But the kernel doesn't seem to agree when I attempt to mount /dev/sdc with the discard option:

EXT4-fs warning (device sdc): ext4_issue_discard:2619: discard not supported, disabling

We're experimenting with other Linux flavors as I type this, but it'd be nice to know what's going on, regardless.

Is this a manifestation of some other ancient component of CentOS 5.5 that's misinforming the kernel? Or maybe is hdparm using a different mechanism than the kernel to determine whether TRIM is supported?

Best Answer

The "FITRIM" message is better than "TRIM" for performance on SSD disk. This support comes since 2.6.37 - so "online discard" is replaced by "batch discard". You have to enable it on ext4 with an ioctl command, see the fstrim utility from util-Linux.

It has been improved in 2.6.39 and 3.1 releases.

Moreover the "direct bio layer" feature for ext4 is disabled in 2.6.37 because of file system corruptions. It has been enabled since 2.6.39.

So for SSD performance, you should update to 2.6.39 or even 3.1