Usually, flash memory controllers also include the "flash translation layer" (FTL), a layer below the file system that maps host side or file system logical block addresses (LBAs) to the physical address of the flash memory (logical-to-physical mapping). The LBAs refer to sector numbers and to a mapping unit of 512 bytes. All LBAs that represent the logical size visible to and managed by the file system are mapped to a physical location (block ID, page ID and sector ID) of the flash memory. As part of the
wear leveling and other flash management algorithms (bad block management, read disturb management, safe flash handling etc.), the physical location of an LBA might dynamically change frequently. The mapping units of an FTL can differ so that LBAs are mapped block-, page- or even sub-page-based. Depending on the usage pattern, a finer mapping granularity can significantly reduce the flash wear out and maximize the endurance of a flash based storage media. The deduplication function to eliminate redundant data and duplicate writes is also added in FTL. As the FTL metadata takes up its own flash space, it needs protection in case of power loss. In addition, it is possible for the mapping table to wear out before other parts of the flash memory has, prematurely ending the life of a storage device. This is usually avoided in enterprise devices by allocating an oversized space for spares, although more durable forms of storage like
MRAM has been proposed for FTL too. The FTL may have three types: page mapping, block mapping, and hybrid mapping. Page mapping can have higher performance, but it has bigger FTL metadata size and higher cost, and is usually used on
solid state drives. Block mapping can have smaller metadata size and lower cost, but it has lower performance, and is usually used on
USB flash drives. On page mapping FTL implementations, the ratio of FTL metadata size and storage capacity is usually 1:1000, for example, a 1TB flash storage device may have 1GB of FTL metadata. Usually the FTL is implemented by firmware running on a flash memory controller built into the storage device (such as nearly all SSDs, eMMCs, SD cards, USB flash drives, etc). However, some systems connect the host processor directly to raw flash chips with no intermediate hardware flash memory controller, and instead handle bad-block management and wear leveling with software running on the host processor. ==Garbage collection==