Skip to main content

fsync_directory

Function fsync_directory 

Source
pub fn fsync_directory(dir: &Path) -> Result<()>
Expand description

Fsync a directory to ensure file creation/deletion metadata is durable.

On ext4/XFS, creating or deleting a file writes the file data to disk but the directory entry may only be in the page cache. A power loss before the directory entry is persisted causes the file to “disappear” on reboot. Calling fsync on the directory fd ensures the metadata (filename, inode pointer) is on stable storage.