# Leveraging Static and Dynamic Wear Leveling to Prolong the Lifespan of Solid-State Drives
## 2 Background and Related Work  
### SSD Internals and NAND Flash Memory  
SSDs use NAND flash memory chips interconnected in a parallel structure through multiple channels as storage media. Each NAND chip comprises multiple dies capable of independent NAND operations, with each die further divided into multiple planes. These planes consist of blocks, serving as the minimum units for erase operations, and each block is subdivided into pages, which represent the minimum units for read and write operations. Similar to EEPROM, NAND flash memory adheres to the erase-before-write principle, necessitating that data be written only to pages that have been previously erased. Due to the larger unit size of erase operations compared to write operations (blocks vs. pages), implementing in-place updates is challenging. Consequently, NAND-based storage devices, such as SSDs, integrate flash translation layer (FTL) firmware internally. This FTL firmware facilitates the processing of host write requests using an out-of-place update method [22; 23; 24; 25; 26]. When a write request for specific sectors arrives from the file system, the data are written to a new clean page instead of the page that was storing the existing data. At this point, the page that previously stored the data is invalidated since it no longer contains valid data. Consequently, performing the out-of-place update causes the location of valid data, i.e., the sector's location, to change with each write, and the FTL (Flash Translation Layer) maintains a mapping table to remember the current valid locations of sectors. Since the mapping table is frequently accessed, it is generally kept in memory, and for this purpose, SSDs are equipped with a large amount of RAM. When the proportion of clean pages falls below a certain threshold due to write request processing, garbage collection is initiated to reclaim clean pages. Garbage collection is performed in three stages: 1. selection of a victim block, 2. copying valid pages from the victim block to clean pages of other blocks, and 3. erasure of the victim block. For instance, if a NAND block consists of a total of 256 pages and a victim block has 10 valid pages, then before erasing the victim block, its 10 valid pages must be copied to clean pages of other blocks. Upon completion of the copying operation, the victim block is erased, resulting in the reclamation of a total of 256 clean pages. However, as 10 clean pages from other blocks are used to copy the valid pages from the victim block, the actual number of additional clean pages reclaimed is 246. Hence, the execution time of garbage collection and the actual number of clean pages reclaimed are inversely proportional to the number of valid pages in the victim block. Therefore, from a performance perspective, the greedy policy [15; 21], which selects the block with the fewest valid pages as the victim block, is optimal. This policy minimizes the copying of valid pages, thereby reducing the execution time of garbage collection and maximizing the actual number of clean pages reclaimed by garbage collection. However, since the selection of the victim block does not consider the accumulated erase count of each block, there is a risk of uneven erase counts among blocks. Meanwhile, each block of NAND flash memory has a maximum threshold for erasures. The NAND cells are wrapped in an oxide insulating layer, which gradually deteriorates due to the ingress and egress of electrons during write and erase operations. Eventually, when the accumulated erase count of a block exceeds the threshold, it becomes a bad block due to the natural loss of electrons caused by the damage to the insulating layer, leading to unintentional data corruption. As bad blocks cannot reliably maintain data, they become unusable. In general, SSDs have more storage capacity than what is exposed to the file system in order to improve the efficiency of garbage collection and to cope with the occurrence of bad blocks. This is known as overprovisioning.