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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
// Copyright (c) 2026 2youg1 and the sprawling contributors
//! FaultFs: the second Vfs adapter โ a deterministic power-loss model
//!. Compiled for tests and for citysim under the
//! `fault` feature; never in a production build.
//!
//! The model is stricter than any real platform so the write discipline
//! it enforces holds on every platform (`crates/storage/spec/FaultFs.lean` ยง8-2):
//! - every file has two planes: `durable` (survives power loss) and
//! `live` (what the running process observes). `sync_data` promotes
//! live to durable; a power cut drops the unsynced delta, except a
//! `TornTail` prefix that models a torn write reaching the platter.
//! - a created file's directory entry survives only after `sync_dir` on
//! its parent โ even when its bytes were synced (stricter than POSIX).
//! - removals are instantly durable (simplification: the only remover is
//! tail recovery, and a resurrected empty segment is harmless โ reopen
//! tolerates it).
//! - the op hitting `cut_at_op` fails with "power lost"; the plan is then
//! consumed, so the same instance serves the powered reopen. Appends
//! land on `live` before the cut check so the tear can bite the very
//! write that died.
//!
//! Everything is explicit in [`FaultPlan`]; there is no randomness.
//! Fault plans: which write dies, and how.
use ;
use PathBuf;
/// How much of each file's unsynced delta the platter kept.
pub
pub