Charlie Cassidy
Member
For a SATA or SAS SSD (I'm not as familiar with eMMC/SD Cards/USB thumbdrives), replacing a bad block does not reduce the available storage (i.e. does not reduce MAX_LBA). The capacity of the drive remains the same. You lose a physical block but not a logical block.
Modern SSDs maintain a logical-to-physical mapping in their firmware and physical address space is larger than logical address space. This is overprovisioning. The effect is similar to running defrag on a HDD. Many defraggers have difficulty running if there is little to no empty space on the drive. There just isn't enough space to copy files to coalesce used and empty space.
Garbage collection on an SSD is basically a defrag process. If you want to erase a block that has a mix of valid and invalid data, you need to move the valid data to another block. In order to do this, you need free blocks to move the data to. This is what the overprovisioned space is used for. If you didn't have it, the drive would eventually fill up and every block would have some dirty pages but there would be no free space to write to.
All of this is necessary because of the nature of the underlying NAND flash storage. Flash can only be written from a 1 to a 0, not from a 0 to a 1. To remove 0 bits, you must do an erase. Flash is written and read a page at a time (4KB/8KB/16KB these days) and is erased a block at a time (typically 128 pages). It also cannot be overwritten (or overwritten a very limited number of times) and for many types of flash must be written in order (i.e., you must write page 0, then 1, then 2... in a block or else data will be corrupted).
Modern SSDs maintain a logical-to-physical mapping in their firmware and physical address space is larger than logical address space. This is overprovisioning. The effect is similar to running defrag on a HDD. Many defraggers have difficulty running if there is little to no empty space on the drive. There just isn't enough space to copy files to coalesce used and empty space.
Garbage collection on an SSD is basically a defrag process. If you want to erase a block that has a mix of valid and invalid data, you need to move the valid data to another block. In order to do this, you need free blocks to move the data to. This is what the overprovisioned space is used for. If you didn't have it, the drive would eventually fill up and every block would have some dirty pages but there would be no free space to write to.
All of this is necessary because of the nature of the underlying NAND flash storage. Flash can only be written from a 1 to a 0, not from a 0 to a 1. To remove 0 bits, you must do an erase. Flash is written and read a page at a time (4KB/8KB/16KB these days) and is erased a block at a time (typically 128 pages). It also cannot be overwritten (or overwritten a very limited number of times) and for many types of flash must be written in order (i.e., you must write page 0, then 1, then 2... in a block or else data will be corrupted).