detached 60f7034

fix(faultfs): crash files in path order so power loss is reproducible per seed

commit
60f7034381d3325d5f09f4a999efc3a5bfff3359
author
brice · · 2026-10-10 02:10 UTC
parent
aeec46d
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
1 file · +5 -1
M internal/fsys/faultfs/faultfs.go +5 -1
@@ -15,9 +15,11 @@ import (
1515 "errors"
1616 "io"
1717 "io/fs"
18+ "maps"
1819 "math/rand/v2"
1920 "os"
2021 "path/filepath"
22+ "slices"
2123 "sort"
2224 "sync"
2325 "time"
@@ -175,8 +177,10 @@ func (f *FS) PowerLoss(o PowerLossOptions) {
175177 delete(f.files, p)
176178 }
177179 }
180+ // Crash files in path order so a seeded Rand gives reproducible results.
178181 seen := map[*node]bool{}
179- for _, n := range f.files {
182+ for _, p := range slices.Sorted(maps.Keys(f.files)) {
183+ n := f.files[p]
180184 if !seen[n] {
181185 seen[n] = true
182186 n.crash(o)
@@ -15,9 +15,11 @@ import (
15 "errors"15 "errors"
16 "io"16 "io"
17 "io/fs"17 "io/fs"
18+ "maps"
18 "math/rand/v2"19 "math/rand/v2"
19 "os"20 "os"
20 "path/filepath"21 "path/filepath"
22+ "slices"
21 "sort"23 "sort"
22 "sync"24 "sync"
23 "time"25 "time"
@@ -175,8 +177,10 @@ func (f *FS) PowerLoss(o PowerLossOptions) {
175 delete(f.files, p)177 delete(f.files, p)
176 }178 }
177 }179 }
180+ // Crash files in path order so a seeded Rand gives reproducible results.
178 seen := map[*node]bool{}181 seen := map[*node]bool{}
179- for _, n := range f.files {182+ for _, p := range slices.Sorted(maps.Keys(f.files)) {
183+ n := f.files[p]
180 if !seen[n] {184 if !seen[n] {
181 seen[n] = true185 seen[n] = true
182 n.crash(o)186 n.crash(o)

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 2

↑↓ moveenter openesc close