You got it absolutely correct, but skipped a few not so obvious things:
A flash device is divided into three major "modes of thought" for lack of a better term:
1. Read blocks:
A read block is the smallest addressable space in the device, (usually 4096 bytes or some multiple of that), and it can be read as often as you want. Due to the lack of moving parts, the actual location of a particular sequence of read blocks can be, literally, anywhere on the device. The device's firmware and internal microcontroller is responsible for maintaining the logical to physical mapping and it's totally hidden. Unneeded read blocks are marked "stale" (or something like that) indicating that the data there is no longer important and doesn't need to be copied.
2. Write blocks:
A write block is a large collection of read blocks and is the smallest addressable space that can be written to.
The other side of that is if it needs to write something there (data has been changed or whatever), the entire write block has to be copied into memory, the data changed, and then written somewhere else. The old write block is marked "stale" and can be scavenged.
3. Erase blocks:
Erase blocks are HUGE collections of write blocks and are the smallest addressable space that can be erased.
Note that the bits in a write block can only be set one way, 1 to 0 or 0 to 1. (Usually 1 to 0). This is done using a special high "write" voltage to inject a charge into a particular isolated MOS gate to change the bit's state. The only way to flip them back is by erasing an entire erase block which takes an even higher-voltage bias, (higher than the write voltage), to successfully drain all the trapped gate charges and reset the bits. This is one of the reasons that flash chips have a relatively limited lifetime - repeated higher-voltage write and erase stresses eventually cause leakage paths to form in the substrate causing failed blocks that must be discarded.
In order to erase an entire erase block, any non-stale write blocks have to be read into memory and moved first.
TRIM is designed to be a way to signal to the underlying system which read and/or write blocks can be marked as "stale". This way the underlying system can know which blocks are important and which aren't and can avoid moving a lot of unnecessary stale data around that it didn't need to move, saving stress on the delicate silicon substrate.
A flash device is divided into three major "modes of thought" for lack of a better term:
1. Read blocks:
A read block is the smallest addressable space in the device, (usually 4096 bytes or some multiple of that), and it can be read as often as you want. Due to the lack of moving parts, the actual location of a particular sequence of read blocks can be, literally, anywhere on the device. The device's firmware and internal microcontroller is responsible for maintaining the logical to physical mapping and it's totally hidden. Unneeded read blocks are marked "stale" (or something like that) indicating that the data there is no longer important and doesn't need to be copied.
2. Write blocks:
A write block is a large collection of read blocks and is the smallest addressable space that can be written to.
The other side of that is if it needs to write something there (data has been changed or whatever), the entire write block has to be copied into memory, the data changed, and then written somewhere else. The old write block is marked "stale" and can be scavenged.
3. Erase blocks:
Erase blocks are HUGE collections of write blocks and are the smallest addressable space that can be erased.
Note that the bits in a write block can only be set one way, 1 to 0 or 0 to 1. (Usually 1 to 0). This is done using a special high "write" voltage to inject a charge into a particular isolated MOS gate to change the bit's state. The only way to flip them back is by erasing an entire erase block which takes an even higher-voltage bias, (higher than the write voltage), to successfully drain all the trapped gate charges and reset the bits. This is one of the reasons that flash chips have a relatively limited lifetime - repeated higher-voltage write and erase stresses eventually cause leakage paths to form in the substrate causing failed blocks that must be discarded.
In order to erase an entire erase block, any non-stale write blocks have to be read into memory and moved first.
TRIM is designed to be a way to signal to the underlying system which read and/or write blocks can be marked as "stale". This way the underlying system can know which blocks are important and which aren't and can avoid moving a lot of unnecessary stale data around that it didn't need to move, saving stress on the delicate silicon substrate.
Statistics: Posted by jharris1993 — Tue Oct 01, 2024 4:34 pm