With a checksum layout chosen, we can put checksums to work β and then meet two sneakier failures they donβt yet catch.
45.4 Using Checksums
Verifying a block is a three-step ritual on every read: fetch the stored checksum , recompute the checksum over the bytes you got back, and compare.
1Read the block and its stored checksum
When reading block D, the client also reads the checksum saved with it, the stored checksum Cs(D).
If they match, the data is (almost certainly) intact. If not, corruption is detected β recover from a redundant copy if you have one, else return an error. A checksum only detects; without another copy of the block, detection just tells you precisely how out of luck you are.
45.5 A New Problem: Misdirected Writes
Basic checksums assume the right data ends up in the right place. But a disk or RAID controller can commit a misdirected write misdirected write A failure mode where the disk or RAID controller writes the data correctly but to the wrong location (wrong block, or in a multi-disk system the wrong disk). Detected by storing a physical identifier β the disk and block numbers β together with the checksum, so a read can tell whether the right block is in the right place. defined in ch. 45 β open in glossary : the data is written correctly, just to the wrong location β block Dx lands at address y (clobbering Dy), or even on the wrong disk entirely. The block that lands is internally consistent, so its checksum happily matches β the fault is purely one of place.
The fix adds a physical ID to each blockβs stored info: its own disk number and offset. On read, the client checks that the stored address matches the address it meant to read:
1Store each blockβs own address
On every write, save the checksum AND a physical ID β the blockβs disk number and offset β next to the data.
That extra redundancy β the disk and block numbers repeated next to each block β is worthless on a perfect disk, but itβs exactly what turns a silent misplacement into a detected corruption.
45.6 One Last Problem: Lost Writes
The nastiest failure is the lost write lost write A failure mode where the device reports a write as completed but never actually persists it, leaving the old block contents behind. Basic checksums and physical IDs still match the stale block, so detection requires either a write verify (read-after-write) or a checksum kept elsewhere β e.g. ZFS stores a checksum in each inode and indirect block, so a lost data write no longer matches. defined in ch. 45 β open in glossary : the device reports a write as complete but never persists it, leaving the old contents in place. Now both of our defenses are useless β the stale block still matches its own old checksum, and its physical ID is still correct:
1The write is acknowledged but lost
The client writes new contents Dβ². The device reports success, but never actually persists it β the disk still holds the OLD D.
The classic brute-force answer is a write verify (read-after-write): read the block straight back to confirm it reached the surface β safe, but it doubles write I/O. Sunβs ZFS takes a cheaper route: store each blockβs checksum in its inode and indirect blocks. The write updates the inodeβs checksum, so a lost data write no longer matches it. Only if the writes to both the inode and the data are lost together does the scheme fail β unlikely, though not impossible.
45.7 Scrubbing
When do all these checksums actually get checked? At access time β but most data is read rarely, so it would sit unverified while bit rot silently corrupts every copy. Disk scrubbing disk scrubbing Periodically reading through every block of the system and re-verifying its checksum (often nightly or weekly), so that rarely-accessed data does not silently rot until every copy is corrupted. Most latent sector errors in the Bairavasundaram studies were found this way. defined in ch. 45 β open in glossary closes that gap: the system periodically reads through every block and re-verifies its checksum, typically on a nightly or weekly schedule. (In the failure studies, most latent sector errors were found precisely this way.)
45.8 Overheads of Checksumming
Nothing is free. Checksummingβs costs split into the usual two kinds β space and time:
| kind | detail | |
|---|---|---|
| disk space | space | β 0.19% β an 8-byte checksum per 4 KB data block |
| memory | space | room for checksums alongside the data while checking β short-lived if discarded right after use |
| CPU | time | compute the checksum on every store AND every read |
| extra I/O | time | when checksums live apart from the data, plus background scrubbing (tunable β schedule it at night) |
Space is nearly a rounding error; the time cost (CPU per block, plus any extra I/O for separated checksums and scrubbing) is the one you actually tune β hence the copy-and-checksum fusion and the scheduled, off-peak scrubs.
45.9 Summary β every defense closes one gap
Each layer of protection catches a failure the previous one couldnβt. Reading the table top to bottom is the whole chapter in miniature:
| latent sector error | block corruption | misdirected write | lost write | |
|---|---|---|---|---|
| in-drive ECC | β returns error | β | β | β |
| + basic checksum | β | β Cs β Cc | β | β |
| + physical ID | β | β | β address β request | β |
| + inode checksum / write-verify | β | β | β | β inodeβs checksum β stale data |
Different checksums guard against different faults, and as devices evolve, new failure modes will keep appearing β forcing us to revisit these ideas or invent new ones. Redundancy remains the key: it powers both the detection here and the recovery that follows.
Check yourself: using checksums, misdirected & lost writes
1.On reading block D, the client finds the stored checksum Cs(D) and the freshly computed checksum Cc(D) do not match. What does that mean, and what can be done?
2.Why does a basic checksum fail to catch a misdirected write, and what extra information catches it?
3.A lost write occurs: the device acknowledges a write it never persisted, so the OLD block contents remain. Why do a basic checksum and a physical ID BOTH fail to detect it, and what does?
4.Why do storage systems perform disk scrubbing rather than relying only on checks at access time?
5.Checksumming's space overhead is tiny (~0.19%), but time overhead can be noticeable. What common trick reduces the CPU cost?
6.Thinking of the cumulative defenses, which single fault is caught ONLY once you add a checksum stored away from the data (e.g. in the inode) or do a write-verify?