I think it's possible to argue that UFS TRIM could be improved on FreeBSD.
I have several Linux systems using SSDs. None of them have TRIM enabled at the file system level. They do have it enabled at the volume manager level, but only for TRIMing disk blocks explicitly released by the volume manager itself (e.g. when a volume is shrunk).
I TRIM all my Linux SSD file systems weekly, from
cron
, using
fstrim
. The TRIM request has to percolate through several software layers. In my case, that's almost always xfs (file system), lvm (volume manager), md (software RAID), and hardware (SATA). But
fstrim
works regardless of the stack (well, for all the common file system options).
Enabling TRIM at the file system level means that TRIM is activated every time a file is deleted (blocks get added to the free list) which:
- presents large numbers of small chunks of free disk blocks to the SSD controller, fragmenting the lists; and
- routinely disrupts and slows down regular file system activities.
Conversely, periodic bulk TRIMing facilitates the aggregation of maximal length runs of free blocks for presentation to the SSD controller, shortening the lists and minimising fragmentation. It also limits I/O disruption from TRIM commands to a time of the administrators' choosing.
Bulk TRIMing does need to be scheduled at a quiet time, as it's significantly disruptive to other file system activity.