NAND Flash Wear Leveling Algorithm

Aug 27, 2022

Because the number of write operations of flash memory is limited, if 100000 write operations have been performed on some units, the write reliability of these units cannot be guaranteed, and some units may fail. For example, some management data system logs are rewritten frequently, while some static file data is almost never rewritten. If not controlled, some blocks will be damaged in advance due to repeated erasures, and some blocks have not been rewritten, In order to solve this problem, write operations are evenly distributed to all flash memory cells to make a balance on the whole to avoid failure of individual cells. Wear leveling is an algorithm widely used to solve this problem.

Wear leveling is to provide a block mapping mechanism to spread the write loss among different blocks. It will not cause some blocks to be written down first and invalidate the entire SSD disk. Instead, some reserved blocks will replace the blocks that fail before the expected life. This algorithm makes the life of the whole device the same as the maximum life of flash.

Generally, a page based file storage algorithm is used to realize wear leveling. There is no one-to-one correspondence between the physical address and logical address of flash memory. When the SSD receives a data write request, it will not write in order, but find the unit with the least write. Therefore, when dynamically allocating physical blocks for write data, corresponding priorities will be allocated according to the usage of each block, so as to balance the service life of each cell of the whole memory.