Update on TRIM support

Tim Bisson bissont at mac.com
Wed Jun 1 23:15:42 PDT 2011

Hi All,

Here's an update on TRIM support based on feedback from Matt, Alex, 
Venkatesh, and others. Thanks guys.

First, the code:
If you clone the code and do a:
git difftool upstream/master..HEAD
you can get a diff against the current master (as of today).
* Moved the underlying TRIM code from the IDE driver to the AHCI/SCSI 
* Made UFS block frees (ffs_blkfree()) execute TRIM command on blocks 
asynchronously instead of synchronously. Once the TRIM command is 
completed, we free the actual blocks in the freemap in the callback. 
This makes delete performance much faster as we don't have to wait for 
the TRIM command to finish before returning from the ffs_blkfree().
* Added an option, -E to newfs_hammer, that will run TRIM on the devices 
making up the hammer file system before the hammer file system is created.
* Modified the IOCTL to take in bytes rather than sectors. In the IOCTL, 
we  issue a BUF_CMD_FREEBLKS command using a struct buf, which has a 
size limit of 2^31 (b_bcount) bytes. Therefore, we potentially have to 
break up the IOCTL TRIM command into multiple requests if the original 
command is for more than 2^31 bytes in size.

More information about the Kernel mailing list