Cache SSD shutdown data loss

During a controlled shutdown, the OS/filesystem flushes all pending writes to stable storage, issuing a final write barrier (ie: ATA FLUSH) to be sure no data remains in the volatile write cache. This can need some time, but you don't have to do anything: just wait for the operation to complete (and the system to power-off).

But what does happen during an unexpected shutdown, for example just after a power loss? On consumer SSDs, lacking a powerloss protected write cache, you will lose any unsynched cache content. To avoid losing cached data, the user/OS needs to explicitly sync and flush important but pending data (eg: a database write or a filesystem journal update) via a sync+barrier primitive (ie: sync and fsync() on Linux).

On enterprise SSDs that provide capacitor-based powerloss protected write back cache, a sudden power failure will not cause any data loss. Depending on the drive type/firmware, this protected cache can be exported as writeback or writethrough:

  • in the first case (writeback), the OS will continue sending write barriers and cache flushes, but the drive will simply ignore them unless the on-board controller detects some issues with the powerloss protection circuitry. This mode of operation commands a somewhat higher overhead (due to barrier being generated by the OS), but permits the drive to dynamically switch between actual writeback/writeback+flushes/writethrough modes based on internal health counters;

  • in the second case (writethrough), the OS avoid sending any write barriers. This leads to greater performance (due to less OS overhead), but if the drive electronic detects any issues it can only switch to "full" writethrough, were any write is considered important and immediately flushed to the physical media.


Yes, file system will delay shutdown up to a point it’s own “lazy writer” will flush all the writes to persistent storage. However if you’ll hit “power off” all the data in cache will be lost. Obviously.