← Back to context

Comment by yalogin

4 years ago

> fsync() will both flush writes to the drive, and ask it to flush its write cache to stable storage.

Can someone explain what "flushing write cache to stable storage" means? Isn't that the same as "writes to the drive". I am obviously not well versed in this area. Also what is stable storage? Never heard that term before.

SSDs and other storage drives have two layers (or more). The last layer is stable storage (= when you disconnect power no data is lost or corrupted). When you write to such a device your writes are first made in an earlier layer that is more like your computer’s main memory than actual storage (when you lose power your data is gone or corrupted). Only after time or when the cache is full an actual persistent write is made.