← Back to context

Comment by b112

4 years ago

A crash, lockup, are the same as a power failure.

No, during a crash or lockup, acknowledged writes are not lost. (Because the drive has acknowledged them, they are in the drive's internal queue and thus need no further action from the OS to be committed to durable storage.) Only power loss/power cycle causes this.

Why? During a crash or lockup acked writes still reached the drive. They will be flushed to the storage eventually by the SSD controller. As long as you have power that is.

  • The key word is ‘eventually’. How long? Seconds, or even minutes? If your machine locks up, you turn it off and on again. If the drive didn’t bother to flush its internal caches by then, that data is lost, just as in a power failure.

    • > you turn it off and on again

      That would be a power failure. Kernel crash is not equivalent to that.

      System reboot doesn't entail power failure either. The disks may be powered by an independent external enclosure (e.g. JBOD). All they see is that they stopped receiving commands for a short while.

    • It's at least seconds. Apple's NVMe controller does not try to eagerly flush unflushed writes.

      That said, macOS does issue a flush on kernel panic, and I'm hoping to be able to do the same on Linux.

macOS flushes the NVMe cache on kernel panic.

Probably not on lockups though. A watchdog reset won't flush NVMe. Not sure if they have a special pre-fire path that tries a last ditch NVMe flush...