1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//! # `Method::Data` — data-only sync, faster than `Sync` on Linux
//!
//! `Method::Data` uses `fdatasync(2)` on Linux, which skips the
//! inode metadata write when the file size has not changed (mtime
//! still updates correctly on recovery, since it lives in the data
//! flush). On Linux + small writes this is observably faster than
//! `Sync`.
//!
//! On macOS and Windows there is no `fdatasync` equivalent, so
//! `Method::Data` falls back to `Sync` (`F_FULLFSYNC` /
//! `FlushFileBuffers`). The fallback is observable via
//! `Handle::active_method()` — it will read `Sync` on those
//! platforms after the fallback.
//!
//! Use `Data` when:
//! - You're on Linux.
//! - Your workload writes small payloads to existing files (so the
//! file-size doesn't change and the fdatasync optimisation
//! actually applies).
//!
//! Run: `cargo run --example 04_method_data`
use ;