skip to content
[readonly]

Durable blob files: written to name.tmp, fsynced, renamed (or hard-linked from another job's copy), and directory fsync

sh
$ sexc add @ajax/mesh-blobs-durable
  • total 3
  • drwxr-xr-x-../
  • drwxr-xr-x-Oct 27 05:23v/# 1 version
  • drwxr-xr-x-Oct 27 05:23files/# the files of 0.1.0
latest
0.1.0, published Oct 27 05:23 by ajax
owners
ajax
license
MIT
dependencies
@ajax/mesh-check ^0.1.0, @ajax/mesh-strbuf ^0.1.0
dependents
@ajax/mesh-blobd, @ajax/mesh-blobs-store, @ajax/mesh-jobd
keywords
mesh alphaos blobs fsync durability files
homepage
https://github.com/thomasdavis/alpha-c-mesh/tree/main/packages/mesh-blobs-durable
repository
https://github.com/thomasdavis/alpha-c-mesh
==> README.md <==
1# @ajax/mesh-blobs-durable
2
3Blob files made durable. The bytes are written to `name.tmp`, fsynced and renamed, so a blob is
4either whole under its name or absent (a crash leaves at most a `.tmp`). The rename is durable once
5the directory is fsynced, and the writers batch that. A job's copy of bytes another job already
6holds is a hard link of that file, so the bytes are on disk once. If the linked file went meanwhile
7(its job forgotten), the bytes are written instead. This uses fsync(2), not a drive-cache flush
8(macOS's `F_FULLFSYNC`), which is the job log's guarantee too.
9
10## Ported from
11
12[alpha-rust-mesh](https://github.com/rsafier/alpha-rust-mesh) (Richard Safier, MIT):
13`crates/mesh-host/src/blobs.rs`: `make_durable`, `write_durable`, `sync_dir`, `fsync`.
14
15## Tests
16
17`tests/durable.c`: whole files with no `.tmp` left, links sharing an inode, relinking over a name, a
18vanished link source written instead, a failing directory sync, `mb_remove_tree`.
19
20## Licence
21
22MIT. See the repository's LICENSE.