Just playing around with this today, and it’s very cool. FreeBSD 9.2 now supports TRIM/UNMAP for ZFS.
To see if your disk is reporting the capability, look for kern.cam.da.<device>.delete_method where <device> is the number of the da device, i.e. /dev/da5 is “5” in that place.
For example:
# sysctl -a | grep delete_method
kern.cam.da.0.delete_method: NONE
kern.cam.da.1.delete_method: NONE
kern.cam.da.2.delete_method: NONE
kern.cam.da.3.delete_method: NONE
kern.cam.da.4.delete_method: NONE
kern.cam.da.5.delete_method: UNMAP
kern.cam.da.6.delete_method: NONE
kern.cam.da.7.delete_method: NONE
kern.cam.da.8.delete_method: NONE
kern.cam.da.9.delete_method: NONE
kern.cam.da.10.delete_method: NONE
kern.cam.da.11.delete_method: NONE
kern.cam.da.12.delete_method: NONE
I’ve tested this with a Pure Storage FlashArray, using FreeBSD 9.2 running under VMware, and an RDM LUN passed through to FreeBSD to give it native SCSI access. That’s da5 above showing the UNMAP method.
According to Alexander Motin, the following are supported and settable via sysctl:
NONE - no provisioning support reported by the device; DISABLE - provisioning support was disabled because of errors; ZERO - use WRITE SAME (10) command to write zeroes; WS10 - use WRITE SAME (10) command with UNMAP bit set; WS16 - use WRITE SAME (16) command with UNMAP bit set; UNMAP - use UNMAP command.