Part 1 of 7 · 1 min read
Why this page comes fifth
In this module you will
- Explain why writing new data to a new place can be faster and safer than overwriting in place.
- Describe a log-structured file system: segments, the inode map, the checkpoint region and cleaning.
- Compute the cleaning cost 2 / (1 - u) and compare it with the flash cost of Level 8.
- Explain a copy-on-write tree, count the blocks that one update writes, and say why snapshots are cheap.
- Say what the copy-on-write file systems in use today trade for these gains.
Page 4 made in-place updates safe with a journal, at the cost of writing metadata twice. A different answer is to stop overwriting. This page covers two forms of that answer. Level 8 already showed the idea inside every flash drive, whose translation layer writes updates to new pages and cleans old blocks later. File systems can apply the same plan, and some do. Page 6 turns to how such systems are attached to the kernel.
About this example About this example
Real: The C program in section 4 was compiled with gcc -Wall -Wextra and run on a Linux test machine (kernel 6.18). Its counts of 85, 4 and 81 blocks are its real output.
Scripted: The disk used in section 2 is the made-up drive of Level 8, page 1 (9 ms seek, 7,200 RPM, 100 MB/s). The utilisations in section 3 and the file counts in the exercises are made up to show the idea. The cleaning formula is derived on the page.
Not real: The test machine has no Btrfs, ZFS or F2FS tools, so no copy-on-write file system was run. Section 5 describes them from the books and from general knowledge. The tree in section 4 is a model with fixed fanout and no free-space tracking.