← Blog

NVMe Power-Loss Testing: Build a Write Durability Oracle

Test SSD power-loss protection with a record-level oracle that distinguishes lost durable data from legal in-flight outcomes.

By QA Maestro · · 6 min read

Write down exactly what the host is owed

A power-loss test fails when a required durable write disappears or when data violates a documented atomicity or integrity guarantee. It cannot use the same expected outcome for every outstanding command. Establish the NVMe command-set revision, namespace format and atomic write limits, write cache configuration, and the boundary your software uses to acknowledge data as durable.

Test raw NVMe and filesystem durability as separate cases. A write system call returning is not generally a persistence boundary. For the filesystem case, verify the application’s file and directory durability protocol, including any rename. At the device layer, use the specified Flush or FUA semantics. Linux documents how its block layer passes cache-control intent to drivers.

Keep the expected state outside the drive under test

Give each record an LBA or logical record ID, generation, length, and checksum. Keep the test ledger on an independent host or storage path that survives the interruption. Record issuance, completion status, flush or FUA completion, and the physical cut trigger. Capture the actual power transition with a supported fixture and keep the host or measurement recorder powered.

Use disjoint ranges for the protected set and the in-flight set in the first experiment. A later overwrite of a protected LBA makes the expected outcome more complicated. Establish that the basic persistence case passes before testing interrupted overwrites.

Run one cut that can be adjudicated

Write generation A to the protected range, confirm successful completion, then complete the durability operation. Next issue generation B to a separate range that was initialized to generation 0. Cut SSD power while B is outstanding. After restoration, read raw records before a workload restarts or a filesystem replay changes the evidence in the raw-device case.

Every protected record must match A byte for byte. Evaluate each B record against the expected outcomes of its command and the effective power-fail atomicity rules, including address alignment and boundary constraints. Do not apply an old-or-new oracle to an oversized or boundary-crossing write unless the specification and device contract support it. In a dedicated atomic-overwrite test, check the entire guaranteed write unit rather than independently allowing old or new on each sector.

Record range     Before cut                   After reboot
100–199          A durable after flush        All A, correct checksums
200–299          B submitted, 0 initialized   Evaluate per command contract
300–399          Untouched control            Original data and checksums

Check that the fixture exercised the intended event

Include a no-cut control and a clean shutdown control. Test cuts before a flush, after a confirmed flush, and while new writes are in flight. On each run measure trigger-to-rail-drop delay and check whether queued commands completed during that gap. Label a cut that missed its intended window and retain it in the run log. An SSD reset or host reboot is a separate recovery case and cannot substitute for measured power removal.

Repeat at deployment-relevant queue depths and media states. Spread the trigger offsets across the target window and report the distribution. A long campaign can repeatedly exercise one timing corner if every trigger uses the same fixed delay.

Distinguish media failure from an oracle bug

A checksum mismatch in the protected set is a failure candidate. Before rerunning, preserve the raw readback, the independent ledger, device identity, and timing evidence. Confirm the namespace mapping and check that the supposedly durable operation completed before the rail dropped. Compare the observed payload with known generations. Correct data at the wrong logical address points to a different failure signature than an intact previous generation.

After the first failure, reproduce with a single writer and a small range. Once the basic case is understood, add concurrent namespaces or deeper queues back one at a time. Repeated tests after reinitialization cannot recover the state that explained the first failure.

Report exposure and the actual guarantee

Record firmware, devices, cut count by window, confirmed rail timing, verified records, and recovery time. Keep data integrity, availability, and recovery time as separate release gates. For example, a drive that returns all required bytes but misses the application’s recovery budget passes the integrity check and fails availability.

A result of zero failures in 500 qualified cuts is a count for that campaign. It does not establish that every firmware state or cut phase was covered. List excluded cuts, starting media conditions, and the guarantees the oracle actually checked.

References