Curriculum / Part 2 · Flash and NVMe deep dive
Lesson 7

The FTL and garbage collection

How the Flash Translation Layer hides NAND's rules, why garbage collection causes write amplification, and why you precondition before benchmarking.

⏱ 40 min5-question quizLab 2.1

The simple version

Back to the pen notebook. To "change" a line you write the new version on a fresh line and cross out the old one. Eventually sheets are full of crossed-out lines. A tidy-up helper copies the still-valid lines from a messy sheet to a new one, then tears the old sheet out. That helper is garbage collection, and every line it copies is extra writing you never asked for.

The FTL

The host writes to logical block addresses (LBAs). The SSD's Flash Translation Layer keeps a map from each LBA to a physical NAND location. An overwrite goes to a fresh page; the map is updated and the old page is marked invalid. To the host it looks like an in-place overwrite.

Garbage collection and write amplification

When free blocks run low, the FTL picks blocks with many invalid pages, copies the valid pages elsewhere, and erases the block. Those copies are extra NAND writes.

Write amplification factor (WAF) = NAND bytes written ÷ host bytes written

Example: the host writes 1 TB and the drive writes 2.5 TB to NAND → WAF 2.5. Endurance is consumed at 2.5× the host rate.

Random small overwrites spread invalid pages across many blocks and raise WAF; large sequential writes that invalidate whole blocks keep it near 1.

Over-provisioning

OP % = (raw NAND − user capacity) ÷ user capacity

Spare space gives GC room to work, lowering WAF and steadying write performance. This is part of why 3.2 TB "mixed-use" and 3.84 TB "read-intensive" drives can share similar raw NAND.

TRIM/discard (NVMe: Deallocate) tells the drive which LBAs are no longer in use, which effectively adds free space for GC. fstrim -av runs it on mounted filesystems.

Fresh-out-of-box vs steady state

A new or freshly erased drive has all blocks free, so early writes never trigger GC and look fantastic. Once the drive has been filled and overwritten, GC runs continuously and random-write performance settles lower: steady state.

Precondition before benchmarking writes. The SNIA Solid State Storage Performance Test Specification (PTS) describes the standard approach: fill the drive, then run the target workload until results stabilise. Short tests on a fresh drive overstate write performance.

Tools

fstrim -av
Discard unused blocks on all mounted filesystems that support it.
nvme smart-log
data_units_written is host writes. NAND writes need vendor-specific logs, so WAF is often not directly visible.
fio --rw=randwrite --time_based --runtime=1800
Long-running write test to observe the drop to steady state (test drives only).

Quiz

Lab

Lab 2.1 · The write cliff

A new drive, /dev/nvme1n1, did about 600k 4K random-write IOPS in the vendor's 60-second quick test. In production it delivers far less, and someone suspects a bad batch.

Start lab 2.1 →