Solid State Drive Primer # 12 - Controller Functions - TRIM Command
This article covers the TRIM command supported by some SATA and SCSI SSD controllers. The TRIM command is related to a SSD’s Garbage Collection process described in the previous article.With Garbage Collection, when the Operating System replaces LBA (Logical Block Addresses) which already contain data, such as during a file update/overwrite, the SSD stores the updated data on fresh pages and marks the existing pages as Dirty (or Stale).
At a later time, Garbage Collection reclaims these dirty pages when it erases an entire block, which is the smallest area of erasure in NAND flash. This freshly erased block is now available to be written with new data.
So why the TRIM command?
When the Operating system overwrites the same LBAs, and the SSD controller marks them as dirty for future erasure, it is clear there is no longer valid data in these pages.
But when a file is erased in the operating system, many times only the operating system’s directory is updated. In these cases, there is no erase command sent to the SSD for the LBAs no longer considered valid by the operating system.
In comes the TRIM command. By issuing the TRIM command when a file is permanently deleted, it notifies the SSD that the associated LBAs no longer have valid data and can be marked as dirty for the next round of data collection.