Comparison
| System Call | Target | Content |
|---|
sync | All files that are not sync | data + metadata |
fsync | Specific file descriptor | data + metadata |
fdatasync | Specific file descriptor | data |
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