DragonFly kernel List (threaded) for 2011-06
Update on TRIM support
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.
From "man newfs":
-R Turn on the TRIM enable flag. If enabled, and if the underlying
device supports the BIO_DELETE command, the file system
a delete request to the underlying device for each freed
The trim enable flag is typically set when the underlying
uses flash-memory as the device can use the delete command to
pre-zero or at least avoid copying blocks that have been
-E Use TRIM to erase the file system before creating it. If used
and the underlying device supports TRIM, the device's LBAs
be erased using the TRIM command before the file system is
From "man newfs_hammer"
-E TRIM Device(s) before FS creation. Should only be called if all
devices are SSDs that support TRIM.
Any suggestions, ideas, or feedback is welcome.