[haiku-development] RFC: TRIM request support in ahci [with code]

  • From: Alexander von Gluck <kallisti5@xxxxxxxxxxx>
  • To: <haiku-development@xxxxxxxxxxxxx>
  • Date: Fri, 08 Jun 2012 11:37:24 -0500

I've made the first steps to getting the path for the ATA trim command to the drive.


Fun fact: Linux calls trim discard as trim is an ata term and unmap is the scsi term for the same operation.

My plan so far is:

* Since ahci are emulated as scsi, a scsi operation for trim makes sense (it also keeps it simple) * SAS devices utilize a SCSI "unmap" flag in the SCSI WRITE SAME operation for discard / trim.
   * http://pub.haikungfu.net/scsi_writesame.png  << there

 * Add SCSI WRITE SAME 16 operation to scsi_cmds:
   http://pub.haikungfu.net/0001-scsi-Add-write-same-SCSI-operation.patch
 * Pick up on WRITE SAME operation in ahci port driver, and check for
   unmap flag and TRIM support on the drive.  If everything looks good,
do the sata trim (actual hardware code not yet complete, although we should be able to do it in AHCIPort)
   http://pub.haikungfu.net/0002-ahci-Initial-TRIM-work.patch


The above patches mean to perform the trim on the disk, calling the scsi "write same" from the filesystem (or kernel block) layer on discard somewhere would result in the hardware trim event.

Thoughts?

 -- Alex


Other related posts: