Other use cases
Other use cases
Posted Mar 3, 2026 16:10 UTC (Tue) by farnz (subscriber, #17727)In reply to: Other use cases by epa
Parent article: The ongoing quest for atomic buffered writes
There's three notifications the kernel could give you:
- The data is visible to other readers, but not necessarily the storage device.
- The data is in the storage device's volatile cache, but not necessarily persistent.
- The device reports that the data has been persisted to the long-term storage medium, and absent a hardware issue, will be safe after a system restart.
The problem is that the second notification is not normally a lot more valuable than the first (they both mean "your data is not yet safe, but is visible to other readers", just with different values of "not yet safe"), while the third is costly (either you flush caches to convert "in the storage device's volatile cache" into "persisted", or you use a more expensive "forced unit access" write command, and prevent the device from doing its normal reordering optimizations on writes).
It's thus best for performance if you have to choose which notification of the three you get up-front, and accept the cost of asking for the "data is persisted" notification if you've chosen that one. It could, for example, be worth accepting the increased cost because you're writing to a USB 2.0 attached flash drive, and the resulting extra cost is minimal as compared to the cost of the write itself, and well worth it to avoid a long delay when the write is finished as the device becomes safe to remove, or it might be not worth the extra cost because you're writing to NVME storage, and the user won't remove it.
