PLAIN/TEXT — ISSUE 293/456 COMPUTER SCIENCE · FOUNDATION / SOFTWARE SYSTEMS · ~4 MIN READING DATE: 2027-07-21 ARCHIVE: https://plaintext.click/newsletter/ SUBJECT: When does a saved file really survive a power cut? When does a saved file really survive a power cut? ================================================== / START HERE A programme can report a file write before it reaches lasting storage. A buffer is temporary storage collecting information before passing it onward. fsync is a request to the computer’s managing software to transfer a file’s changed data and associated records to its storage device and wait for completion. Handing information to a buffer is not the same as confirming that transfer. / WHY NOW “The write succeeded” and “this update will survive a sudden shutdown” are different claims. The distinction matters whenever an application promises that an acknowledged record is safely saved. / THE IDEA A typical write can copy bytes, small units of information, into a temporary memory area and return before the device transfer finishes. The operating system is the software managing that area and the computer’s other resources. That batching improves efficiency: several small changes can be handled together. But ordinary working memory loses its contents when power disappears. On Linux, fsync asks for the file’s outstanding changes to be transferred and waits until the device reports completion. The programme must check the result for failure. It must also flush any separate application-level buffer first; the operating system cannot synchronise bytes it has not yet received. / THE FORMAL IDEA application buffer → system write → successful fsync → acknowledge - The arrows specify an ordering for a simplified durability promise. They do not assign a fixed duration to any step. - “Acknowledge” means tell the caller that this record is committed under the stated storage guarantees. An error result is not equivalent to a successful completion. / RUN THE TINY EXAMPLE Change one thing. Predict what happens. An existing file receives record A, 100 bytes. Its write returns while the bytes remain in volatile memory, storage that loses contents without power. Power fails before synchronisation: A may be absent after restart. Change only failure timing: power now fails after successful fsync, with no later file changes. Under the assumed honest storage guarantees, A survives because the required transfer completed before the failure. Waiting moves the confirmation after a persistence boundary. It does not prevent the power failure. If synchronising takes an invented 4 milliseconds, acknowledging before it finishes hides that wait by accepting a different risk, not by performing the same guarantee faster. / SO WHAT? Batching ten records behind one flush can share the waiting cost, but callers must understand which batch has actually completed. Creating or renaming a file adds another subtlety: on Linux, making the file itself durable does not necessarily persist its containing directory entry. The relevant directory may need synchronisation too. / ONE CAVEAT Durability depends on filesystem, device, hardware and correctly reported completion. fsync is not a backup, and it does not make several arbitrary file writes one atomic application transaction. This is a conceptual sequence, not a complete crash-safe saving recipe. / KEEP THIS A durability promise should follow successful persistence confirmation, not merely the moment a programme handed bytes to a temporary buffer. / SOURCE TRAIL [1] Linux man-pages — fsync and directory persistence https://man7.org/linux/man-pages/man2/fsync.2.html NEXT: Why spinning twice as fast is more than twice the push --- HARD IDEAS. PLAIN TEXT. You are receiving this because you asked for one clear computer-science or physics idea each day. Unsubscribe: https://plaintext.click/unsubscribe View in browser: https://plaintext.click/newsletter/2027/07/2027-07-21-fsync-durability.html From: Plain/Text / Brickston Consulting · 30 N Gould St Ste N, Sheridan, WY 82801 US · knowledge@plaintext.click