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
// SPDX-License-Identifier: MIT OR Apache-2.0
//! Atomic file write pipeline: tempfile, fsync, rename, fsync directory.
//!
//! Workload: I/O-bound (single-file durable write + optional backup/journal).
//! Parallelism: none inside one write (ordered rename/fsync contract). Multi-file
//! callers (`backup`, `batch`, `delete`) fan out with rayon around this module.
//!
//! Three write strategies are available, selected automatically:
//!
//! - `WriteStrategy::Rename` — classic tempfile + `rename(2)` (atomic, but
//! destroys hardlinks and inode identity).
//! - `WriteStrategy::InPlace` — `ftruncate(0) + pwrite + fsync_data` on the
//! existing file descriptor (preserves inode and hardlinks, but NOT atomic
//! against a crash between truncate and write).
//! - `WriteStrategy::CopyBack` — like `InPlace` but with a journal sidecar
//! for crash recovery; slowest but most durable. (Reserved for v0.1.13.)
//!
//! The default policy is **auto-detect**: hardlinks and symlinks trigger
//! `InPlace` automatically, regular files use Rename. Pass
//! `WriteStrategy::Rename` explicitly via the `strategy` field of
//! `AtomicWriteOptions` to force the legacy behavior.
pub use ;
pub use ;
pub use ;
pub use ;
include!;