fdatasync
fdatasync is a file-synchronization operation that persists modified data and the metadata required to retrieve it, without requiring synchronization of all other file metadata.
File-size changes must be synchronized because retrieval depends on them; timestamp-only changes need not be. Data-only completion is therefore not metadata-free completion. Like file fsync, fdatasync does not establish persistence of its containing directory entry. Check errors before acknowledging a commit. [1]
Linux reports EIO for synchronization failures and can report ENOSPC or EDQUOT when allocation was deferred beyond write(). An EIO may concern another descriptor's writes to the same file. A successful buffered write is not a guarantee that later synchronization will succeed. [1]
A later successful synchronization is not evidence that previously lost data was reconstructed. In Rebello et al.'s Linux 5.2.11 fsync fault-injection study, failed-write pages could become clean, so retrying fsync need not resubmit them. This is evidence about post-failure recovery, not a measurement of every fdatasync implementation. [3]
Relations
- related
- fsync, msync, sync_file_range, Writeback error, O_DSYNC, O_SYNC, File truncation, Directory fsync, O_RSYNC
Advantages
- Can avoid metadata work that is unnecessary for data retrieval.
Limitations
- Not a transaction across files or a substitute for directory synchronization.
- Less required metadata work does not guarantee lower latency on every filesystem.
Citations
- Linux man-pages 6.19: fsync(2), fdatasync metadata requirements
- Rebello et al., Can Applications Recover from fsync Failures? USENIX ATC 2020, sections 3.2-3.3 and 5
Further reading
Sources & caveats
- The paper's file-system experiments used Linux 5.2.11 and targeted transient block-write faults; its results do not establish behavior for every later kernel or fdatasync path.