The controller is also responsible for wear leveling, error correction and garbage collection. The level of intelligence built into the flash memory controller is an important factor to consider when selecting the right solid-state drives (SSDs) for the job.
What flash controllers are used for
After a flash device is made, the controller formats the flash memory to ensure the device works properly. It maps flash cells and determines which spare cells will replace any failed ones. A portion of the spare cells also holds the firmware for the controller and storage device.
When a device needs to read or write to flash, it talks to the flash controller. Simple devices, such as SD cards and USB flash drives, only have a few flash memory dies connected at once, which limits the speed of the memory. High-performance, enterprise-grade SSDs can have hundreds of dies, which makes them much faster than consumer flash.
Consumer-grade SSDs are generally built with generic flash controllers that are inexpensive and not expected to support frequent program/erase (P/E) cycles. Enterprise-grade SSDs, which must support write-intensive applications, often have proprietary controllers that are specifically designed to extend the drive's endurance and improve performance. An enterprise flash controller can compensate for NAND-flash limitations through highly sophisticated wear-leveling techniques and advanced error-correction algorithms.
What are wear leveling and block picking?
Flash can handle a finite number of write/erase cycles. If one block of flash is programmed and erased without writing to any other blocks, that block would wear out much sooner than the others and kill the device prematurely. To avoid that, flash controllers evenly distribute reads and writes across blocks in a process known as wear leveling.
There are three options for wear leveling: dynamic wear leveling, static or global wear leveling, or no wear leveling.
With dynamic wear leveling, the flash controller maps logical block addressing (LBAs) to physical flash. This means that each time a block is rewritten, it receives a new physical address. The data is recycled, so the device lasts longer than it would have without wear leveling.
Static wear leveling maps LBAs to physical locations and recycles data like dynamic wear leveling does. But static wear leveling also occasionally moves unchanged blocks, so they can be used. This approach wears out almost all of the blocks before killing the drive.
A NAND flash memory system without wear leveling will have a short life. When a device doesn't have wear leveling, the flash memory controllers must give permanent LBAs to physical addresses, so every block written to has to be read, erased and written to again. In this scenario, blocks that are written to frequently wear out, while others are never used. When a few blocks fail, the whole device dies.
The purpose of FTL and mapping
The Flash Transition Layer (FTL) is also usually included in flash controllers. The FTL is a layer that sits below the file system and maps LBAs to physical addresses. LBAs denote the size that the file system can see and manage, and they are mapped to a block ID, page ID and sector ID of the flash device.
The physical location of an LBA can change often as part of wear leveling and other flash management techniques, such as bad block management and safe flash handling. The mapping units of an FTL can also change, so LBAs are mapped based on page or subpage. Finer-grained mapping can reduce flash wear out and improve the endurance of flash storage.
When every block of an SSD has been written to once, the flash controller must return stale blocks, or blocks with outdated data in a process known as garbage collection. All flash media includes some level of garbage collection, but speeds vary based on the controller.