Comparison

System CallTargetContent
syncAll files that are not syncdata + metadata
fsyncSpecific file descriptordata + metadata
fdatasyncSpecific file descriptordata

Detail

sync

void sync();
  • Queue every modified block buffers to the event queue
  • Will be call by the system on a regular interval (~30s)
  • Non-blocking

fsync

int fsync(int filedes);
  • Sync data and metadata of the designated file descriptor
  • Blocking

fdatasync

int fdatasync(int filedes);
  • Sync only the data of the designated file descriptor and neglect the metadata
  • Blocking