Why is TRIM not supported on encrypted "/data" partition? I have a rooted Lenovo A369i. I use LagFix (fstrim) to TRIM partitions. Previously it was working well with /data but after I encrypted my phone it doesn't. I decrypted my phone by formatting. But now in the app it shows /data partition having kernel or hardware issues. It's not hardware because before encryption it was working well.
Just if someone stumbles upon this, following conditions should be met for TRIM to work:

Underlying hardware (eMMC) must support TRIM. For instance Redmi Note 4 comes with MCP: RX1BMB which contains eMMC 5.1 and hence supports TRIM.

Kernel must have support for TRIM, was added in v3.1, but it is disabled by default and vold daemon must map userdata partition with allow_discards option, which it didn't in my case.
If your /data partition is encrypted (FDE), Support for allow_discards was added in version 1.11.0 (1) of device-mapper crypt (1) target, but may not work e.g. on devices with Qualcomm SoCs. See this issue for more details.

Filesystem must also support TRIM (1) (except if you want to TRIM a whole partition with blkdiscard). Android uses ext4 or f2fs on /data partition, both support TRIM.


If these conditions meet, you can perform TRIM manually (fstrim -v /data) or periodically (scheduled service) or continuously (with discard mount option). See this answer for details on how often you should perform fstrim.